Re: Gtk::SpinButton crash




2013-11-22 18:45, John Emmas skrev:
This crashes:-

        Gtk::SpinButton some_spin_button;
        Gtk::Adjustment some_adjuster (2, 0, 100, 1, 10, 0);
        some_spin_button.set_adjustment (some_adjuster);
That's what I have now once again tested with 2.24.4 without extra patches. No crash!

I've used gdb, and set breakpoints at Gtk::Object::disconnect_cpp_wrapper() and Glib::ObjectBase::destroy_notify_callback_().
Here's the result:

(gdb) break Gtk::Object::disconnect_cpp_wrapper
Breakpoint 1 at 0x7ffff7a408b0: file object.cc, line 186.

(gdb) break Glib::ObjectBase::destroy_notify_callback_
Breakpoint 2 at 0x7ffff7315300: file objectbase.cc, line 206.

(gdb) run

Breakpoint 1, Gtk::Object::disconnect_cpp_wrapper (this=this entry=0x7fffffffd7f0) at object.cc:186
186    {
(gdb) bt
#0  Gtk::Object::disconnect_cpp_wrapper (this=this entry=0x7fffffffd7f0) at object.cc:186
#1  0x00007ffff7a409d8 in Gtk::Object::_destroy_c_instance (this=0x7fffffffd7f0) at object.cc:108
#2  0x00007ffff7a40be1 in Gtk::Object::destroy_ (this=<optimized out>) at object.cc:264
#3  0x00007ffff79fb624 in Gtk::Adjustment::~Adjustment (this=0x7fffffffd7f0,
    __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at adjustment.cc:224
#4  0x0000000000404ffc in MyDialog::MyDialog (this=0x6ac020, title=..., modal=true,
    use_separator=true, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at main.cc:15
#5  0x00000000004050fe in main (argc=1, argv=0x7fffffffd9c8) at main.cc:23
(gdb) next
195      if(gobj())
(gdb)
198        g_object_steal_qdata((GObject*)gobj(), Glib::quark_); //It will no longer be possible to get the C++ instance from the C instance.
(gdb)
201        g_object_set_qdata((GObject*)gobj(), Glib::quark_cpp_wrapper_deleted_, (gpointer)true);
(gdb)
204        gobject_ = 0;
(gdb) cont
Continuing.

Breakpoint 1, Gtk::Object::disconnect_cpp_wrapper (this=this entry=0x7fffffffd830) at object.cc:186
186    {
(gdb) bt
#0  Gtk::Object::disconnect_cpp_wrapper (this=this entry=0x7fffffffd830) at object.cc:186
#1  0x00007ffff7a409d8 in Gtk::Object::_destroy_c_instance (this=0x7fffffffd830) at object.cc:108
#2  0x00007ffff7a40be1 in Gtk::Object::destroy_ (this=<optimized out>) at object.cc:264
#3  0x00007ffff7a62885 in Gtk::SpinButton::~SpinButton (this=0x7fffffffd830,
    __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at spinbutton.cc:432
#4  0x0000000000405008 in MyDialog::MyDialog (this=0x6ac020, title=..., modal=true,
    use_separator=true, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at main.cc:16
#5  0x00000000004050fe in main (argc=1, argv=0x7fffffffd9c8) at main.cc:23
(gdb) next
195      if(gobj())
(gdb)
198        g_object_steal_qdata((GObject*)gobj(), Glib::quark_); //It will no longer be possible to get the C++ instance from the C instance.
(gdb)
201        g_object_set_qdata((GObject*)gobj(), Glib::quark_cpp_wrapper_deleted_, (gpointer)true);
(gdb)
204        gobject_ = 0;
(gdb) cont
Continuing.

Breakpoint 1, Gtk::Object::disconnect_cpp_wrapper (this=this entry=0x6ac020) at object.cc:186
186    {
(gdb) bt
#0  Gtk::Object::disconnect_cpp_wrapper (this=this entry=0x6ac020) at object.cc:186
#1  0x00007ffff7aa1d45 in Gtk::Window::_destroy_c_instance (this=0x6ac020) at window.cc:124
#2  0x00007ffff7aa1d91 in Gtk::Window::destroy_ (this=<optimized out>) at window.cc:104
#3  0x00007ffff7a1817f in Gtk::Dialog::~Dialog (this=0x6ac020,
    __vtt_parm=0x405728 <VTT for MyDialog+8>, __in_chrg=<optimized out>) at dialog.cc:226
#4  0x00000000004051e2 in MyDialog::~MyDialog (this=0x6ac020, __in_chrg=<optimized out>,
    __vtt_parm=<optimized out>) at main.cc:6
#5  0x00000000004052b4 in MyDialog::~MyDialog (this=0x6ac020, __in_chrg=<optimized out>,
    __vtt_parm=<optimized out>) at main.cc:6
#6  0x0000000000405138 in main (argc=1, argv=0x7fffffffd9c8) at main.cc:26
(gdb) next
195      if(gobj())
(gdb)
198        g_object_steal_qdata((GObject*)gobj(), Glib::quark_); //It will no longer be possible to get the C++ instance from the C instance.
(gdb)
201        g_object_set_qdata((GObject*)gobj(), Glib::quark_cpp_wrapper_deleted_, (gpointer)true);
(gdb)
204        gobject_ = 0;
(gdb) cont
Continuing.
[Inferior 1 (process 3001) exited normally]
(gdb)

When the SpinButton or the Adjustment is deleted, Gtk::Object::disconnect_cpp_wrapper() is called. g_object_steal_qdata((GObject*)gobj(), Glib::quark_) is called from there. Because of that, Glib::ObjectBase::destroy_notify_callback_() is not called.

Glib::ObjectBase::destroy_notify_callback_() is the GDestroyNotify function, associated with Glib::quark_ in Glib::ObjectBase::_set_current_wrapper(). When that GQuark has been removed (stolen), the GDestroyNotify function will not be called.

I don't know if this helps us. I once again get the suspicion that g_object_steal_qdata() does not work correctly for you.

Kjell



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]