diff options
author | con <qtc-committer@nokia.com> | 2010-01-14 17:49:29 +0100 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2010-01-14 18:17:31 +0100 |
commit | 43003e18c05bf2ef950d0a0f4592a0939fd80124 (patch) | |
tree | d50bf364b63f65106871cff91c4465b1e0fb00ac | |
parent | ee0e1bdd8ca6258f93b5cafd9c25ec8551763da6 (diff) | |
download | qt-creator-43003e18c05bf2ef950d0a0f4592a0939fd80124.tar.gz |
Opening binary files leaves empty entries in open editors window
Leading to a crash when selecting the empty entry.
The patch fixes a big memory leak with bin editors (neither the widget
nor the IFile instance was deleted, the latter leading to the empty
entry in the open editors window), and also puts a saveguard in the open
editors window, so that empty entries are not shown any more.
Task-number: QTCREATORBUG-571
Reviewed-by: Thorbjørn
(cherry picked from commit cd8bc8a207fce7c019facbd26bbbbb818116b821)
-rw-r--r-- | src/plugins/bineditor/bineditorplugin.cpp | 11 | ||||
-rw-r--r-- | src/plugins/coreplugin/editormanager/openeditorswindow.cpp | 7 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 04bf7642f9..e0ffa6c20b 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -297,12 +297,11 @@ class BinEditorInterface : public Core::IEditor { Q_OBJECT public: - BinEditorInterface(BinEditor *parent) - : Core::IEditor(parent) + BinEditorInterface(BinEditor *editor) { Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); - m_editor = parent; - m_file = new BinEditorFile(parent); + m_editor = editor; + m_file = new BinEditorFile(m_editor); m_context << uidm->uniqueIdentifier(Core::Constants::K_DEFAULT_BINARY_EDITOR); m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR); m_cursorPositionLabel = new Utils::LineColumnLabel; @@ -321,7 +320,9 @@ public: connect(m_editor, SIGNAL(cursorPositionChanged(int)), this, SLOT(updateCursorPosition(int))); } - ~BinEditorInterface() {} + ~BinEditorInterface() { + delete m_editor; + } QWidget *widget() { return m_editor; } diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 6079ee7e60..885a6fcfe5 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -32,6 +32,8 @@ #include "editormanager.h" #include "editorview.h" +#include <utils/qtcassert.h> + #include <QtGui/QHeaderView> Q_DECLARE_METATYPE(Core::Internal::EditorView*) @@ -201,11 +203,10 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE foreach (const EditLocation &hi, view->editorHistory()) { if (hi.file.isNull() || filesDone.contains(hi.file)) continue; + QString title = model->displayNameForFile(hi.file); + QTC_ASSERT(!title.isEmpty(), continue;) filesDone.insert(hi.file.data()); - QTreeWidgetItem *item = new QTreeWidgetItem(); - - QString title = model->displayNameForFile(hi.file); if (hi.file->isModified()) title += tr("*"); item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon); |