summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin/editormanager/editormanager.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2013-11-20 10:18:22 +0100
committerKai Koehne <kai.koehne@digia.com>2013-11-20 12:42:13 +0100
commit601951a4e837f02f63ed6a5c2e199db9d325ccc0 (patch)
treebe69b719756e3e2d9cba665184ee2c60e611bb9a /src/plugins/coreplugin/editormanager/editormanager.cpp
parent551b3ed36824457add0425c72439e41fe283f3cc (diff)
downloadqt-creator-601951a4e837f02f63ed6a5c2e199db9d325ccc0.tar.gz
Clean up EditorManagerPlaceHolder
The fix in acca83add48df wasn't enough: One has to make sure that even ~EditorManagerPlaceholder doesn't delete EditorManager implicitly, since it's explicitly deleted in ~MainWindow. Anyway, EditorManagerPlaceHolder::current() is never used, so we can get rid of this static variable entirely and simplify the code by just checking for EditorManager::parent() in the PlaceHolder destructor. Change-Id: I3a0374d20c9f3f9d2680cf8302953a336670fc8a Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Diffstat (limited to 'src/plugins/coreplugin/editormanager/editormanager.cpp')
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 13e142d5be..b10cf3d2b2 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -114,8 +114,6 @@ using namespace Utils;
//===================EditorManager=====================
-EditorManagerPlaceHolder *EditorManagerPlaceHolder::m_current = 0;
-
EditorManagerPlaceHolder::EditorManagerPlaceHolder(Core::IMode *mode, QWidget *parent)
: QWidget(parent), m_mode(mode)
{
@@ -129,16 +127,17 @@ EditorManagerPlaceHolder::EditorManagerPlaceHolder(Core::IMode *mode, QWidget *p
EditorManagerPlaceHolder::~EditorManagerPlaceHolder()
{
- if (m_current == this) {
- EditorManager::instance()->setParent(0);
- EditorManager::instance()->hide();
+ // EditorManager will be deleted in ~MainWindow()
+ EditorManager *em = EditorManager::instance();
+ if (em && em->parent() == this) {
+ em->hide();
+ em->setParent(0);
}
}
void EditorManagerPlaceHolder::currentModeChanged(Core::IMode *mode)
{
if (m_mode == mode) {
- m_current = this;
QWidget *previousFocus = 0;
if (EditorManager::instance()->focusWidget() && EditorManager::instance()->focusWidget()->hasFocus())
previousFocus = EditorManager::instance()->focusWidget();
@@ -146,16 +145,9 @@ void EditorManagerPlaceHolder::currentModeChanged(Core::IMode *mode)
EditorManager::instance()->show();
if (previousFocus)
previousFocus->setFocus();
- } else if (m_current == this) {
- m_current = 0;
}
}
-EditorManagerPlaceHolder* EditorManagerPlaceHolder::current()
-{
- return m_current;
-}
-
// ---------------- EditorManager
namespace Core {