| [ Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]
STR #295
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 2 - Low, e.g. a documentation error or undocumented side-effect |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Core Library |
Summary: | Fl_Text_Display does not delete Text_Buffer and crashes if pass NULL |
Version: | 1.1.4 |
Created By: | jedimasterthrash |
Assigned To: | mike |
Fix Version: | 1.1.5rc1 |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | jedimasterthrash 15:00 Feb 24, 2004 |
| Fl_Text_Display always calls a function on its Text_Buffer during destruction, which means that you can't delete your Fl_Text_Buffer prior to the Fl_Text_Display instance destruction.
The problem is that if your Fl_Text_Display is in a group as part of a Window, then Fl_Text_Display gets destructed after your inherited class's destructor is done, which means you have no chance to delete the Text_Buffer (for both of us in the world who diligently clean up all of our mess).
The first solution would be to disassociate the Text_Buffer from the Text_Display prior to its destruction. However, if you pass NULL to Text_Display::buffer(), the function crashes because it calls a function on the buffer (NULL) without checking to see if the parameter is NULL first.
The only solution that works is to remove the Text_Display from the window prior to its destruction, which allows you to manually delete the Display and then manually delete the Buffer after it. remove(pTextEditor); delete pTextEditor; delete pTextBuffer;
My recommended fix would be to have Text_Display delete the Text_Buffer, though I guess this conflicts with allowing a single buffer to be used in multiple editors. I would then recommend adding reference counting to the Buffer. Any object whose pointer could be owned by multiple other objects should have reference counting. Then the buffer can delete itself once all its outstanding references have been released.
Thanks.
| |
|
#2 | mike 17:52 Feb 29, 2004 |
| Updated ::buffer() to check that the new buffer is non-NULL. | |
|
#3 | mike 17:52 Feb 29, 2004 |
| Fixed in CVS - the anonymous CVS repository will be updated at midnight PST. | |
[ Return to Bugs & Features ]
|
| |