STR #1420

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 ]

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:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text top right image
 
#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.  
bottom left image   bottom right image

Return to Bugs & Features ]

 
 

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