This commit makes the local, static drawing functions in the source
file available for subclasses by converting them to static protected
methods as requested by STR 2022.
The source and header files have been reformatted according to the
CMP, documentation for the new protected methods was added.
Source code *functionality* has not been changed.
This resolves and closes STR 2022.
Todo:
- investigate whether these drawing methods wouldn't better be
member functions and "convert" them if applicable
- investigate whether the internal struct FL_CHART_ENTRY could become
a local part of the Fl_Chart class, maybe Fl_Chart::Entry.
- rename private member variables with trailing underscore (see CMP)
Although the memory "leak" is not really an issue in this demo
program (memory is returned anyway), "fixing" the leak warning
issued by valgrind and address sanitizer demonstrates the new
feature to "bind" images.
Detected by valgrind :
==16102== Conditional jump or move depends on uninitialised value(s)
==16102== at 0x449A10: Drawing_Area::idle() (mandelbrot.cxx:143)
Helper function convert_crlf() from file fl_wayland_clipboard_dnd.cxx has been
repaired by commit a4b33f8 (13 jan 2023). But the same function was also in
file Fl_cocoa.mm. This commit moves the repaired code to class Fl_Screen_Driver
and has both fl_wayland_clipboard_dnd.cxx and Fl_cocoa.mm use it.
src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx:
- fix font_name_process() out of bounds memory access
- unify/align font_name_process() code (see also Xlib/xft)
- fix font name string allocation
src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
- unify/align font_name_process() code (see also Cairo_Graphics)
- fix font name string allocation
Todo: move common code to Fl_Graphics_Driver or another common file.
Error was reported by Address Sanitizer (ASAN) when picking a file.
Platform: Unix/Linux.
==1734703==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete []) on 0x607000108420
#0 0x7f3357d846ef in operator delete[](void*) ../../../../src/libsanitizer/asan/asan_new_delete.cc:168
#1 0x4e195f in Fl_Native_File_Chooser_Driver::strfree(char*) ../../src/Fl_Native_File_Chooser.cxx:262
...
0x607000108420 is located 0 bytes inside of 66-byte region [0x607000108420,0x607000108462)
allocated by thread T0 here:
#0 0x7f3357d0a3ed in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cc:445
#1 0x57951a in Fl_Kdialog_Native_File_Chooser_Driver::filter(char const*) ../../src/Fl_Native_File_Chooser_Kdialog.cxx:245
#2 0x4e14a0 in Fl_Native_File_Chooser::filter(char const*) ../../src/Fl_Native_File_Chooser.cxx:176
- replace strchr() with memchr() because buffer is not nul-terminated
- fix '*(p+1)' potentially accessing memory out of bounds
This fix also prevents
- multiple memmove() calls
- multiple searches from the beginning of the string
- add Fl_Scheme_Choice widget for quick scheme selection
- fix label alignment of selection box
- set selection_color()
- set selectbox()
- make the tree the resizable() of the window
This widget offers the selection of all known FLTK schemes as a simple
widget based on Fl_Choice.
Some test and demo programs use Fl_Scheme_Choice to enable the developer
or user to switch schemes quickly for comparison.
Todo:
- add features to add new schemes during runtime (partially done)
- update status when the scheme is changed by Fl::scheme("...")