+2007-12-03 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Lars.
+
+ Fixed crash when rendering form elements with Qt 4.4
+
+ QPainter::device() is not guaranteed to return a QWidget, so do the safe "cast" with the
+ help of QPaintDevice::devType().
+ Also fall back to the QApplication::style() if we don't have a widget.
+
+ * platform/qt/RenderThemeQt.cpp:
+ (WebCore::RenderThemeQt::paintButton):
+ (WebCore::RenderThemeQt::paintTextField):
+ (WebCore::RenderThemeQt::paintMenuList):
+ (WebCore::RenderThemeQt::getStylePainterAndWidgetFromPaintInfo):
+
2007-12-02 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
Reviewed by Sam Weinig.
return true;
QStyleOptionButton option;
- option.initFrom(widget);
+ if (widget)
+ option.initFrom(widget);
option.rect = r;
// Get the correct theme data for a button
return true;
QStyleOptionFrameV2 panel;
-
- panel.initFrom(widget);
+ if (widget)
+ panel.initFrom(widget);
panel.rect = r;
panel.state |= QStyle::State_Sunken;
panel.features = QStyleOptionFrameV2::None;
return true;
QStyleOptionComboBox opt;
- opt.initFrom(widget);
+ if (widget)
+ opt.initFrom(widget);
EAppearance appearance = applyTheme(opt, o);
const QPoint topLeft = r.topLeft();
painter->translate(topLeft);
QPainter*& painter, QWidget*& widget) const
{
painter = (i.context ? static_cast<QPainter*>(i.context->platformContext()) : 0);
- widget = (painter ? static_cast<QWidget*>(painter->device()) : 0);
- style = (widget ? widget->style() : 0);
-
- return (painter && widget && style);
+ widget = 0;
+ QPaintDevice* dev = 0;
+ if (painter)
+ dev = painter->device();
+ if (dev && dev->devType() == QInternal::Widget)
+ widget = static_cast<QWidget*>(dev);
+ style = (widget ? widget->style() : QApplication::style());
+
+ return (painter && style);
}
EAppearance RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const