summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/script/api/qscriptengine.cpp5
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp8
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp4
3 files changed, 9 insertions, 8 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 97d8061..bebb972 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -2369,6 +2369,11 @@ QScriptContext *QScriptEngine::pushContext()
void QScriptEngine::popContext()
{
Q_D(QScriptEngine);
+ if (d->currentFrame->returnPC() != 0 || d->currentFrame->codeBlock() != 0
+ || d->currentFrame->returnValueRegister() != 0 || !currentContext()->parentContext()) {
+ qWarning("QScriptEngine::popContext() doesn't match with pushContext()");
+ return;
+ }
JSC::RegisterFile &registerFile = d->currentFrame->interpreter()->registerFile();
JSC::Register *const newEnd = d->currentFrame->registers() - JSC::RegisterFile::CallFrameHeaderSize - d->currentFrame->argumentCount();
d->currentFrame->scopeChain()->pop()->deref();
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index 7a363ac..87db0ad 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -487,12 +487,8 @@ void tst_QScriptContext::pushAndPopContext()
QCOMPARE(eng.currentContext(), topLevel);
// popping the top-level context is not allowed
- QEXPECT_FAIL("", "Crashes", Continue);
-#if 1
- QVERIFY(false);
-#else
- eng.popContext()
-#endif
+ QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::popContext() doesn't match with pushContext()");
+ eng.popContext();
QCOMPARE(eng.currentContext(), topLevel);
{
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 0b16980..f7bac56 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -193,9 +193,9 @@ void tst_QScriptEngine::pushPopContext()
eng.popContext();
eng.popContext();
- QEXPECT_FAIL("", "cannot pop more context than it pushes", Abort);
- QVERIFY(false);
+ QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::popContext() doesn't match with pushContext()");
eng.popContext(); // ignored
+ QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::popContext() doesn't match with pushContext()");
eng.popContext(); // ignored
}