check against a null qscriptengine

This commit is contained in:
Marco Martin 2011-05-17 16:39:15 +02:00
parent a79fea0eb8
commit ff47808ef2

View File

@ -135,6 +135,9 @@ bool DeclarativeAppletScript::init()
void DeclarativeAppletScript::collectGarbage() void DeclarativeAppletScript::collectGarbage()
{ {
if (!m_engine) {
return;
}
m_engine->collectGarbage(); m_engine->collectGarbage();
} }
@ -195,6 +198,9 @@ QScriptValue DeclarativeAppletScript::newPlasmaSvg(QScriptContext *context, QScr
QScriptValue DeclarativeAppletScript::variantToScriptValue(QVariant var) QScriptValue DeclarativeAppletScript::variantToScriptValue(QVariant var)
{ {
if (!m_engine) {
return QScriptValue();
}
return m_engine->newVariant(var); return m_engine->newVariant(var);
} }
@ -297,6 +303,9 @@ void DeclarativeAppletScript::popupEvent(bool popped)
void DeclarativeAppletScript::dataUpdated(const QString &name, const Plasma::DataEngine::Data &data) void DeclarativeAppletScript::dataUpdated(const QString &name, const Plasma::DataEngine::Data &data)
{ {
if (!m_engine) {
return;
}
QScriptValueList args; QScriptValueList args;
args << m_engine->toScriptValue(name) << m_engine->toScriptValue(data); args << m_engine->toScriptValue(name) << m_engine->toScriptValue(data);
@ -308,6 +317,9 @@ void DeclarativeAppletScript::extenderItemRestored(Plasma::ExtenderItem* item)
if (!m_env) { if (!m_env) {
return; return;
} }
if (!m_engine) {
return;
}
QScriptValueList args; QScriptValueList args;
args << m_engine->newQObject(item, QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject); args << m_engine->newQObject(item, QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
@ -347,6 +359,10 @@ ScriptEnv *DeclarativeAppletScript::scriptEnv()
void DeclarativeAppletScript::setupObjects() void DeclarativeAppletScript::setupObjects()
{ {
m_engine = m_declarativeWidget->scriptEngine(); m_engine = m_declarativeWidget->scriptEngine();
if (!m_engine) {
return;
}
connect(m_engine, SIGNAL(signalHandlerException(const QScriptValue &)), connect(m_engine, SIGNAL(signalHandlerException(const QScriptValue &)),
this, SLOT(signalHandlerException(const QScriptValue &))); this, SLOT(signalHandlerException(const QScriptValue &)));