| [ Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]
STR #1420
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 2 - Low, e.g. a documentation error or undocumented side-effect |
Scope: | 2 - Specific to an operating system |
Subsystem: | Core Library |
Summary: | Fl_X::make() -- bad code? |
Version: | 1.1.7 |
Created By: | danh |
Assigned To: | matt |
Fix Version: | 1.1-current (SVN: v5423) |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | danh 07:37 Sep 05, 2006 |
| Fl_win32.cxx: line 1180 Here is the code:
static const char *first_class_name = 0L; const char *class_name = w->xclass(); if (!class_name) class_name = first_class_name; // reuse first class name used if (!class_name) class_name = "FLTK"; // default to create a "FLTK" WNDCLASS if (!first_class_name) { first_class_name = class_name; } ----------------- This caused problems in my program because the first class name was taken from w->xclass(), but that string was later deleted. This caused first_class_name to point to garbage.
I've fixed my problem by making sure this doesn't happen, but why not just copy the string to prevent this problem? | |
|
#2 | matt 00:10 Sep 06, 2006 |
| I updated the documentation accordingly. I believe that in 99.9% of all cases, Fl_Window::xclass() will be called with a static string, so there is no need to duplicate the constant. In those very few exceptions, it shoudl be easiest to call myWindow->xclass(strdup(myXClass); . The allocated memory will be cleared automatically on termination. | |
[ Return to Bugs & Features ]
|
| |