Razor-qt/razor-qt — Issue #137: Desktop crashes when adding plugin
Author: vljubovic
Created: 2011-12-28 09:48:08+00:00
State: open

Using Mandriva Linux 2010.1, Qt 4.6.2. Desktop loads normally but when trying to add any plugin it crashes (and restarts immediately). Backtrace:

[New Thread 0xb6554b70 (LWP 4117)]
QSS file cannot be found in any location: "light/desktop.qss"
RazorDesktop: try to load "/usr/lib/razor-desktop/libdesktop-razor.so"
RazorWorkSpaceManager::RazorWorkSpaceManager "razor"
workspace for screen 0
RazorWorkSpace::RazorWorkSpace
Object::connect: No such signal UPower::monitoring(const QString &) in /home/vedran/razorqt/razor/razorqt-0.4.0/libraries/razorqt/powermanager.cpp:77
File Name: "/etc/xdg/menus/razor-applications.menu"
* Plugin loaded.
"Fully featured desktop implementation with all Razor's bells and whistles"
[New Thread 0xb5a14b70 (LWP 4118)]
[Thread 0xb5a14b70 (LWP 4118) exited]
addPlugin "helloworld"
* Plugin loaded.
"Display simple text. A debugging/sample widget."

Program received signal SIGSEGV, Segmentation fault.
0xb5d412b1 in RazorWorkSpace::addPlugin (this=0x80b0e00, pluginInfo=...)
at /home/vedran/razorqt/razor/razorqt-0.4.0/razorqt-desktop/desktop-razor/razorworkspace.cpp:407
warning: Source file is more recent than executable.
407	plugin->setSizeAndPosition(QPointF(x, y), size);
(gdb) print plugin
$1 = (DesktopWidgetPlugin *) 0x0
(gdb) print item
$2 = (QGraphicsItem *) 0x0

Apparently plugin is loaded normally but dynamic_cast to QGraphicsItem fails and gives zero pointer. The only possible explanation is that Mandriva compiles Qt with -no-rtti option, as discussed here:
http://developer.qt.nokia.com/doc/qt-4.8/qobject.html#qobject_cast
http://developer.qt.nokia.com/forums/viewthread/2802

One solution is to have all plugins derived from QObject and then use qobject_cast, but that will screw with multiple inheritance which I see you're using. In my projects I solved this by having plugins not be the widget itself but a widget factory.

Do what you want with this bug, but some distributors will likely compile Qt without rtti and Razor will crash and burn on such systems. At least add a check for zero pointer.