set the view on the page; this is a but in QtWebkit, but at least this prevents crashing for now

svn path=/branches/KDE/4.4/kdelibs/; revision=1090789
This commit is contained in:
Aaron J. Seigo 2010-02-16 01:08:57 +00:00
parent 0d7b5e88d8
commit 1b191f52ba
2 changed files with 22 additions and 3 deletions

View File

@ -22,6 +22,7 @@
#include <QtGui/QGraphicsSceneDragDropEvent> #include <QtGui/QGraphicsSceneDragDropEvent>
#include <QtGui/QGraphicsSceneMouseEvent> #include <QtGui/QGraphicsSceneMouseEvent>
#include <QtGui/QGraphicsSceneWheelEvent> #include <QtGui/QGraphicsSceneWheelEvent>
#include <QtGui/QGraphicsView>
#include <QtGui/QKeyEvent> #include <QtGui/QKeyEvent>
#include <QtGui/QStyleOptionGraphicsItem> #include <QtGui/QStyleOptionGraphicsItem>
@ -35,9 +36,9 @@
#include <kio/accessmanager.h> #include <kio/accessmanager.h>
#include <accessmanager.h> #include <accessmanager.h>
#include "plasma/widgets/webview.h" #include "animator.h"
#include "plasma.h"
#include "plasma/animator.h" #include "widgets/webview.h"
namespace Plasma namespace Plasma
{ {
@ -201,6 +202,10 @@ void WebView::setPage(QWebPage *page)
} }
d->page = 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) { if (d->page) {
connect(d->page, SIGNAL(loadProgress(int)), connect(d->page, SIGNAL(loadProgress(int)),
@ -290,6 +295,7 @@ void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
QMouseEvent me(QEvent::MouseButtonPress, event->pos().toPoint(), QMouseEvent me(QEvent::MouseButtonPress, event->pos().toPoint(),
event->button(), event->buttons(), event->modifiers()); event->button(), event->buttons(), event->modifiers());
// d->page->event(event);
d->page->event(&me); d->page->event(&me);
if (me.isAccepted() && !d->dragToScroll) { if (me.isAccepted() && !d->dragToScroll) {
event->accept(); 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) void WebView::setGeometry(const QRectF &geometry)
{ {
QGraphicsWidget::setGeometry(geometry); QGraphicsWidget::setGeometry(geometry);

View File

@ -211,6 +211,7 @@ class PLASMA_EXPORT WebView : public QGraphicsWidget
void dragLeaveEvent(QGraphicsSceneDragDropEvent * event); void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
void dragMoveEvent(QGraphicsSceneDragDropEvent * event); void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
void dropEvent(QGraphicsSceneDragDropEvent * event); void dropEvent(QGraphicsSceneDragDropEvent * event);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
private: private: