Fix a crash when opening the Inspector
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Jan 2008 03:43:09 +0000 (03:43 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Jan 2008 03:43:09 +0000 (03:43 +0000)
         Reviewed by Anders.

         * WebInspectorClient.cpp:
         (WebInspectorClient::createPage): Call
         WebPreferences::initWithIdentifier so our custom WebPreferences will
         have all its members initialized.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29863 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/win/ChangeLog
WebKit/win/WebInspectorClient.cpp

index 05a3622..ef70a5d 100644 (file)
@@ -1,5 +1,16 @@
 2008-01-29  Adam Roben  <aroben@apple.com>
 
+        Fix a crash when opening the Inspector
+
+        Reviewed by Anders.
+
+        * WebInspectorClient.cpp:
+        (WebInspectorClient::createPage): Call
+        WebPreferences::initWithIdentifier so our custom WebPreferences will
+        have all its members initialized.
+
+2008-01-29  Adam Roben  <aroben@apple.com>
+
         Fix Bug 16786: "Display images when page opens" preference affects
         Inspector
 
index fe1d0f8..a82eee6 100644 (file)
@@ -115,9 +115,27 @@ Page* WebInspectorClient::createPage()
 
     m_webView.adoptRef(WebView::createInstance());
 
+    if (FAILED(m_webView->setHostWindow((OLE_HANDLE)(ULONG64)m_hwnd)))
+        return 0;
+
+    RECT rect;
+    GetClientRect(m_hwnd, &rect);
+    if (FAILED(m_webView->initWithFrame(rect, 0, 0)))
+        return 0;
+
     // Keep preferences separate from the rest of the client, making sure we are using expected preference values.
     // One reason this is good is that it keeps the inspector out of history via "private browsing".
-    COMPtr<WebPreferences> preferences(AdoptCOM, WebPreferences::createInstance());
+    // FIXME: It's crazy that we have to do this song and dance to end up with
+    // a private WebPreferences object, even within WebKit. We should make this
+    // process simpler, and consider whether we can make it simpler for WebKit
+    // clients as well.
+    COMPtr<WebPreferences> tempPreferences(AdoptCOM, WebPreferences::createInstance());
+    COMPtr<IWebPreferences> iPreferences;
+    if (FAILED(tempPreferences->initWithIdentifier(BString(L"WebInspectorPreferences"), &iPreferences)))
+        return 0;
+    COMPtr<WebPreferences> preferences(Query, iPreferences);
+    if (!preferences)
+        return 0;
     if (FAILED(preferences->setAutosaves(FALSE)))
         return 0;
     if (FAILED(preferences->setPrivateBrowsingEnabled(TRUE)))
@@ -146,14 +164,6 @@ Page* WebInspectorClient::createPage()
     if (FAILED(m_webView->setPreferences(preferences.get())))
         return 0;
 
-    if (FAILED(m_webView->setHostWindow((OLE_HANDLE)(ULONG64)m_hwnd)))
-        return 0;
-
-    RECT rect;
-    GetClientRect(m_hwnd, &rect);
-    if (FAILED(m_webView->initWithFrame(rect, 0, 0)))
-        return 0;
-
     m_webView->setProhibitsMainFrameScrolling(TRUE);
 
     if (FAILED(m_webView->viewWindow(reinterpret_cast<OLE_HANDLE*>(&m_webViewHwnd))))