Permalink
Browse files

qtscript: Add check that callback function exists for setTimer() and …

…queue().
  • Loading branch information...
1 parent 7c52f5c commit c91644c3dc569d872c4f99aba36a2ac65e6aa213 @perim perim committed Mar 15, 2013
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/qtscript.cpp
View
@@ -192,6 +192,9 @@ static QScriptValue js_setTimer(QScriptContext *context, QScriptEngine *engine)
QScriptValue ms = context->argument(1);
int player = engine->globalObject().property("me").toInt32();
timerNode node(engine, funcName, player, ms.toInt32());
+ QScriptValue value = engine->globalObject().property(funcName); // check existence
+ SCRIPT_ASSERT(context, value.isValid() && value.isFunction(), "No such function: %s",
+ funcName.toUtf8().constData());
if (context->argumentCount() == 3)
{
QScriptValue obj = context->argument(2);
@@ -251,6 +254,9 @@ static QScriptValue js_queue(QScriptContext *context, QScriptEngine *engine)
{
SCRIPT_ASSERT(context, context->argument(0).isString(), "Queued functions must be quoted");
QString funcName = context->argument(0).toString();
+ QScriptValue value = engine->globalObject().property(funcName); // check existence
+ SCRIPT_ASSERT(context, value.isValid() && value.isFunction(), "No such function: %s",
+ funcName.toUtf8().constData());
int ms = 0;
if (context->argumentCount() > 1)
{

0 comments on commit c91644c

Please sign in to comment.