summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bruning <michael.bruning@qt.io>2016-06-09 12:58:29 +0200
committerMichael BrĂ¼ning <michael.bruning@qt.io>2016-06-09 12:41:22 +0000
commitc4fc323d0771e24ae726065cdce9eafef2c09c41 (patch)
tree2822e13fee2623ade795b6a6936adc01d27f3d03
parent5e3250a24a8cde71de085754922aa6708c036237 (diff)
Also initialize context data if the menu policy is CustomContextMenu.
It does contain valid data and some users seem to build upon the standard context menu. Also, return early with a nullptr from createStandardContextMenu when the context menu data d ptr is null. Task-number: QTBUG-53952 Change-Id: Ib30e85f10e3ae681527210a9e8554f5a21dba7ae Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp4
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 04b8a2b6f..3f11e5aef 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -1143,6 +1143,7 @@ bool QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData
view->contextMenuEvent(&event);
break;
case Qt::CustomContextMenu:
+ contextData = data;
Q_EMIT view->customContextMenuRequested(data.pos);
break;
case Qt::ActionsContextMenu:
@@ -1281,6 +1282,9 @@ bool QWebEnginePagePrivate::isEnabled() const
QMenu *QWebEnginePage::createStandardContextMenu()
{
Q_D(QWebEnginePage);
+ if (!d->contextData.d)
+ return nullptr;
+
QMenu *menu = new QMenu(d->view);
QAction *action = 0;
const WebEngineContextMenuData &contextMenuData = *d->contextData.d;
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index 90d5111c1..539e809d4 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -281,6 +281,9 @@
the user clicks on the web page with the right mouse button. It is
called from the default \l{QWidget::}{contextMenuEvent()} handler. The popup menu's
ownership is transferred to the caller.
+
+ Returns \c nullptr if the context menu data is not initialized, for example when it
+ is called when there is actually no context menu requested.
*/
/*!