- Revision
- 125439
- Author
- [email protected]
- Date
- 2012-08-13 13:12:52 -0700 (Mon, 13 Aug 2012)
Log Message
[Qt] Clean up exception handling
https://bugs.webkit.org/show_bug.cgi?id=93880
Reviewed by Kenneth Rohde Christiansen.
The JSC C API uses a JSValueRef* exception parameter to indicate to the
caller that an exception was thrown. Naturally the caller must store
that ValueRef on the stack in order to get seen and marked by the
garbage collector, otherwise the callee would have to use
JSValueProtect on it.
This patch fixes one such case where in fact the exception pointer was passed as zero to the
callee and thus ignored. The patch also removes an unused exception parameter.
* bridge/qt/qt_class.cpp:
(JSC::Bindings::QtClass::fallbackObject):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::QtRuntimeMethod::QtRuntimeMethod):
* bridge/qt/qt_runtime.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (125438 => 125439)
--- trunk/Source/WebCore/ChangeLog 2012-08-13 20:05:13 UTC (rev 125438)
+++ trunk/Source/WebCore/ChangeLog 2012-08-13 20:12:52 UTC (rev 125439)
@@ -1,3 +1,25 @@
+2012-08-13 Simon Hausmann <[email protected]>
+
+ [Qt] Clean up exception handling
+ https://bugs.webkit.org/show_bug.cgi?id=93880
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ The JSC C API uses a JSValueRef* exception parameter to indicate to the
+ caller that an exception was thrown. Naturally the caller must store
+ that ValueRef on the stack in order to get seen and marked by the
+ garbage collector, otherwise the callee would have to use
+ JSValueProtect on it.
+
+ This patch fixes one such case where in fact the exception pointer was passed as zero to the
+ callee and thus ignored. The patch also removes an unused exception parameter.
+
+ * bridge/qt/qt_class.cpp:
+ (JSC::Bindings::QtClass::fallbackObject):
+ * bridge/qt/qt_runtime.cpp:
+ (JSC::Bindings::QtRuntimeMethod::QtRuntimeMethod):
+ * bridge/qt/qt_runtime.h:
+
2012-08-13 Pavel Feldman <[email protected]>
Web Inspector: remove commitEditing from the text editor delegate.
Modified: trunk/Source/WebCore/bridge/qt/qt_class.cpp (125438 => 125439)
--- trunk/Source/WebCore/bridge/qt/qt_class.cpp 2012-08-13 20:05:13 UTC (rev 125438)
+++ trunk/Source/WebCore/bridge/qt/qt_class.cpp 2012-08-13 20:12:52 UTC (rev 125439)
@@ -71,14 +71,18 @@
{
QtInstance* qtinst = static_cast<QtInstance*>(inst);
JSContextRef context = toRef(exec);
- JSValueRef* exception = 0;
+ JSValueRef exception = 0;
UString ustring(identifier.publicName());
const QByteArray name = QString(reinterpret_cast<const QChar*>(ustring.characters()), ustring.length()).toLatin1();
// First see if we have a cache hit
- if (QtRuntimeMethod* method = qtinst->m_methods.value(name))
- return toJS(method->jsObjectRef(context, exception));
+ if (QtRuntimeMethod* method = qtinst->m_methods.value(name)) {
+ JSValue obj = toJS(method->jsObjectRef(context, &exception));
+ if (exception)
+ return throwError(exec, toJS(exec, exception));
+ return obj;
+ }
// Nope, create an entry
const QByteArray normal = QMetaObject::normalizedSignature(name.constData());
@@ -109,9 +113,12 @@
return jsUndefined();
int flags = metaMethod.methodType() == QMetaMethod::Signal ? QtRuntimeMethod::MethodIsSignal : 0;
- QtRuntimeMethod* method = new QtRuntimeMethod(context, exception, static_cast<QtInstance*>(inst)->getObject(), normal, index, flags, qtinst);
+ QtRuntimeMethod* method = new QtRuntimeMethod(context, static_cast<QtInstance*>(inst)->getObject(), normal, index, flags, qtinst);
qtinst->m_methods.insert(name, method);
- return toJS(method->jsObjectRef(context, exception));
+ JSValue obj = toJS(method->jsObjectRef(context, &exception));
+ if (exception)
+ return throwError(exec, toJS(exec, exception));
+ return obj;
}
// This functionality is handled by the fallback case above...
Modified: trunk/Source/WebCore/bridge/qt/qt_runtime.cpp (125438 => 125439)
--- trunk/Source/WebCore/bridge/qt/qt_runtime.cpp 2012-08-13 20:05:13 UTC (rev 125438)
+++ trunk/Source/WebCore/bridge/qt/qt_runtime.cpp 2012-08-13 20:12:52 UTC (rev 125439)
@@ -1290,7 +1290,7 @@
return cls;
}
-QtRuntimeMethod::QtRuntimeMethod(JSContextRef ctx, JSValueRef* exception, QObject* object, const QByteArray& identifier, int index, int flags, QtInstance* instance)
+QtRuntimeMethod::QtRuntimeMethod(JSContextRef ctx, QObject* object, const QByteArray& identifier, int index, int flags, QtInstance* instance)
: m_object(object)
, m_identifier(identifier)
, m_index(index)
Modified: trunk/Source/WebCore/bridge/qt/qt_runtime.h (125438 => 125439)
--- trunk/Source/WebCore/bridge/qt/qt_runtime.h 2012-08-13 20:05:13 UTC (rev 125438)
+++ trunk/Source/WebCore/bridge/qt/qt_runtime.h 2012-08-13 20:12:52 UTC (rev 125439)
@@ -102,7 +102,7 @@
AllowPrivate = 2
};
- QtRuntimeMethod(JSContextRef, JSValueRef* exception, QObject*, const QByteArray& identifier, int signalIndex, int flags, QtInstance*);
+ QtRuntimeMethod(JSContextRef, QObject*, const QByteArray& identifier, int signalIndex, int flags, QtInstance*);
~QtRuntimeMethod();
static JSValueRef call(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);