Commit dfa7995b authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.designModeWidget: fix

Using a QWeakPointer for m_textEditor, since the texteditor might be
deleted if the document was closed.
Moving the NavigationHistory handling upwards.

Change-Id: Ib5c14d6cd139490379cc2bf76d5440720c5664bc
Reviewed-on: http://codereview.qt.nokia.com/526

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 11457966
...@@ -185,7 +185,6 @@ void DocumentWarningWidget::goToError() ...@@ -185,7 +185,6 @@ void DocumentWarningWidget::goToError()
DesignModeWidget::DesignModeWidget(QWidget *parent) : DesignModeWidget::DesignModeWidget(QWidget *parent) :
QWidget(parent), QWidget(parent),
m_syncWithTextEdit(false), m_syncWithTextEdit(false),
m_textEditor(0),
m_mainSplitter(0), m_mainSplitter(0),
m_leftSideBar(0), m_leftSideBar(0),
m_rightSideBar(0), m_rightSideBar(0),
...@@ -271,8 +270,12 @@ void DesignModeWidget::toggleSidebars() ...@@ -271,8 +270,12 @@ void DesignModeWidget::toggleSidebars()
void DesignModeWidget::showEditor(Core::IEditor *editor) void DesignModeWidget::showEditor(Core::IEditor *editor)
{ {
if (m_textEditor && editor) if (m_textEditor && editor)
if (m_textEditor->file()->fileName() == editor->file()->fileName()) if (m_textEditor->file()->fileName() != editor->file()->fileName()) {
return; if (!m_keepNavigatorHistory)
addNavigatorHistoryEntry(editor->file()->fileName());
setupNavigatorHistory();
}
// //
// Prevent recursive calls to function by explicitly managing initialization status // Prevent recursive calls to function by explicitly managing initialization status
// (QApplication::processEvents is called explicitly at a number of places) // (QApplication::processEvents is called explicitly at a number of places)
...@@ -295,9 +298,6 @@ void DesignModeWidget::showEditor(Core::IEditor *editor) ...@@ -295,9 +298,6 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
textEditor = qobject_cast<TextEditor::ITextEditor*>(editor); textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
if (textEditor) if (textEditor)
m_fakeToolBar->addEditor(textEditor); m_fakeToolBar->addEditor(textEditor);
if (!m_keepNavigatorHistory)
addNavigatorHistoryEntry(fileName);
setupNavigatorHistory();
} }
if (debug) if (debug)
......
...@@ -130,7 +130,7 @@ public: ...@@ -130,7 +130,7 @@ public:
void saveSettings(); void saveSettings();
void setAutoSynchronization(bool sync); void setAutoSynchronization(bool sync);
TextEditor::ITextEditor *textEditor() const {return m_textEditor; } TextEditor::ITextEditor *textEditor() const {return m_textEditor.data(); }
private slots: private slots:
void undo(); void undo();
...@@ -200,7 +200,7 @@ private: ...@@ -200,7 +200,7 @@ private:
void setupNavigatorHistory(); void setupNavigatorHistory();
void addNavigatorHistoryEntry(const QString &fileName); void addNavigatorHistoryEntry(const QString &fileName);
TextEditor::ITextEditor *m_textEditor; QWeakPointer<TextEditor::ITextEditor> m_textEditor;
QSplitter *m_mainSplitter; QSplitter *m_mainSplitter;
Core::SideBar *m_leftSideBar; Core::SideBar *m_leftSideBar;
......
Supports Markdown
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