FLTK logo

STR #1007

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 #1007

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:Fixes for GDI (mostly device context) leaks in 1.1.x on WIN32
Version:1.1-current
Created By:larry.finger.lwfinger
Assigned To:matt
Fix Version:1.1.7 (SVN: v4563)
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:


Name/Time/Date Filename/Size  
 
#1 larry.finger.lwfinger
20:09 Sep 01, 2005
patch-1.1.x-r4527
18k
 
 
#2 larry.finger.lwfinger
12:57 Sep 11, 2005
patch_1.1.x-r4558
18k
 
     

Trouble Report Comments:


Name/Time/Date Text  
 
#1 larry.finger.lwfinger
20:09 Sep 01, 2005
FLTK 1.1.x leaks Device Context (DC) objects when running on Windows. The reason for this is that when the ReleaseDC call is made, the state of the DC does not match its contents when it was obtained. For each of these, Windows issues only a warning, but the corresponding GDI object is leaked rather than deleted. The attached patch fixes all DC leaks, and fixes a few places where regions were leaked. In addition, it deletes cached fonts, brushes and pens at program exit to avoid the appearance of leaks when run under BoundsChecker, or other such programs. See forum discussions on GDI leaks. Note: The program must hide all windows and allow the return from Fl::run() for the cleanup at exit to function. An exit(0) statement will defeat this cleanup. fluid has been modified for this cleanup behavior.

Other fixes are as follows:
(1) Previously, the menuwindow destructor issued a 'delete title' to close the titlewindow. As the menuwindow is a child of the titlewindow, Windows deleted both. The next step, however, was to destroy menuwindow - At this point, Windows issued an error about an 'Invalid window handle'. The fix is to add a 'hide()' before the 'delete title' in ~menuwindow. That way the menuwindow is deleted first.

(2) Routine RegisterClassEx (which has nothing to do with C++ classes) was being called for each window created; however, the same ID was being used for all calls. After the first, an error was generated. A static true/false int has been added to run the call only for the first window created.

With these changes, a run of fluid that loads CubeViewUI.fi and opens and closes every widget window does not generate any errors or warnings, and leaks only 1 pen and 1 brush at exit. The same run on unmodified 1.1.x-r4527 code generates 74 errors.

The patch was generated using 1.1.x-r4527, but it applies with only some offsets against 1.1.x-r4537.
 
 
#2 matt
01:19 Sep 06, 2005
This patch changes the size of class Fl_X by adding a new member which may make the library binary incompatible. Mike, others, can we allow that, since Fl_X is an 'internal' structure?  
 
#3 mike
06:49 Sep 06, 2005
Fl_X is an internal structure. I'd still recommend adding the new saved_hdc to the end of it rather than the middle, in case any apps *do* use Fl_X for OS-specific stuff.

The "Remove_Win_Fonts" function needs to be renamed to conform to our coding specs, especially since it is polluting the global namespace... Perhaps "fl_free_fonts" would be a better name???
 
 
#4 larry.finger.lwfinger
13:03 Sep 11, 2005
I found a couple of places where simple projects would crash with an empty saved DC list. I also renamed the global routines to meet with the coding conventions. I have attached a new file to patch fltk-1.1.x-r4558.

Larry
 
 
#5 matt
16:04 Sep 12, 2005
Applied second patch by hand. OP: could you please check if all changes were made correctly? Thanks!

Thanks for the patch! This is a great help!
 
     

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'.