I have a custom GTK+ widget which I am compiling in a C++ file (instead of C). Most of the code is the C subset of C++. The application seems to run fine. (Right now it merely displays a top-level window with the widget in it.) However, I have included a destructor in the widget structure and noticed that the destructor is never called.
- What should I do (short of using gtkmm) in order to ensure that the destructor is called?
- What are the other consequences I should be aware of when implementing a GTK+ widget in C++?
GTK uses object oriented C, where the Object oriented part is visualized using function pointers. so if you can cache your this pointer with C side code of gtk widget, then here is more info…
if you are running out of time, then take a review of this example… Look for gtk_cpu_destroy in this example, the following code set the function pointer in widget.
beside gtkmm, there also exist gfc project, which i think is cleaner, and easier to understand…
my query is if your custom widget is really gtk widget or gdk widget… not all events of gdk are handled in gtkmm(or at least they were not back in 2009), thus beware that your application may crash too often, if your widget is extensively using gdk, and gdk events are not trapped. tools like systemtap might help you to trap the events causing problem.