[PATCH] Fix crash in K3ListView
christoph at maxiom.de
Wed Dec 17 15:26:49 GMT 2008
Richard "nixternal" Johnson of Kubuntu fame reported a crash in Qt Designer
when using Skulpture style. Debugging this, I found out that there are
actually two crashes: one has been fixed in Skulpture, the other is explained
Since Designer is not a KDE application, I had to use gdb to get a backtrace.
The following trace is presented in call order (a forwardtrace?) and
Follow carefully, you got to learn something new ;)
#16 0xb7b1fb95 in qdesigner_internal::WidgetFactory::createCustomWidget
(this=0x81844f0, className=@0xbfc6d764, parentWidget=0x0,
Designer loaded its plugins and now creates the widgets
#15 0xb61f2934 in K3ListViewPlugin::createWidget ()
#14 0xb549059b in K3ListView::K3ListView ()
A KDE 3 Support widget is created (K3ListView)
#13 0xb548d904 in K3ListViewLineEdit::K3ListViewLineEdit ()
#12 0xb5deeff9 in KLineEdit::KLineEdit ()
#11 0xb5de8203 in KLineEdit::init () from /usr/local/kde4/lib/libkdeui.so.5
That listview creates a lineedit widget (in its d-pointer constructor!)
#10 0xb5d45f27 in KGlobalSettings::self ()
#9 0xb5d45c9b in KGlobalSettings::KGlobalSettings ()
#8 0xb5d42e4e in KGlobalSettings::Private::kdisplaySetStyle ()
The lineedit appearently needs KDE settings and calls into KGlobalSettings
#7 0xb5d42d9c in KGlobalSettings::Private::kdisplaySetPalette ()
That in turn makes KDE initialize its palette
#6 0xb6e87a7c in QApplication::setPalette (palette=@0xbfc6d340,
className=0x0) at /mnt/git/qt-snapshot/src/gui/kernel/qapplication.cpp:1750
#5 0xb6e87763 in QApplicationPrivate::setPalette_helper (palette=@0xbfc6d340,
#4 0xb68ca79b in QCoreApplication::notifyInternal (this=0xbfc6d984,
#3 0xb6e8bd3a in QApplication::notify (this=0xbfc6d984, receiver=0x84139a8,
e=0xbfc6d2dc) at /mnt/git/qt-snapshot/src/gui/kernel/qapplication.cpp:3944
#2 0xb6e83c1c in QApplicationPrivate::notify_helper (this=0x80bb660,
Creating that palette notifies the application about the palette change
#1 0xb548cb13 in K3ListView::event ()
Eventually, the K3ListView gets the QEvent::ApplicationPaletteChange event
(before it its constructor has finished!)
#0 0xb6f835db in QColor::operator= (this=0xac, color=@0x8435d98)
... and crashes because it stores a color to nowhere.
Why? Because the d-pointer of the K3ListView is currently being created,
but its value is not set yet, because it is still in executing the constructor
of the d-pointer member!
So what should we learn? Never create widgets inside the constructor of
a widget before the d-pointer has been assigned.
Attached is a patch for kdelibs/kde3support, please review.
Maybe we need an EBN checker for this type of error?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1459 bytes
Desc: not available
More information about the kde-core-devel