Commit 601951a4 authored by Kai Koehne's avatar Kai Koehne

Clean up EditorManagerPlaceHolder

The fix in acca83ad 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: default avatarEike Ziller <eike.ziller@digia.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 551b3ed3
......@@ -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 {
......
......@@ -79,12 +79,10 @@ class CORE_EXPORT EditorManagerPlaceHolder : public QWidget
public:
explicit EditorManagerPlaceHolder(Core::IMode *mode, QWidget *parent = 0);
~EditorManagerPlaceHolder();
static EditorManagerPlaceHolder* current();
private slots:
void currentModeChanged(Core::IMode *);
private:
Core::IMode *m_mode;
static EditorManagerPlaceHolder* m_current;
};
class CORE_EXPORT EditorManager : public QWidget
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment