2013-11-25 22:05, John Emmas skrev:
Hi Kjell,
Many thanks for sending me your versions of those files. The good
news is that with only the exception of some commented sections, your
versions are identical to mine. Both versions exhibit the same
behaviour (and unfortunately, the same problems).
I'm wondering now if I've been fooling myself to think that this
SpinButton/Adjuster issue is somehow related to the previous one that
got solved. For various reasons it does look a bit similar - but I'm
now starting to think that the SpinButton/Adjuster problem is actually
a clearly defined issue in its own right. The reason I'm wondering is
that this sequence crashes:-
Create a SpinButton
Create an Adjustment
Attach the Adjustment to the SpinButton
Delete the Adjustment
Delete the SpinButton // Remember that the (deleted)
Adjustment is still attached !!
The previous sequence is the case I have tested without a crash. You can
see the result in the gdb output gdblog1.txt that I sent to you.
When the destructor Gtk::Adjustment::~Adjustment() executes,
disconnect_cpp_wrapper() is called and it calls
g_object_steal_qdata((GObject*)gobj(), Glib::quark). Because
Glib::quark_ is removed, Glib::ObjectBase::destroy_notify_callback_()
and Gtk::Object::destroy_notify_() is not called for the Adjustment.
In
https://mail.gnome.org/archives/gtkmm-list/2013-November/msg00052.html
you said that the crash occurs when gtk_spin_button_finalize() calls
gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(object), NULL).
Let me guess: The crash occurs when gtk_spin_button_set_adjustment()
calls g_object_unref(spin_button->adjustment). This is where the
GtkAdjustment looses its last reference, and it's finalized. Then
Glib::ObjectBase::destroy_notify_callback_() will *not* be called, if
Glib::quark_ has been removed. If the GQuark functions don't work
correctly for you, and Glib::quark_ has not been removed, then
Glib::ObjectBase::destroy_notify_callback_() is called, and your program
crashes.
Remember also that you reported strange contents in a list of GQuarks in
another test program in
https://mail.gnome.org/archives/gtkmm-list/2013-November/msg00022.html.
OTOH this sequence doesn't crash:-
Create a SpinButton
Create an Adjustment
Attach the Adjustment to the SpinButton
Delete the SpinButton // Adjustment hasn't been deleted yet !!
Delete the Adjustment
But wait a minute... during my tests I discovered some evidence to
suggest that this sequence wouldn't crash either:-
Create a SpinButton
Create an Adjustment
Attach the Adjustment to the SpinButton
Detach the Adjustment (using
'Gtk::SpinButton::unset_adjustment()')
Delete the Adjustment // These two deletions can now
Delete the SpinButton // get done (safely) in either order
So I guess I'm questioning the safety of deleting a Gtk::SpinButton
whilst it has an (invalid) Gtk::Adjustment attached. I don't know
enough about the gtkmm spec to know whether that should (or should
not) be safe. It certainly isn't safe at present, from what I can
tell. Would it help for me to try the same thing with a plain GTK+
app? If it's safe to do with GTK+ I'd assume it should also be safe
with gtkmm....
John
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list