[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.1/kdelibs/khtml
From:       Maks Orlovich <maksim () kde ! org>
Date:       2008-08-26 21:14:05
Message-ID: 1219785245.800838.28545.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 852920 by orlovich:

Fix the debugger window keeping konqueror open, by refcounting it and destroying it 
when all KJSProxy's are gone. Also fix debugger disabling not taking effect, and 
many cases of debugger enabling in the middle of execution crashing by syncing 
things at session boundaries (imperfectly for enabling, though)

Most of the credit goes to Hugh Daschbach for masterfully analyzing the issue.

CCBUG:157685
BUG:169881


 M  +5 -14     ecma/debugger/debugwindow.cpp  
 M  +3 -3      ecma/debugger/debugwindow.h  
 M  +24 -26    ecma/kjs_proxy.cpp  
 M  +1 -2      khtml_part.cpp  


--- branches/KDE/4.1/kdelibs/khtml/ecma/debugger/debugwindow.cpp #852919:852920
@@ -91,23 +91,12 @@
 using namespace KJSDebugger;
 
 DebugWindow* DebugWindow::s_debugger = 0;
-DebugWindow *DebugWindow::createInstance()
-{
-    Q_ASSERT(!s_debugger);
-    s_debugger = new DebugWindow();
-    return s_debugger;
-}
 
-void DebugWindow::destroyInstance()
-{
-    Q_ASSERT(s_debugger);
-    Q_ASSERT(s_debugger->m_activeSessionCtxs.isEmpty());
-    s_debugger->hide();
-    delete s_debugger;
-}
-
 DebugWindow * DebugWindow::window()
 {
+    if (!s_debugger)
+        s_debugger = new DebugWindow();
+
     return s_debugger;
 }
 
@@ -376,6 +365,8 @@
     assert(m_docsForIntrp.isEmpty());
     assert(m_docForSid.isEmpty());
     assert(m_docForIUKey.isEmpty());
+    assert(m_activeSessionCtxs.isEmpty());
+    s_debugger = 0;
 }
 
 void DebugWindow::closeEvent(QCloseEvent* event)
--- branches/KDE/4.1/kdelibs/khtml/ecma/debugger/debugwindow.h #852919:852920
@@ -39,6 +39,7 @@
 #include "khtml_pagecache.h"
 #include "khtml_part.h"
 #include "dom/dom_misc.h"
+#include "misc/shared.h"
 
 #include <QStack>
 #include <QVector>
@@ -71,7 +72,8 @@
 *
 * There is only one debug window per program. This can be obtained by calling \
                #instance
 */
-class DebugWindow : public KXmlGuiWindow, public KJS::Debugger, public \
KComponentData +class DebugWindow : public KXmlGuiWindow, public KJS::Debugger, \
public KComponentData, +                    public khtml::Shared<DebugWindow>
 {
     Q_OBJECT
 
@@ -79,8 +81,6 @@
     DebugWindow(QWidget *parent = 0);
     virtual ~DebugWindow();
 
-    static DebugWindow *createInstance();
-    static void destroyInstance();
     static DebugWindow *window();
 
     // Returns true if the debugger is active, and has blocked the execution
--- branches/KDE/4.1/kdelibs/khtml/ecma/kjs_proxy.cpp #852919:852920
@@ -66,9 +66,9 @@
 
   void initScript();
   void applyUserAgent();
-
 private:
   KJS::ScriptInterpreter* m_script;
+  WTF::RefPtr<DebugWindow> m_debugWindow;
   bool m_debugEnabled;
 #ifndef NDEBUG
   static int s_count;
@@ -141,8 +141,8 @@
 #ifdef KJS_DEBUGGER
     if (inlineCode)
         filename = "(unknown file)";
-    if (DebugWindow::window())
-        DebugWindow::window()->attach(m_script);
+    if (m_debugWindow)
+        m_debugWindow->attach(m_script);
 #else
     Q_UNUSED(baseLine);
 #endif
@@ -202,9 +202,8 @@
   // (we used to delete and re-create it, previously)
     if (m_script) {
 #ifdef KJS_DEBUGGER
-        DebugWindow *debugWin = DebugWindow::window();
-        if (debugWin)
-            debugWin->clearInterpreter(m_script);
+        if (m_debugWindow)
+            m_debugWindow->clearInterpreter(m_script);
 #endif
         m_script->clear();
 
@@ -225,6 +224,14 @@
 	    ;
     JSLock::unlock();
   }
+
+#ifdef KJS_DEBUGGER
+  // Detach from debugging entirely if it's been turned off.
+  if (m_debugWindow && !m_debugEnabled) {
+    m_debugWindow->detach(m_script);
+    m_debugWindow = 0;
+  }
+#endif
 }
 
 DOM::EventListener *KJSProxyImpl::createHTMLEventHandler(QString sourceUrl, QString \
name, QString code, DOM::NodeImpl *node) @@ -232,8 +239,8 @@
   initScript();
 
 #ifdef KJS_DEBUGGER
-    if (DebugWindow::window())
-        DebugWindow::window()->attach(m_script);
+    if (m_debugWindow)
+        m_debugWindow->attach(m_script);
 #else
     Q_UNUSED(sourceUrl);
 #endif
@@ -262,30 +269,21 @@
 {
 #ifdef KJS_DEBUGGER
   m_debugEnabled = enabled;
-  //if (m_script)
-  //    m_script->setDebuggingEnabled(enabled);
-  // NOTE: this is consistent across all KJSProxyImpl instances, as we only
-  // ever have 1 debug window
-    if (!enabled && DebugWindow::window())
-    {
-        DebugWindow::destroyInstance();
-    }
-    else if (enabled && !DebugWindow::window())
-    {
-        DebugWindow::createInstance();
-        initScript();
-        DebugWindow::window()->attach(m_script);
-    }
-#else
-    Q_UNUSED(enabled);
+
+  // Note that we attach to the debugger only before
+  // running a script. Detaches/disabling are done between
+  // documents, at clear. Both are done so the debugger
+  // see the entire session
+  if (enabled)
+    m_debugWindow = DebugWindow::window();
 #endif
 }
 
 void KJSProxyImpl::showDebugWindow(bool /*show*/)
 {
 #ifdef KJS_DEBUGGER
-    if (DebugWindow::window())
-        DebugWindow::window()->show();
+    if (m_debugWindow)
+        m_debugWindow->show();
 #else
     //Q_UNUSED(show);
 #endif
--- branches/KDE/4.1/kdelibs/khtml/khtml_part.cpp #852919:852920
@@ -1080,8 +1080,7 @@
   if ( !d->m_frame->m_jscript )
     if (!createJScript(d->m_frame))
       return 0;
-  if (d->m_bJScriptDebugEnabled)
-    d->m_frame->m_jscript->setDebugEnabled(true);
+   d->m_frame->m_jscript->setDebugEnabled(d->m_bJScriptDebugEnabled);
 
   return d->m_frame->m_jscript;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic