diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2009-11-23 14:26:36 (GMT) |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2009-11-23 14:37:47 (GMT) |
commit | 23002374d11598b26b6585e78dc073071a13f0ec (patch) | |
tree | ea6c40cc26758a9f8011921c5477079ea3e256c9 /src/script/api | |
parent | 8644ff560002c4ae786e5b1f11450c1b1f80e7e8 (diff) | |
download | Qt-23002374d11598b26b6585e78dc073071a13f0ec.zip Qt-23002374d11598b26b6585e78dc073071a13f0ec.tar.gz Qt-23002374d11598b26b6585e78dc073071a13f0ec.tar.bz2 |
Don't crash in eval() function when QtScript debugger is attached
The built-in eval() function bypasses the script registration
performed by QScriptEngine::evaluate(), so if we get an
atStatement() callback from JSC from that script, the
scriptID-to-sourceProvider lookup will fail.
In this case, just return from atStatement() without delivering
the positionChange() callback to the QScriptEngineAgent, since
the agent will not have received the scriptLoad() callback for
that script anyway.
This is a change in behavior from 4.5, but we consider it
the minimum-impact fix at this point to keep 4.6.0 from
crashing. The only downside is that debugging will
effectively be "disabled" for the script passed to eval(),
but that's a lot better than crashing.
Task-number: QTBUG-6108
Reviewed-by: Jedrzej Nowacki
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/qscriptengineagent.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp index e7998b7..a2af514 100644 --- a/src/script/api/qscriptengineagent.cpp +++ b/src/script/api/qscriptengineagent.cpp @@ -154,7 +154,10 @@ void QScriptEngineAgentPrivate::exceptionCatch(const JSC::DebuggerCallFrame& fra void QScriptEngineAgentPrivate::atStatement(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, int column) { QScript::UStringSourceProviderWithFeedback *source = engine->loadedScripts.value(sourceID); - Q_ASSERT(source != 0); + if (!source) { + // QTBUG-6108: We don't have the source for this script, so ignore. + return; + } column = source->columnNumberFromOffset(column); JSC::CallFrame *oldFrame = engine->currentFrame; int oldAgentLineNumber = engine->agentLineNumber; @@ -183,7 +186,10 @@ void QScriptEngineAgentPrivate::didReachBreakpoint(const JSC::DebuggerCallFrame& { if (q_ptr->supportsExtension(QScriptEngineAgent::DebuggerInvocationRequest)) { QScript::UStringSourceProviderWithFeedback *source = engine->loadedScripts.value(sourceID); - Q_ASSERT(source != 0); + if (!source) { + // QTBUG-6108: We don't have the source for this script, so ignore. + return; + } column = source->columnNumberFromOffset(column); JSC::CallFrame *oldFrame = engine->currentFrame; int oldAgentLineNumber = engine->agentLineNumber; |