From 7f2fadda40fa79a35e9c77ef4f9613940c23f382 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 10 Jul 2009 15:25:22 +0200 Subject: don't crash during GC if no prototype has been set for a metatype Also, have pushContext() return currentContext() for now, to avoid crashing, and disable processing of __postInit__ property in importExtension() for same reason. --- src/script/api/qscriptengine.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index cd31b8d..f5b798a 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -505,8 +505,10 @@ void GlobalObject::mark() { QHash::const_iterator it; - for (it = engine->m_typeInfos.constBegin(); it != engine->m_typeInfos.constEnd(); ++it) - (*it)->prototype.mark(); + for (it = engine->m_typeInfos.constBegin(); it != engine->m_typeInfos.constEnd(); ++it) { + if ((*it)->prototype) + (*it)->prototype.mark(); + } } } @@ -1838,7 +1840,7 @@ QScriptContext *QScriptEngine::pushContext() { Q_D(QScriptEngine); qWarning("QScriptEngine::pushContext() not implemented"); - return 0; + return d->contextForFrame(d->currentFrame); #ifndef Q_SCRIPT_NO_EVENT_NOTIFY // notifyContextPush(); TODO #endif @@ -2579,7 +2581,8 @@ QScriptValue QScriptEngine::importExtension(const QString &extension) } // if the __postInit__ function has been set, we call it - QScriptValue postInit = ctx->activationObject().property(QLatin1String("__postInit__")); + // ### enable once activationObject() works + QScriptValue postInit; // = ctx->activationObject().property(QLatin1String("__postInit__")); if (postInit.isFunction()) { postInit.call(globalObject()); if (hasUncaughtException()) { -- cgit v0.12