Recent

Author Topic: Dialogs in library (NPAPI plugin)  (Read 11008 times)

Arvur

  • New Member
  • *
  • Posts: 48
    • My GitHub
Dialogs in library (NPAPI plugin)
« on: September 26, 2014, 01:40:27 pm »
I'm compiling Firefox/Opera plugin in Linux Mint with Lazarus and FPC built from trunk.
It works in Windows already. There are some ShowMessage and InputQuery calls. They work fine in Windows.

But it does not work in Linux. If I add Interfaces unit and LCL package to project - plugin stops loading into browser. Without them it is loaded Ok (I've commented out those calls to Dialogs unit).

I've tried different widgetsets - gtk/qt/fpgui. No way.
When I use code from this wiki page http://wiki.lazarus.freepascal.org/X11#A_window_with_a_message a window is shown normally.
So I guess the problem is not in browser security but somewhere in LCL.

Unfortunatelly I didn't manage to debug code in Lazarus. Setting firefox/opera as host application leads to gdb failure. And the browser is not even launched.

Is this a known issue? Maybe someone can tell me how to use dialogs in browser plugin?
Or perhaps some ideas how I can investigate this deeper?

Thanks!

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1251
Re: Dialogs in library (NPAPI plugin)
« Reply #1 on: September 26, 2014, 02:06:53 pm »
Short answer - I've absolute no idea :-(

For the Linux side of the plugin - are you compiling directly on Linux, or cross-compiling?   

While cross-compiling shouldn't be a problem, I recently came across a situation (now resolved) where some code was using {$ifdef gtk2} and assuming the subsequent environment would be Linux (so of course the code failed under Windows/gtk2).   
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

Arvur

  • New Member
  • *
  • Posts: 48
    • My GitHub
Re: Dialogs in library (NPAPI plugin)
« Reply #2 on: September 26, 2014, 02:19:28 pm »
For the Linux side of the plugin - are you compiling directly on Linux, or cross-compiling?   
Directly on Linux, Mike. It is in VirtualBox but I suppose it does not matter.

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1251
Re: Dialogs in library (NPAPI plugin)
« Reply #3 on: September 26, 2014, 02:51:13 pm »
For the Linux side of the plugin - are you compiling directly on Linux, or cross-compiling?   
Directly on Linux, Mike. It is in VirtualBox but I suppose it does not matter.
Rats - that was the only idea I had.

No wait.. - this plugin - is it in a dll by any chance (or so I guess under Linux)?   There's some threads around here about various LCL components failing in dll's...  Hang on, I'll see if I can dig them out...

Here's one:
http://forum.lazarus.freepascal.org/index.php/topic,23987.msg143967.html#msg143967

Err, maybe less useful
http://forum.lazarus.freepascal.org/index.php/topic,24882.msg150337.html#msg150337

I'm running out of steam here I'm afraid...
« Last Edit: September 26, 2014, 02:55:42 pm by Mike.Cornflake »
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

taazz

  • Hero Member
  • *****
  • Posts: 5364
Re: Dialogs in library (NPAPI plugin)
« Reply #4 on: September 26, 2014, 03:03:16 pm »
How about giving a go on fpgui instead. It might not be as integrated in lazarus as CD but I guess that it is custom painted and should have dialogs implemented for linux, better make sure it does before spending any time.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Dialogs in library (NPAPI plugin)
« Reply #5 on: September 26, 2014, 03:04:44 pm »
@taazz:
I've tried different widgetsets - gtk/qt/fpgui. No way.

Edit: oh you probably mean pure fpgui instead of the Lazarus fpgui widgetset? Yes, that may be a good idea!
http://wiki.lazarus.freepascal.org/fpGUI
« Last Edit: September 26, 2014, 03:07:55 pm by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Arvur

  • New Member
  • *
  • Posts: 48
    • My GitHub
Re: Dialogs in library (NPAPI plugin)
« Reply #6 on: September 26, 2014, 03:24:26 pm »
Yes. It is library (dll in Windows, so in Linux).

Here's one:
http://forum.lazarus.freepascal.org/index.php/topic,23987.msg143967.html#msg143967

Err, maybe less useful
http://forum.lazarus.freepascal.org/index.php/topic,24882.msg150337.html#msg150337
Application.Initialize didn't help. Also tried this solution: http://bugs.freepascal.org/view.php?id=16611 - plugin hangs on ShowModal call.
The second link seems interesting! I'll give it a try.

Edit: oh you probably mean pure fpgui instead of the Lazarus fpgui widgetset? Yes, that may be a good idea!
I tried both, widgetset and pure package ((
It is very strange. Since fpGUI uses X11 directly it should do the trick. I think I will try pure fpgui once more. Very-very carefully. Perhaps with some simple demo plugin.

Fred vS

  • Hero Member
  • *****
  • Posts: 2524
    • StrumPract is the musicians best friend
Re: Dialogs in library (NPAPI plugin)
« Reply #7 on: September 26, 2014, 06:34:36 pm »
Hello.

You may try this fpGUI example =>

https://sites.google.com/site/fiensprototyping/fpguitest_java.tar.gz


This is a Java-compatible native library demo showing dialogs.
This is pure fpGUI (no use of Interface nor LCL).

If you want "classical" native library, there are (very few) things to change in library code: =>

Java Native Library :
Code: [Select]
procedure MainProc(PEnv: pointer; Obj: pointer); cdecl;
...
exports
MainProc name 'Java_filedialog_mainproc';
end.

vs Classical Native Library:
Code: [Select]
procedure MainProc(); cdecl;
...
exports
MainProc name 'mainproc';
end.

Fred
« Last Edit: September 26, 2014, 07:03:57 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs

Arvur

  • New Member
  • *
  • Posts: 48
    • My GitHub
Re: Dialogs in library (NPAPI plugin)
« Reply #8 on: September 28, 2014, 11:49:56 am »
Ah! If I run Opera from console I can see some errors.
Code: [Select]
TRasterImage.BitmapHandleNeeded: Unable to create handles, using default
ERROR in LCL: TWinControl.CreateWnd: The nogui widgetset does not support visual controls.
Creating gdb catchable error:

  $B58199AB  TLAZLOGGER__DEBUGLNSTACK,  line 720 of lazloggerbase.pas
  $B57E68D7  DUMPSTACK,  line 1414 of lclproc.pas
  $B57E518A  RAISEGDBEXCEPTION,  line 859 of lclproc.pas
  $B58ADF60  TWINCONTROL__CREATEWND,  line 7358 of ./include/wincontrol.inc
  $B576B691  TSCROLLINGWINCONTROL__CREATEWND,  line 23 of ./include/scrollingwincontrol.inc
  $B5771D67  TCUSTOMFORM__CREATEWND,  line 2587 of ./include/customform.inc
  $B5772DA8  TFORM__CREATEWND,  line 3050 of ./include/customform.inc
  $B58AD931  TWINCONTROL__CREATEHANDLE,  line 7264 of ./include/wincontrol.inc
  $B58AEA91  TWINCONTROL__HANDLENEEDED,  line 7710 of ./include/wincontrol.inc
opera [crash logging]: CRASH!!
/usr/lib/opera/pluginwrapper/operapluginwrapper-native got signal SIGSEGV at address 00000000
What is "nogui widgetset"???

And concerning fpGUI:
It is very strange. Since fpGUI uses X11 directly it should do the trick. I think I will try pure fpgui once more. Very-very carefully. Perhaps with some simple demo plugin.
I've tried fpgui once more. Very simple plugin - only exported procedures that write to syslog their names.
If I add fpg_dialogs to uses clause and call ShowMessage the plugin crashes.
Running Opera from console gives this exception with no details
Code: [Select]
opera [crash logging]: CRASH!!
/usr/lib/opera/pluginwrapper/operapluginwrapper-native got signal SIGSEGV at address B58BC030

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1251
Re: Dialogs in library (NPAPI plugin)
« Reply #9 on: September 28, 2014, 12:06:05 pm »
What is "nogui widgetset"???

Nicely found.  Nogui is one of the widgetsets available.  From memory, it essentially doesn't allow handles, and I think it's used for building dlls that want to call various lcl routines, but which don't want the GUI overhead of including those units.  Whatever the nogui widgetset is, it's obvious that at least part of your build process doesn't know about the widgetset that you actually want to use. 

I've never developed dll's before.  How are you telling Lazarus which widgetset you want to use?   Maybe there's other options for dll's?
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

Arvur

  • New Member
  • *
  • Posts: 48
    • My GitHub
Re: Dialogs in library (NPAPI plugin)
« Reply #10 on: September 28, 2014, 01:14:10 pm »
Unfortunately I can not reproduce this message. And now I can not even tell which widgetset it was compiled wit. But for sure I didn't chose nogui.

How are you telling Lazarus which widgetset you want to use? Maybe there's other options for dll's?
In Project Options -> Compiler Options -> Additions and Overrides. There I use "Set LCLWidgetType" button. Is that correct?

Fred vS

  • Hero Member
  • *****
  • Posts: 2524
    • StrumPract is the musicians best friend
Re: Dialogs in library (NPAPI plugin)
« Reply #11 on: September 28, 2014, 01:55:24 pm »
Quote
And concerning fpGUI:
Quote from: Arvur on September 26, 2014, 03:24:26 pm

    It is very strange. Since fpGUI uses X11 directly it should do the trick. I think I will try pure fpgui once more. Very-very carefully. Perhaps with some simple demo plugin.

I've tried fpgui once more. Very simple plugin - only exported procedures that write to syslog their names.
If I add fpg_dialogs to uses clause and call ShowMessage the plugin crashes.
Running Opera from console gives this exception with no details
Code: [Select]

opera [crash logging]: CRASH!!
/usr/lib/opera/pluginwrapper/operapluginwrapper-native got signal SIGSEGV at address B58BC030


Have you try the library example i give with your application ?
https://sites.google.com/site/fiensprototyping/fpguitest_java.tar.gz

How do you call the fpGUI procedure in your program (Opera ?).
Have you exported the fpGUI procedure as a native library ?

And, please, could you give the code that you use ?

[EDIT] Here how to install fpGUI =>
http://wiki.freepascal.org/fpGUI

Thanks.

Fred
« Last Edit: September 28, 2014, 02:18:22 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs

zeljko

  • Hero Member
  • *****
  • Posts: 1206
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Dialogs in library (NPAPI plugin)
« Reply #12 on: September 28, 2014, 02:51:27 pm »
I'm compiling Firefox/Opera plugin in Linux Mint with Lazarus and FPC built from trunk.
It works in Windows already. There are some ShowMessage and InputQuery calls. They work fine in Windows.

But it does not work in Linux. If I add Interfaces unit and LCL package to project - plugin stops loading into browser. Without them it is loaded Ok (I've commented out those calls to Dialogs unit).

I've tried different widgetsets - gtk/qt/fpgui. No way.
When I use code from this wiki page http://wiki.lazarus.freepascal.org/X11#A_window_with_a_message a window is shown normally.
So I guess the problem is not in browser security but somewhere in LCL.

Unfortunatelly I didn't manage to debug code in Lazarus. Setting firefox/opera as host application leads to gdb failure. And the browser is not even launched.

Is this a known issue? Maybe someone can tell me how to use dialogs in browser plugin?
Or perhaps some ideas how I can investigate this deeper?

Thanks!

stdcall must be cdecl under linux (if U use it) ?

Fred vS

  • Hero Member
  • *****
  • Posts: 2524
    • StrumPract is the musicians best friend
Re: Dialogs in library (NPAPI plugin)
« Reply #13 on: September 28, 2014, 04:40:15 pm »
Hello.

Here demo of "classical" native library, loaded by a Python script.
https://sites.google.com/site/fiensprototyping/fpguitest_native.tar.gz

The binaries are compiled with Mint 64 bit.

One binary is the program-demo,
The other is the library-demo. (that should give the same result as the program).

That library-demo has only one export procedure, to show some dialog boxes of fpGUI.

To run the python-script, in terminal do :=>

cd fpguitest_native (go in demo directory)

python filedialog.pyw


Plese read ReadMe.txt to re-compile.

PS: Here how to install fpGUI =>
http://wiki.freepascal.org/fpGUI


Fred
« Last Edit: September 28, 2014, 04:47:36 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1251
Re: Dialogs in library (NPAPI plugin)
« Reply #14 on: September 28, 2014, 07:11:38 pm »
Unfortunately I can not reproduce this message. And now I can not even tell which widgetset it was compiled wit. But for sure I didn't chose nogui.

How are you telling Lazarus which widgetset you want to use? Maybe there's other options for dll's?
In Project Options -> Compiler Options -> Additions and Overrides. There I use "Set LCLWidgetType" button. Is that correct?

Well, that's how I do it for apps.  Maybe dll's need another way?   Anyone any ideas?
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

 

TinyPortal © 2005-2018