>From 841b7d884a0156bc658e37792c6e73472f815472 Mon Sep 17 00:00:00 2001 From: Rostislav Khlebnikov Date: Tue, 25 Aug 2015 16:45:51 +0100 Subject: [PATCH] Fixed a crash on exit --- .../src/internal/berryWorkbenchSourceProvider.cpp | 22 ++++++++++------------ .../src/internal/berryWorkbenchSourceProvider.h | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchSourceProvider.cpp b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchSourceProvider.cpp index bc61d1b..652697e 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchSourceProvider.cpp +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchSourceProvider.cpp @@ -66,8 +66,6 @@ WorkbenchSourceProvider::WorkbenchSourceProvider() , lastShowInInput(nullptr) , lastEditorInput(nullptr) , display(nullptr) - , lastActiveShell(nullptr) - , lastActiveWorkbenchWindowShell(nullptr) { } @@ -94,8 +92,8 @@ WorkbenchSourceProvider::~WorkbenchSourceProvider() qApp->removeEventFilter(this); HookListener(const_cast(lastActiveWorkbenchWindow.Lock().GetPointer()), nullptr); lastActiveWorkbenchWindow.Reset(); - lastActiveWorkbenchWindowShell = nullptr; - lastActiveShell = nullptr; + lastActiveWorkbenchWindowShell.Reset(); + lastActiveShell.Reset(); lastWindow.Reset(); } @@ -224,9 +222,9 @@ void WorkbenchSourceProvider::WindowOpened(const SmartPointer& void WorkbenchSourceProvider::HandleCheck(const SmartPointer& s) { - if (s != lastActiveShell) + if (s != lastActiveShell.Lock()) { - lastActiveShell = s.GetPointer(); + lastActiveShell = s; CheckActivePart(); IWorkbenchWindow* window = nullptr; if (s.IsNotNull()) @@ -593,9 +591,9 @@ void WorkbenchSourceProvider::HandleShellEvent() // } LogDebuggingInfo("\tWSP:lastActiveShell: " + - (lastActiveShell ? lastActiveShell->GetControl()->objectName() : QString("NULL"))); + (!lastActiveShell.Expired() ? lastActiveShell.Lock()->GetControl()->objectName() : QString("NULL"))); LogDebuggingInfo("\tWSP:lastActiveWorkbenchWindowShell: " + - (lastActiveWorkbenchWindowShell ? lastActiveWorkbenchWindowShell->GetControl()->objectName() : QString("NULL"))); + (!lastActiveWorkbenchWindowShell.Expired() ? lastActiveWorkbenchWindowShell.Lock()->GetControl()->objectName() : QString("NULL"))); const ISourceProvider::StateMapType currentState = GetCurrentState(); const Shell::ConstPointer newActiveShell = currentState.value(ISources::ACTIVE_SHELL_NAME()).Cast(); @@ -632,8 +630,8 @@ void WorkbenchSourceProvider::HandleShellEvent() } // Figure out which variables have changed. - const bool shellChanged = newActiveShell != lastActiveShell; - const bool windowChanged = newActiveWorkbenchWindowShell != lastActiveWorkbenchWindowShell; + const bool shellChanged = newActiveShell != lastActiveShell.Lock(); + const bool windowChanged = newActiveWorkbenchWindowShell != lastActiveWorkbenchWindowShell.Lock(); const bool toolbarChanged = newToolbarVisibility != lastToolbarVisibility; const bool statusLineChanged = newStatusLineVis != lastStatusLineVisibility; @@ -748,8 +746,8 @@ void WorkbenchSourceProvider::HandleShellEvent() } // Update the member variables. - lastActiveShell = newActiveShell.GetPointer(); - lastActiveWorkbenchWindowShell = newActiveWorkbenchWindowShell.GetPointer(); + lastActiveShell = newActiveShell; + lastActiveWorkbenchWindowShell = newActiveWorkbenchWindowShell; lastActiveWorkbenchWindow = newActiveWorkbenchWindow; lastToolbarVisibility = newToolbarVisibility; lastStatusLineVisibility = newStatusLineVis; diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchSourceProvider.h b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchSourceProvider.h index 16f87cc..a502935 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchSourceProvider.h +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchSourceProvider.h @@ -157,7 +157,7 @@ private: * null if the last call to * Display.getActiveShell() returned null. */ - const Shell* lastActiveShell; + WeakPointer lastActiveShell; /** * The last workbench window shell seen as active by this provider. This @@ -165,7 +165,7 @@ private: * workbench.getActiveWorkbenchWindow() returned * null. */ - const Shell* lastActiveWorkbenchWindowShell; + WeakPointer lastActiveWorkbenchWindowShell; /** * The last workbench window seen as active by this provider. This value may -- 1.8.4.msysgit.0