Commit afab0b8e authored by Allan Sandfeld Jensen's avatar Allan Sandfeld Jensen
Browse files

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: default avatarJüri Valdmann <juri.valdmann@qt.io>
Reviewed-by: default avatarViktor Engelmann <viktor.engelmann@qt.io>
Showing with 8 additions and 1 deletion
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "devtools_frontend_qt.h" #include "devtools_frontend_qt.h"
#include "browser_context_adapter.h"
#include "browser_context_qt.h" #include "browser_context_qt.h"
#include "web_contents_adapter.h" #include "web_contents_adapter.h"
...@@ -153,6 +154,12 @@ DevToolsFrontendQt *DevToolsFrontendQt::Show(QSharedPointer<WebContentsAdapter> ...@@ -153,6 +154,12 @@ DevToolsFrontendQt *DevToolsFrontendQt::Show(QSharedPointer<WebContentsAdapter>
DCHECK(frontendAdapter); DCHECK(frontendAdapter);
DCHECK(inspectedContents); 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(); content::WebContents *contents = frontendAdapter->webContents();
if (contents == inspectedContents) { if (contents == inspectedContents) {
qWarning() << "You can not inspect youself"; qWarning() << "You can not inspect youself";
...@@ -184,7 +191,7 @@ DevToolsFrontendQt::DevToolsFrontendQt(QSharedPointer<WebContentsAdapter> webCon ...@@ -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 // 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. // 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())); m_prefStore = std::move(scoped_refptr<PersistentPrefStore>(new InMemoryPrefStore()));
else else
CreateJsonPreferences(false); CreateJsonPreferences(false);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment