FLTK logo

STR #177

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]

STR #177

Application:FLTK Library
Status:1 - Closed w/Resolution
Priority:3 - Moderate, e.g. unable to compile the software
Scope:2 - Specific to an operating system
Subsystem:WIN32
Summary:Win32/RegisterWindowClass, two FLTKstatic-linked DLL loaded to one app cause crash
Version:1.1.4
Created By:gyohng.netscape
Assigned To:mike
Fix Version:Will Not Fix
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text  
 
#1 gyohng.netscape
11:31 Oct 01, 2003
A crash happens, if side application is loading 2 different dll, and both of dlls have FLTK linked statically.

1. App loads DLL1
2. App shows DLL1 window
3.     DLL1 registers window class 'FLTK'
4.     DLL1 uses class 'FLTK' to show window
5. App loads DLL2
6. App shows DLL2 window
7.     DLL2 registers class 'FLTK' (ignored by windows - class exists)
8.     DLL2 uses class 'FLTK' from DLL1
9. DLL1's WndProc is fooled with Fl_Window, belonging to DLL2
10.Crash!

Fix, file Fl_win32.cxx:

   const char* class_name = /*w->xclass();
   if (!class_name) class_name =*/ "FLTK"; // create a "FLTK" WNDCLASS

   const char* message_name = "FLTK::ThreadWakeup";

+  UnregisterClass(class_name,fl_display);
   WNDCLASSEX wc;
   // Documentation states a device context consumes about 800 bytes

No side effects found. Please, apply.

 
 
#2 gyohng.netscape
18:23 Oct 13, 2003
Side effect of patch found. Though application doesn't crash,  it doesn't show valid interface on the concurrently opened window from the second DLL (shows blank).

This happens only when ONE application loads TWO dll files, and both DLL files have FLTK linked statically.
 
 
#3 gyohng.netscape
19:20 Oct 21, 2003
Problem is solved by assigning fl_display to hInstance, which is passed to DllMain (#ifdef WIN32)

GetModuleHandle indeed returns instance of a parent executable, and not hInstance of a DLL module (which has FLTK linked statically).

Wonder if there could be any intelligent workaround for this?
 
 
#4 mike
17:39 Oct 31, 2003
All I can recommend is to link both DLLs and the app against the FLTKDLL library...  
 
#5 matt
14:42 Apr 22, 2008
It is generally impossible to link the same library statically more than once because all application-wide variables will exist multiple times as well.  
     

Return to Bugs & Features ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.