summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-04-11 13:21:12 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-04-13 07:48:03 +0000
commitafab0b8e6fd7950d7048b2bda87b5a7775ce9e80 (patch)
tree128dd94424c7e765836165842e093623261e3494
parent058ca5807f88ac6c5fc67db483e99427a7e4abfa (diff)
Fix crash on opening devtools in simplebrowser
The devtools webcontents-adapter is no longer guaranteed to be initialized at this point, and we can initialize it directly with the right site instance. Task-number: QTBUG-67642 Change-Id: I8abbd4297ae677d3bd8d45f00f7463d60ee2bce5 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io> Reviewed-by: Viktor Engelmann <viktor.engelmann@qt.io>
-rw-r--r--src/core/devtools_frontend_qt.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp
index 98008fa58..810235dba 100644
--- a/src/core/devtools_frontend_qt.cpp
+++ b/src/core/devtools_frontend_qt.cpp
@@ -44,6 +44,7 @@
#include "devtools_frontend_qt.h"
+#include "browser_context_adapter.h"
#include "browser_context_qt.h"
#include "web_contents_adapter.h"
@@ -153,6 +154,12 @@ DevToolsFrontendQt *DevToolsFrontendQt::Show(QSharedPointer<WebContentsAdapter>
DCHECK(frontendAdapter);
DCHECK(inspectedContents);
+ if (!frontendAdapter->isInitialized()) {
+ scoped_refptr<content::SiteInstance> site =
+ content::SiteInstance::CreateForURL(frontendAdapter->browserContext(), GURL(GetFrontendURL()));
+ frontendAdapter->initialize(site.get());
+ }
+
content::WebContents *contents = frontendAdapter->webContents();
if (contents == inspectedContents) {
qWarning() << "You can not inspect youself";
@@ -184,7 +191,7 @@ DevToolsFrontendQt::DevToolsFrontendQt(QSharedPointer<WebContentsAdapter> webCon
{
// We use a separate prefstore than BrowserContextQt, because that one is in-memory only, and this
// needs to be stored or it will show introduction text on every load.
- if (web_contents()->GetBrowserContext()->IsOffTheRecord())
+ if (webContentsAdapter->browserContextAdapter()->isOffTheRecord())
m_prefStore = std::move(scoped_refptr<PersistentPrefStore>(new InMemoryPrefStore()));
else
CreateJsonPreferences(false);