Title: [133899] trunk/Source/WebKit/qt
Revision
133899
Author
[email protected]
Date
2012-11-08 07:32:38 -0800 (Thu, 08 Nov 2012)

Log Message

[Qt] API test tst_qwebinspector crashes
https://bugs.webkit.org/show_bug.cgi?id=101599

Reviewed by Simon Hausmann.

Delete the internal inspector from QWebPage destructor, instead of causing recursions
between QWebPagePrivate::setInspector and QWebInspector::setPage.

Also separate the three tests in tst_QWebInspector to better tell which one is failing.

* Api/qwebpage.cpp:
(QWebPagePrivate::~QWebPagePrivate):
(QWebPagePrivate::setInspector):
* tests/qwebinspector/tst_qwebinspector.cpp:
(tst_QWebInspector):
(tst_QWebInspector::attachAndDestroyPageFirst):
(tst_QWebInspector::attachAndDestroyInspectorFirst):
(tst_QWebInspector::attachAndDestroyInternalInspector):

Modified Paths

Diff

Modified: trunk/Source/WebKit/qt/Api/qwebpage.cpp (133898 => 133899)


--- trunk/Source/WebKit/qt/Api/qwebpage.cpp	2012-11-08 15:25:17 UTC (rev 133898)
+++ trunk/Source/WebKit/qt/Api/qwebpage.cpp	2012-11-08 15:32:38 UTC (rev 133899)
@@ -378,11 +378,6 @@
 
 QWebPagePrivate::~QWebPagePrivate()
 {
-    if (inspector && inspectorIsInternalOnly) {
-        // Since we have to delete an internal inspector,
-        // call setInspector(0) directly to prevent potential crashes
-        setInspector(0);
-    }
 #ifndef QT_NO_CONTEXTMENU
     delete currentContextMenu.data();
 #endif
@@ -392,8 +387,13 @@
     delete settings;
     delete page;
     
-    if (inspector)
-        inspector->setPage(0);
+    if (inspector) {
+        // If the inspector is ours, delete it, otherwise just detach from it.
+        if (inspectorIsInternalOnly)
+            delete inspector;
+        else
+            inspector->setPage(0);
+    }
 
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     NotificationPresenterClientQt::notificationPresenter()->removeClient();
@@ -1466,13 +1466,6 @@
     if (inspector)
         inspector->d->setFrontend(0);
 
-    if (inspectorIsInternalOnly) {
-        QWebInspector* inspToDelete = inspector;
-        inspector = 0;
-        inspectorIsInternalOnly = false;
-        delete inspToDelete;    // Delete after to prevent infinite recursion
-    }
-
     inspector = insp;
 
     // Give inspector frontend web view if previously created

Modified: trunk/Source/WebKit/qt/ChangeLog (133898 => 133899)


--- trunk/Source/WebKit/qt/ChangeLog	2012-11-08 15:25:17 UTC (rev 133898)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-11-08 15:32:38 UTC (rev 133899)
@@ -1,5 +1,26 @@
 2012-11-07  Allan Sandfeld Jensen  <[email protected]>
 
+        [Qt] API test tst_qwebinspector crashes
+        https://bugs.webkit.org/show_bug.cgi?id=101599
+
+        Reviewed by Simon Hausmann.
+
+        Delete the internal inspector from QWebPage destructor, instead of causing recursions
+        between QWebPagePrivate::setInspector and QWebInspector::setPage.
+
+        Also separate the three tests in tst_QWebInspector to better tell which one is failing.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::~QWebPagePrivate):
+        (QWebPagePrivate::setInspector):
+        * tests/qwebinspector/tst_qwebinspector.cpp:
+        (tst_QWebInspector):
+        (tst_QWebInspector::attachAndDestroyPageFirst):
+        (tst_QWebInspector::attachAndDestroyInspectorFirst):
+        (tst_QWebInspector::attachAndDestroyInternalInspector):
+
+2012-11-08  Allan Sandfeld Jensen  <[email protected]>
+
         [Qt] Open link in this window action
         https://bugs.webkit.org/show_bug.cgi?id=101226
 

Modified: trunk/Source/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp (133898 => 133899)


--- trunk/Source/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp	2012-11-08 15:25:17 UTC (rev 133898)
+++ trunk/Source/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp	2012-11-08 15:32:38 UTC (rev 133899)
@@ -28,41 +28,48 @@
     Q_OBJECT
 
 private Q_SLOTS:
-    void attachAndDestroy();
+    void attachAndDestroyPageFirst();
+    void attachAndDestroyInspectorFirst();
+    void attachAndDestroyInternalInspector();
 };
 
-void tst_QWebInspector::attachAndDestroy()
+void tst_QWebInspector::attachAndDestroyPageFirst()
 {
-    {   // External inspector + manual destruction of page first
-        QWebPage* page = new QWebPage();
-        page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
-        QWebInspector* inspector = new QWebInspector();
-        inspector->setPage(page);
-        page->updatePositionDependentActions(QPoint(0, 0));
-        page->triggerAction(QWebPage::InspectElement);
+    // External inspector + manual destruction of page first
+    QWebPage* page = new QWebPage();
+    page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+    QWebInspector* inspector = new QWebInspector();
+    inspector->setPage(page);
+    page->updatePositionDependentActions(QPoint(0, 0));
+    page->triggerAction(QWebPage::InspectElement);
 
-        delete page;
-        delete inspector;
-    }
-    {   // External inspector + manual destruction of inspector first
-        QWebPage* page = new QWebPage();
-        page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
-        QWebInspector* inspector = new QWebInspector();
-        inspector->setPage(page);
-        page->updatePositionDependentActions(QPoint(0, 0));
-        page->triggerAction(QWebPage::InspectElement);
+    delete page;
+    delete inspector;
+}
 
-        delete inspector;
-        delete page;
-    }
-    {   // Internal inspector
-        QWebPage page;
-        page.settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
-        page.updatePositionDependentActions(QPoint(0, 0));
-        page.triggerAction(QWebPage::InspectElement);
-    }
+void tst_QWebInspector::attachAndDestroyInspectorFirst()
+{
+    // External inspector + manual destruction of inspector first
+    QWebPage* page = new QWebPage();
+    page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+    QWebInspector* inspector = new QWebInspector();
+    inspector->setPage(page);
+    page->updatePositionDependentActions(QPoint(0, 0));
+    page->triggerAction(QWebPage::InspectElement);
+
+    delete inspector;
+    delete page;
 }
 
+void tst_QWebInspector::attachAndDestroyInternalInspector()
+{
+    // Internal inspector
+    QWebPage page;
+    page.settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+    page.updatePositionDependentActions(QPoint(0, 0));
+    page.triggerAction(QWebPage::InspectElement);
+}
+
 QTEST_MAIN(tst_QWebInspector)
 
 #include "tst_qwebinspector.moc"
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to