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

List:       kde-commits
Subject:    KDE/kdelibs/kjsembed/kjsembed
From:       Erik Lloyd Bunce <kde () bunce ! us>
Date:       2007-04-30 2:38:53
Message-ID: 1177900733.110818.27006.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 659352 by bunce:

More diagnostics in SlotProxy::callMethod() and EventProxy::calHandler().

 M  +29 -14    eventproxy.cpp  
 M  +17 -10    slotproxy.cpp  


--- trunk/KDE/kdelibs/kjsembed/kjsembed/eventproxy.cpp #659351:659352
@@ -99,6 +99,7 @@
     KJS::JSObject *jsobj(m_watch);
     KJS::JSObject *fun = jsobj->get(exec, id )->toObject( exec );
 
+    KJS::JSValue *retValue;
     if ( !fun->implementsCall() )
     {
         QString msg = i18n( "Bad event handler: Object %1 Identifier %2 Method %3 \
Type: %4.", @@ -106,22 +107,36 @@
           id.ascii(),
           fun->className().ascii(),
           e->type());
-        throwError(exec, KJS::TypeError, msg);
+        retValue = throwError(exec, KJS::TypeError, msg);
+    }
+    else
+    {
+        // Process args
+        KJS::List args;
+        args.append( JSEventUtils::event(exec, e) );
+        
+        // Call handler
+        retValue = fun->call( exec, jsobj, args );
+    }
+    
+    if ( exec->hadException() ) 
+    {
+        if (m_interpreter->shouldPrintExceptions())
+        {
+            KJS::JSLock lock;
+            KJS::JSObject* exceptObj = retValue->toObject(exec);
+            QString message = toQString(exceptObj->toString(exec));
+            QString sourceURL = toQString(exceptObj->get(exec, \
"sourceURL")->toString(exec)); +            int sourceId = exceptObj->get(exec, \
"sourceId")->toUInt32(exec); +            int line = exceptObj->get(exec, \
"line")->toUInt32(exec); +            (*KJSEmbed::conerr()) << i18n("Exception \
calling '%1' function from %2:%3:%4", id.ascii(), !sourceURL.isEmpty() ? sourceURL : \
QString::number(sourceId), line, message) << endl; +        }
+        
+        
+        // clear it so it doesn't stop other things
+        exec->clearException();
         return false;
     }
-
-    // Process args
-    KJS::List args;
-    args.append( JSEventUtils::event(exec, e) );
-
-    // Call handler
-    fun->call( exec, jsobj, args );
-
-    if ( exec->hadException() ) {
-    //TODO ext the script here with the error
-      exec->clearException();
-      return false;
-    }
   
     return true;
 }
--- trunk/KDE/kdelibs/kjsembed/kjsembed/slotproxy.cpp #659351:659352
@@ -101,30 +101,37 @@
     KJS::List args = convertArguments(exec, _a);
     KJS::Identifier id = KJS::Identifier( KJS::UString(methodName.data()));
     KJS::JSObject *fun = m_object->get(exec, id )->toObject( exec );
+    KJS::JSValue *retValue;
     if ( !fun->implementsCall() )
     {
-    // We need to create an exception here...
+        QString msg = i18n( "Bad slot handler: Object %1 Identifier %2 Method %3 \
Signature: %4.", +                            m_object->className().ascii(),
+                            id.ascii(),
+                            methodName.data(),
+                            QString(m_signature));
+        
+        retValue = throwError(exec, KJS::TypeError, msg);
     }
-
-    KJS::JSValue *retValue = fun->call(exec, m_object, args);
-
+    else
+        retValue = fun->call(exec, m_object, args);
+    
     if( exec->hadException() )
     {
         if (m_interpreter->shouldPrintExceptions())
         {
             KJS::JSLock lock;
-            KJS::JSObject* exceptObj = retValue->toObject(exec);
+            KJS::JSObject* exceptObj = \
exec->exception()->toObject(exec);//retValue->toObject(exec);  QString message = \
                toQString(exceptObj->toString(exec));
             QString sourceURL = toQString(exceptObj->get(exec, \
                "sourceURL")->toString(exec));
             int sourceId = exceptObj->get(exec, "sourceId")->toUInt32(exec);
             // would include the line number, but it's always last line of file
-            //int line = exceptObj->get(exec, "line")->toUInt32(exec);
-            (*KJSEmbed::conerr()) << i18n("Exception calling '%1' slot from %2:%3", \
QString(methodName), !sourceURL.isEmpty() ? sourceURL : QString::number(sourceId), \
                message) << endl;
-
-            // clear it so it doesn't stop other things
-            exec->clearException();
+            int line = exceptObj->get(exec, "line")->toUInt32(exec);
+            (*KJSEmbed::conerr()) << i18n("Exception calling '%1' slot from \
%2:%3:%4", QString(methodName), !sourceURL.isEmpty() ? sourceURL : \
QString::number(sourceId), line, message) << endl;  }
 
+        // clear it so it doesn't stop other things
+        exec->clearException();
+        
         return KJS::jsNull();
     }
     else


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

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