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

List:       kde-commits
Subject:    KDE/kdelibs/kjsembed
From:       Erik Lloyd Bunce <kde () bunce ! us>
Date:       2007-04-27 19:56:09
Message-ID: 1177703769.664062.16583.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 658578 by bunce:

Improve SlotProxy exception handling so it no longer causes a crash\!  Make kjsembed \
Engine::runFile() include the file name when calling the underlying kjs interpreter. \
Make QObject binding lookup more robust in the face of namespaces. Fix Qt-only build.

 M  +1 -1      kjsembed/kjsembed.cpp  
 M  +12 -2     kjsembed/qobject_binding.cpp  
 M  +25 -6     kjsembed/slotproxy.cpp  
 M  +3 -0      qtonly/CMakeLists.txt  


--- trunk/KDE/kdelibs/kjsembed/kjsembed/kjsembed.cpp #658577:658578
@@ -230,7 +230,7 @@
 
 //    qDebug() << "Loaded code: " << toQString(code);
     
-    return interpreter->evaluate( KJS::UString(""), 0, code, 0 );
+    return interpreter->evaluate( fileName, 0, code, 0 );
 }
 
 Engine::ExitStatus Engine::runFile( const KJS::UString &fileName )
--- trunk/KDE/kdelibs/kjsembed/kjsembed/qobject_binding.cpp #658577:658578
@@ -701,15 +701,25 @@
     const QMetaObject *meta = value->metaObject();
     KJS::JSObject *parent = exec->dynamicInterpreter()->globalObject();
     KJS::JSObject *returnValue;
-
+    int pos;
     QString clazz;
     do
     {
         clazz = meta->className();
+        
+#ifdef CREATEQOBJ_DIAG
+        qDebug() << "clazz=" << clazz;
+#endif
+        // strip off namespace since they aren't included
+        if ((pos = clazz.lastIndexOf("::")) != -1)
+            clazz.remove(0, pos + 2);
+#ifdef CREATEQOBJ_DIAG
+        qDebug() << "cleaned clazz=" << clazz;
+#endif
         if ( parent->hasProperty( exec, KJS::Identifier(toUString(clazz)) ) )
         {
 #ifdef CREATEQOBJ_DIAG
-            qDebug() << "createQObject(): clazz=" << clazz << " value=" << value;// \
<< " typeid(T)=" << typeid(T).name(); +            qDebug() << "createQObject(): \
clazz=" << clazz << " value=" << value;  #endif
             Pointer<QObject> pov(value);
             returnValue = StaticConstructor::bind(exec, clazz, pov);
--- trunk/KDE/kdelibs/kjsembed/kjsembed/slotproxy.cpp #658577:658578
@@ -65,10 +65,16 @@
     staticMetaObject.d.stringdata = m_stringData.data();
     staticMetaObject.d.data = m_data;
     staticMetaObject.d.extradata = 0;
+#ifdef DEBUG_SLOTPROXY
+		qDebug() << "SlotProxy() obj=" << this <<  " m_signature=" << m_signature;
+#endif
 }
 
 SlotProxy::~SlotProxy()
 {
+#ifdef DEBUG_SLOTPROXY
+	qDebug() << "??????SlotProxy::~SlotProxy() obj=" << this <<" m_signature=" << \
m_signature; +#endif
 }
 
 const QMetaObject *SlotProxy::metaObject() const
@@ -87,7 +93,7 @@
 KJS::JSValue *SlotProxy::callMethod( const QByteArray & methodName, void **_a )
 {
 #ifdef DEBUG_SLOTPROXY
-    qDebug() << "SlotProxy::callMethod(" << methodName << ",_a)";
+	qDebug() << "SlotProxy::callMethod(" << methodName << ",_a) obj=" << this;
 #endif
     KJS::ExecState *exec = m_interpreter->globalExec();
     // Crash
@@ -104,9 +110,22 @@
 
     if( exec->hadException() )
     {
-    //TODO ext the script here with the error
-      m_interpreter->deref();
-      return KJS::jsNull();
+        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); +            // 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();
+        }
+
+        return KJS::jsNull();
     }
     else
     {
@@ -126,7 +145,7 @@
     QList<QByteArray> params = method.parameterTypes();
     int idx = 1;
 #ifdef DEBUG_SLOTPROXY
-    qDebug() << "SlotProxy::convertArguments(): m_signature" << m_signature << " \
offset=" << offset << " params=" << params; +    qDebug() << \
"SlotProxy::convertArguments(): obj=" << this << " m_signature=" << m_signature << " \
offset=" << offset << " params=" << params ;  #endif
     foreach( QByteArray param, params )
     {
@@ -238,7 +257,7 @@
 int SlotProxy::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
 {
 #if defined(DEBUG_SLOTPROXY) && (DEBUG_SLOTPROXY > 1)
-    qDebug("SlotProxy::qt_metacall(_c=%d, _id=%d, _a=%p _a[0]=%p _a[1]=%p", _c, _id, \
_a, _a[0], _a[1]); +	qDebug("SlotProxy::qt_metacall(_c=%d, _id=%d, _a=%p _a[0]=%p \
_a[1]=%p) obj=", _c, _id, _a, _a[0], _a[1], this);  #endif
     _id = QObject::qt_metacall(_c, _id, _a);
     if (_id < 0)
--- trunk/KDE/kdelibs/kjsembed/qtonly/CMakeLists.txt #658577:658578
@@ -102,6 +102,9 @@
 # Use the one variable for the lib you depend upon.
 # E.g. kdeui uses ${QJS_KDECORE_INCLUDES}. Something that depends on kparts uses \
${QJS_KPARTS_INCLUDES}.  
+set(KDE4_KJS_INCLUDES ${CMAKE_SOURCE_DIR}/kjs
+                      ${CMAKE_BINARY_DIR}/kjs)
+
 # kdecore depends on Qt
 set(QJS_KDECORE_INCLUDES ${CMAKE_SOURCE_DIR}/kdecore ${CMAKE_BINARY_DIR}/kdecore \
${CMAKE_SOURCE_DIR}/kdecore/network ${QT_INCLUDES} \
${CMAKE_SOURCE_DIR}/kdecore/kservice ${_QJS_PLATFORM_INCLUDE_DIRS})  


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

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