[PATCH] Fix crash in K3ListView

Christoph Feck christoph at maxiom.de
Wed Dec 17 15:26:49 GMT 2008


Hello all,

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

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

Follow carefully, you got to learn something new ;)

#16 0xb7b1fb95 in qdesigner_internal::WidgetFactory::createCustomWidget 
(this=0x81844f0, className=@0xbfc6d764, parentWidget=0x0, 
creationError=0xbfc6d6ab)
    Designer loaded its plugins and now creates the widgets

#15 0xb61f2934 in K3ListViewPlugin::createWidget () 
from /mnt/local/kde4/lib/kde4/plugins/designer/kde3supportwidgets.so
#14 0xb549059b in K3ListView::K3ListView () 
from /usr/local/kde4/lib/libkde3support.so.4
    A KDE 3 Support widget is created (K3ListView)

#13 0xb548d904 in K3ListViewLineEdit::K3ListViewLineEdit () 
from /usr/local/kde4/lib/libkde3support.so.4
#12 0xb5deeff9 in KLineEdit::KLineEdit () 
from /usr/local/kde4/lib/libkdeui.so.5
#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 () 
from /usr/local/kde4/lib/libkdeui.so.5
#9  0xb5d45c9b in KGlobalSettings::KGlobalSettings () 
from /usr/local/kde4/lib/libkdeui.so.5
#8  0xb5d42e4e in KGlobalSettings::Private::kdisplaySetStyle () 
from /usr/local/kde4/lib/libkdeui.so.5
    The lineedit appearently needs KDE settings and calls into KGlobalSettings

#7  0xb5d42d9c in KGlobalSettings::Private::kdisplaySetPalette () 
from /usr/local/kde4/lib/libkdeui.so.5
    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, 
className=0x0, clearWidgetPaletteHash=true)
at ../../include/QtCore/../../../../git/qt-snapshot/src/corelib/kernel/qcoreapplication.h:208
#4  0xb68ca79b in QCoreApplication::notifyInternal (this=0xbfc6d984, 
receiver=0x84139a8, event=0xbfc6d2dc) 
at /mnt/git/qt-snapshot/src/corelib/kernel/qcoreapplication.cpp:590
#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, 
receiver=0xbfc6d2dc, e=0xbfc6cfbc) 
at /mnt/git/qt-snapshot/src/gui/kernel/qapplication.cpp:3979
    Creating that palette notifies the application about the palette change

#1  0xb548cb13 in K3ListView::event () 
from /usr/local/kde4/lib/libkde3support.so.4
    Eventually, the K3ListView gets the QEvent::ApplicationPaletteChange event
    (before it its constructor has finished!)

#0  0xb6f835db in QColor::operator= (this=0xac, color=@0x8435d98) 
at /mnt/git/qt-snapshot/src/gui/painting/qcolor.cpp:1908
    ... 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?

Christoph (kdepepo)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kde3support.diff
Type: text/x-diff
Size: 1459 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081217/83218663/attachment.diff>


More information about the kde-core-devel mailing list