Dialogs in library (NPAPI plugin) lazarus / 31-LCL ---------------------------------------------------------------------- Arvur · 2014-09-26 11:40 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 · 2014-09-26 12:06 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). ---------------------------------------------------------------------- Arvur · 2014-09-26 12:19 Quote from: Mike.Cornflake on September 26, 2014, 02:06:53 pmFor 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 · 2014-09-26 12:51 Quote from: Arvur on September 26, 2014, 02:19:28 pmQuote from: Mike.Cornflake on September 26, 2014, 02:06:53 pmFor 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.ht ml#msg143967 Err, maybe less useful http://forum.lazarus.freepascal.org/index.php/topic,24882.msg150337.ht ml#msg150337 I'm running out of steam here I'm afraid... ---------------------------------------------------------------------- taazz · 2014-09-26 13:03 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. ---------------------------------------------------------------------- BigChimp · 2014-09-26 13:04 @taazz: Quote from: Arvur on September 26, 2014, 01:40:27 pmI'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 ---------------------------------------------------------------------- Arvur · 2014-09-26 13:24 Yes. It is library (dll in Windows, so in Linux). Quote from: Mike.Cornflake on September 26, 2014, 02:51:13 pmHere's one: http://forum.lazarus.freepascal.org/index.php/topic,23987.msg143967.ht ml#msg143967 Err, maybe less useful http://forum.lazarus.freepascal.org/index.php/topic,24882.msg150337.ht ml#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. Quote from: BigChimp on September 26, 2014, 03:04:44 pmEdit: 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 · 2014-09-26 16:34 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 ---------------------------------------------------------------------- Arvur · 2014-09-28 09:49 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: Quote from: Arvur on September 26, 2014, 03:24:26 pmIt 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 · 2014-09-28 10:06 Quote from: Arvur on September 28, 2014, 11:49:56 amWhat 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? ---------------------------------------------------------------------- Arvur · 2014-09-28 11:14 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. Quote from: Mike.Cornflake on September 28, 2014, 12:06:05 pmHow 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 · 2014-09-28 11:55 QuoteAnd 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 ---------------------------------------------------------------------- zeljko · 2014-09-28 12:51 Quote from: Arvur on September 26, 2014, 01:40:27 pmI'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 · 2014-09-28 14:40 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 ---------------------------------------------------------------------- Mike.Cornflake · 2014-09-28 17:11 Quote from: Arvur on September 28, 2014, 01:14:10 pmUnfortunately 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. Quote from: Mike.Cornflake on September 28, 2014, 12:06:05 pmHow 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? ---------------------------------------------------------------------- Fred vS · 2014-09-28 18:43 Quote  Maybe dll's need another way?   Anyone any ideas? Hum, for dll's, to compile it, i use terminal (or Geany), => fpc mydll.pas  Sometimes, i use a extrafpc.cfg file and that fpc parameter =>  fpc mydll.pas @extrafpc.cfg ---------------------------------------------------------------------- Mike.Cornflake · 2014-09-28 18:45 Quote from: Fred vS on September 28, 2014, 08:43:14 pmQuote  Maybe dll's need another way?   Anyone any ideas? Hum, for dll's, to compile it, i use terminal (or Geany), => fpc mydll.pas  The question was not how to compile, but how to tell the dll which widgetset for the dll to use when it's including the LCL.   Sorry if that wasn't clear. ---------------------------------------------------------------------- Fred vS · 2014-09-28 18:50 QuoteThe question was not how to compile, but how to tell the dll which widgetset for the dll to use when it's including the LCL.   Sorry if that wasn't clear. Ooops, ok, i get it. Hum, i have (hard) try to use lcl or interface with dll. => i never was able to do it work. Sorry to come back ... but with pure fpGUI (not the one of LCL), it is easy to do graphical-return libraries... ---------------------------------------------------------------------- Fred vS · 2014-09-28 19:02 Quote  Maybe dll's need another way?   Anyone any ideas? Now you're all going to hate me... but i think it is a bad idea to use lcl for a library.