From 8b550a13ada31680cf4be071ccd4658de9e1335e Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 16 Feb 2010 01:07:25 +0000 Subject: [PATCH] set the view on the page; this is a but in QtWebkit, but at least this prevents crashing for now svn path=/trunk/KDE/kdelibs/; revision=1090788 --- widgets/webview.cpp | 24 +++++++++++++++++++++--- widgets/webview.h | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/widgets/webview.cpp b/widgets/webview.cpp index 3fd893003..da8a154f2 100644 --- a/widgets/webview.cpp +++ b/widgets/webview.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -35,9 +36,9 @@ #include #include -#include "plasma/widgets/webview.h" - -#include "plasma/animator.h" +#include "animator.h" +#include "plasma.h" +#include "widgets/webview.h" namespace Plasma { @@ -201,6 +202,10 @@ void WebView::setPage(QWebPage *page) } d->page = page; + //FIXME: QWebPage _requires_ a QWidget view to not crash in places such as + // WebCore::PopupMenu::show() due to hostWindow()->platformPageClient() == NULL + // because QWebPage::d->client is NULL + d->page->setView(viewFor(this)); if (d->page) { connect(d->page, SIGNAL(loadProgress(int)), @@ -290,6 +295,7 @@ void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event) QMouseEvent me(QEvent::MouseButtonPress, event->pos().toPoint(), event->button(), event->buttons(), event->modifiers()); +// d->page->event(event); d->page->event(&me); if (me.isAccepted() && !d->dragToScroll) { event->accept(); @@ -477,6 +483,18 @@ void WebView::dropEvent(QGraphicsSceneDragDropEvent * event) } } +QVariant WebView::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemSceneHasChanged && d->page) { + //FIXME: QWebPage _requires_ a QWidget view to not crash in places such as + // WebCore::PopupMenu::show() due to hostWindow()->platformPageClient() == NULL + // because QWebPage::d->client is NULL + d->page->setView(viewFor(this)); + } + + return QGraphicsWidget::itemChange(change, value); +} + void WebView::setGeometry(const QRectF &geometry) { QGraphicsWidget::setGeometry(geometry); diff --git a/widgets/webview.h b/widgets/webview.h index 45baff8f1..cb59e9647 100644 --- a/widgets/webview.h +++ b/widgets/webview.h @@ -211,6 +211,7 @@ class PLASMA_EXPORT WebView : public QGraphicsWidget void dragLeaveEvent(QGraphicsSceneDragDropEvent * event); void dragMoveEvent(QGraphicsSceneDragDropEvent * event); void dropEvent(QGraphicsSceneDragDropEvent * event); + QVariant itemChange(GraphicsItemChange change, const QVariant &value); QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; private: