FLTK logo

[fltk.general] Cleaning up Fl_Text_Buffer

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Cleaning up Fl_Text_Buffer Rob McDonald Dec 24, 2021  
 
I have a class derived from Fl_Double_Window.

That Fl_Double_Window has a Fl_Group that ends up holding an Fl_Text_Display.

The class also has a Fl_Text_Buffer associated with the Fl_Text_Display.

I am working on the destructor for my class.

If I call delete on the Fl_Text_Buffer, then the Buffer is destroyed before the Fl_Text_Display destructor gets called (through the Fl_Double_Window and Fl_Group destructors).

I've tried setting the Fl_Text_Display's buffer to NULL before destructing the buffer.  This seems to 'work', but also seems extremely hacky.

Foo::~Foo()
{
    m_Display->buffer( NULL );
    delete m_Buffer;
}

Is this the proper way to clean up in this situation?

I might be able to make the Fl_Text_Buffer a direct member variable (instead of a pointer allocated with new), but I can still imagine situations where this would arise.

Am I missing something?

Rob

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/bd9a4810-5f42-4763-9a3e-56e3efef2984n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

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