FLTK logo

STR #828

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

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:WIN32
Summary:fl_font_win32.cxx: fl_draw segfault
Version:1.1-current
Created By:av_pete
Assigned To:mike
Fix Version:1.1-current (SVN: v4329)
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text  
 
#1 av_pete
23:47 Apr 22, 2005
fltk-1.1.x-r4229 (win32): fl_draw() will segfault if the static fl_fontsize variable is NULL.

nb: all other fl_font_win32.cxx functions check fl_fontsize before dereference. e.g. fl_width().

preventative solution: add a fl_fontsize check before calling SelectObject. this will cause the default operating system font to be displayed if fl_fontsize is NULL.

void fl_draw(const char* str, int n, int x, int y) {
  COLORREF oldColor = SetTextColor(fl_gc, fl_RGB());
  if (fl_fontsize) SelectObject(fl_gc, fl_fontsize->fid);
  ^^^^^^^^^^^^^^^^
  TextOut(fl_gc, x, y, str, n);
  SetTextColor(fl_gc, oldColor);
}
 
 
#2 mike
06:37 May 12, 2005
Fixed in Subversion repository.

Note, however, that strictly speaking your code was broken, not FLTK (the API requires that you set a font first)
 
     

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