From 43003e18c05bf2ef950d0a0f4592a0939fd80124 Mon Sep 17 00:00:00 2001 From: con Date: Thu, 14 Jan 2010 17:49:29 +0100 Subject: [PATCH] Opening binary files leaves empty entries in open editors window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/plugins/bineditor/bineditorplugin.cpp | 11 ++++++----- .../coreplugin/editormanager/openeditorswindow.cpp | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 04bf7642f9d..e0ffa6c20b9 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 6079ee7e60c..885a6fcfe5f 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 + #include 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; - filesDone.insert(hi.file.data()); - - QTreeWidgetItem *item = new QTreeWidgetItem(); - QString title = model->displayNameForFile(hi.file); + QTC_ASSERT(!title.isEmpty(), continue;) + filesDone.insert(hi.file.data()); + QTreeWidgetItem *item = new QTreeWidgetItem(); if (hi.file->isModified()) title += tr("*"); item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon);