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

List:       kfm-devel
Subject:    patch: m_runningScripts guard
From:       Harri Porten <porten () trolltech ! com>
Date:       2001-07-22 18:03:27
[Download RAW message or body]

Hi !

Last night I discussed with Dirk that we will have to queue actions like
form submissions and redirections if a script is still running. This will
enable the script to cancel such actions (Dirks motivation) and fix things
by e.g. prevent the page to be closed underneath an opened alert() box (my
motivation).

A complete fix might be some more work but attached you'll find a diff
that puts an incremental b_runningScripts guard around the script
execution. If b_runningScripts is > 0 when submit() is being called it
will be scheduled for a later submittal. Very much like we already do in
case this happens during parsing.

Any comments ?

Harri.


["khtml_part.diff" (TEXT/PLAIN)]

Index: khtml_part.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
retrieving revision 1.521
diff -u -3 -p -r1.521 khtml_part.cpp
--- khtml_part.cpp	2001/07/22 09:59:54	1.521
+++ khtml_part.cpp	2001/07/22 18:00:30
@@ -141,6 +141,7 @@ public:
     m_doc = 0L;
     m_decoder = 0L;
     m_jscript = 0L;
+    m_runningScripts = 0;
     m_kjs_lib = 0;
     m_job = 0L;
     m_bComplete = true;
@@ -231,6 +232,7 @@ public:
 
   KJSProxy *m_jscript;
   KLibrary *m_kjs_lib;
+  int m_runningScripts;
   bool m_bJScriptEnabled :1;
   bool m_bJavaEnabled :1;
   bool m_bPluginsEnabled :1;
@@ -846,7 +848,11 @@ QVariant KHTMLPart::executeScript( const
 
   if (!proxy)
     return QVariant();
+  d->m_runningScripts++;
   QVariant ret = proxy->evaluate( script.unicode(), script.length(), n );
+  d->m_runningScripts--;
+  if ( d->m_submitForm )
+      submitFormAgain();
   if ( d->m_doc )
     d->m_doc->updateRendering();
 
@@ -2884,7 +2890,7 @@ void KHTMLPart::submitForm( const char *
       args.setContentType( "Content-Type: " + contentType + "; boundary=" + boundary );
   }
 
-  if ( d->m_bParsing ) {
+  if ( d->m_bParsing || d->m_runningScripts > 0 ) {
     if( d->m_submitForm ) {
         return;
     }
@@ -4242,7 +4248,14 @@ QVariant KHTMLPart::executeKJSFunctionCa
     if (!proxy)
         return QVariant();
 
-    return proxy->executeFunctionCall(thisVal,functionObj,args,extraScope);
+    d->m_runningScripts++;
+    QVariant v = proxy->executeFunctionCall( thisVal, functionObj,
+					     args, extraScope );
+    d->m_runningScripts--;
+    if ( d->m_submitForm )
+      submitFormAgain();
+
+    return v;
 }
 
 


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

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