Fixes a crash when stepping out in the Inspector's debugger.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2008 01:44:59 +0000 (01:44 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2008 01:44:59 +0000 (01:44 +0000)
http://bugs.webkit.org/show_bug.cgi?id=19037

Reviewed by Dan Bernstein.

* page/InspectorController.cpp:
(WebCore::currentCallFrame): Adds a null check of currentCallFrame,
since it can be null. Also returns JSNull to better signify this.
* page/inspector/ScriptsPanel.js: Updates the debugger interface
when stepping so the currentCallFrame isn't accessed when not paused.
Adds a _clearInterface function to remove duplicate code.

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

WebCore/ChangeLog
WebCore/page/InspectorController.cpp
WebCore/page/inspector/ScriptsPanel.js

index 8ab405e..99cb8ca 100644 (file)
@@ -1,3 +1,18 @@
+2008-05-13  Timothy Hatcher  <timothy@apple.com>
+
+        Fixes a crash when stepping out in the Inspector's debugger.
+
+        http://bugs.webkit.org/show_bug.cgi?id=19037
+
+        Reviewed by Dan Bernstein.
+
+        * page/InspectorController.cpp:
+        (WebCore::currentCallFrame): Adds a null check of currentCallFrame,
+        since it can be null. Also returns JSNull to better signify this.
+        * page/inspector/ScriptsPanel.js: Updates the debugger interface
+        when stepping so the currentCallFrame isn't accessed when not paused.
+        Adds a _clearInterface function to remove duplicate code.
+
 2008-05-13  chris fleizach  <cfleizach@apple.com>
 
         Reviewed by Beth Dakin
index 5793768..256ddc9 100644 (file)
@@ -828,8 +828,8 @@ static JSValueRef currentCallFrame(JSContextRef ctx, JSObjectRef /*function*/, J
         return JSValueMakeUndefined(ctx);
 
     JavaScriptCallFrame* callFrame = controller->currentCallFrame();
-    if (!callFrame->isValid())
-        return JSValueMakeUndefined(ctx);
+    if (!callFrame || !callFrame->isValid())
+        return JSValueMakeNull(ctx);
 
     ExecState* globalExec = callFrame->execState()->lexicalGlobalObject()->globalExec();
 
index d8ff1fb..9b2269b 100644 (file)
@@ -288,18 +288,13 @@ WebInspector.ScriptsPanel.prototype = {
     {
         this.visibleView = null;
 
-        this._clearCurrentExecutionLine();
-
         if (!InspectorController.debuggerAttached()) {
             this._paused = false;
             this._waitingToPause = false;
             this._stepping = false;
         }
 
-        this.sidebarPanes.callstack.update(null);
-        this.sidebarPanes.scopechain.update(null);
-
-        this._updateDebuggerButtons();
+        this._clearInterface();
 
         this.filesSelectElement.removeChildren();
         this.functionsSelectElement.removeChildren();
@@ -564,12 +559,23 @@ WebInspector.ScriptsPanel.prototype = {
         }
     },
 
+    _clearInterface: function()
+    {
+        this.sidebarPanes.callstack.update(null);
+        this.sidebarPanes.scopechain.update(null);
+
+        this._clearCurrentExecutionLine();
+        this._updateDebuggerButtons();
+    },
+
     _toggleDebugging: function()
     {
         this._paused = false;
         this._waitingToPause = false;
         this._stepping = false;
 
+        this._clearInterface();
+
         if (InspectorController.debuggerAttached()) {
             this.element.appendChild(this.attachOverlayElement);
             InspectorController.stopDebugging();
@@ -577,12 +583,6 @@ WebInspector.ScriptsPanel.prototype = {
             this.attachOverlayElement.parentNode.removeChild(this.attachOverlayElement);
             InspectorController.startDebuggingAndReloadInspectedPage();
         }
-
-        this.sidebarPanes.callstack.update(null);
-        this.sidebarPanes.scopechain.update(null);
-
-        this._clearCurrentExecutionLine();
-        this._updateDebuggerButtons();
     },
 
     _togglePause: function()
@@ -597,11 +597,7 @@ WebInspector.ScriptsPanel.prototype = {
             InspectorController.pauseInDebugger();
         }
 
-        this.sidebarPanes.callstack.update(null);
-        this.sidebarPanes.scopechain.update(null);
-
-        this._clearCurrentExecutionLine();
-        this._updateDebuggerButtons();
+        this._clearInterface();
     },
 
     _stepOverClicked: function()
@@ -609,6 +605,8 @@ WebInspector.ScriptsPanel.prototype = {
         this._paused = false;
         this._stepping = true;
 
+        this._clearInterface();
+
         InspectorController.stepOverStatementInDebugger();
     },
 
@@ -617,6 +615,8 @@ WebInspector.ScriptsPanel.prototype = {
         this._paused = false;
         this._stepping = true;
 
+        this._clearInterface();
+
         InspectorController.stepIntoStatementInDebugger();
     },
 
@@ -625,6 +625,8 @@ WebInspector.ScriptsPanel.prototype = {
         this._paused = false;
         this._stepping = true;
 
+        this._clearInterface();
+
         InspectorController.stepOutOfFunctionInDebugger();
     }
 }