diff options
author | Kai Koehne <kai.koehne@digia.com> | 2013-08-21 12:30:46 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-21 15:55:32 +0200 |
commit | 4f35280bd039c2d2f0c53e936740440f1d887916 (patch) | |
tree | ab5f685fc7c5571552f9d6356733c541bbb2ae82 /src | |
parent | fe0b3bb05ffb80579233e367f94078da8abd935d (diff) |
Debugger: Fix crash when app exits while debugging
Make sure we don't access an already deleted v8engine any more.
Task-number: QTBUG-33100
Change-Id: Ic517577ae30b41375cbf9f787cfe0a29121171e2
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/debugger/qv8debugservice.cpp | 11 | ||||
-rw-r--r-- | src/qml/debugger/qv8debugservice_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 3 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/qml/debugger/qv8debugservice.cpp b/src/qml/debugger/qv8debugservice.cpp index 9045b4b50e..575097f829 100644 --- a/src/qml/debugger/qv8debugservice.cpp +++ b/src/qml/debugger/qv8debugservice.cpp @@ -148,12 +148,18 @@ QV8DebugService *QV8DebugService::instance() return v8ServiceInstance(); } -void QV8DebugService::initialize(const QV8Engine *engine) +void QV8DebugService::addEngine(const QV8Engine *engine) { // just make sure that the service is properly registered v8ServiceInstance()->setEngine(engine); } +void QV8DebugService::removeEngine(const QV8Engine *engine) +{ + if (v8ServiceInstance()->d_func()->engine == engine) + v8ServiceInstance()->setEngine(0); +} + void QV8DebugService::setEngine(const QV8Engine *engine) { Q_D(QV8DebugService); @@ -280,7 +286,8 @@ void QV8DebugService::processDebugMessages() { Q_D(QV8DebugService); v8::HandleScope handleScope; - v8::Context::Scope contextScope(d->engine->context()); + if (d->engine) + v8::Context::Scope contextScope(d->engine->context()); v8::Debug::ProcessDebugMessages(); } diff --git a/src/qml/debugger/qv8debugservice_p.h b/src/qml/debugger/qv8debugservice_p.h index e6f05a2397..75fd69290c 100644 --- a/src/qml/debugger/qv8debugservice_p.h +++ b/src/qml/debugger/qv8debugservice_p.h @@ -75,7 +75,8 @@ public: ~QV8DebugService(); static QV8DebugService *instance(); - static void initialize(const QV8Engine *engine); + static void addEngine(const QV8Engine *engine); + static void removeEngine(const QV8Engine *engine); void debugMessageHandler(const QString &message); diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index fef3dd21fe..cc49b4f0a2 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -749,7 +749,7 @@ void QQmlEnginePrivate::init() QQmlEngineDebugService::isDebuggingEnabled()) { isDebugging = true; QQmlEngineDebugService::instance()->addEngine(q); - QV8DebugService::initialize(v8engine()); + QV8DebugService::addEngine(v8engine()); QV8ProfilerService::initialize(); QQmlProfilerService::initialize(); QDebugMessageService::instance(); @@ -838,6 +838,7 @@ QQmlEngine::~QQmlEngine() Q_D(QQmlEngine); if (d->isDebugging) { QQmlEngineDebugService::instance()->remEngine(this); + QV8DebugService::removeEngine(handle()); } // Emit onDestruction signals for the root context before |