On 3/20/2024 2:26 PM, 'Albrecht Schlosser' via fltk.coredev wrote:
On 3/20/24 17:53 Gonzalo Garramulo wrote:
Okay. After digging, I found what it was. I was subclassing
Fl_Text_Display and initializing its Fl_Text_Buffer in the constructor
like:
mBuffer = new Fl_Text_Buffer();
instead of calling the textdisplay->buffer() function. It turns out
textdisplay->buffer() sets a callback that counts lines when
wrap_mode() is not set to WRAP_AT_BOUNDS. Changing my code to:
Fl_Text_Buffer* buf = new Fl_Text_Buffer();
buffer(buf);
Find attached a sample program for testing.
I'm glad you found the issue.
FTR: The only thing we could do in FLTK to prevent such kinds of errors
would be to make some of the protected members private but
Fl_Text_Display is such a "beast" that I wouldn't want to open that can
of worms.
I thought the same, and was about to suggest it. But... you can have
multiple shared Fl_Text_Buffers or a single one used in one
Fl_Text_Display and you might want to delete them in the destructor like
I do. Making the variables private would prevent you from deleting them.
I think the best solution would be to document this with a note in the
buffer() function.
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.