Commit cd8bc8a2 authored by con's avatar con
Browse files

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
parent 1da2e9e8
...@@ -297,12 +297,11 @@ class BinEditorInterface : public Core::IEditor ...@@ -297,12 +297,11 @@ class BinEditorInterface : public Core::IEditor
{ {
Q_OBJECT Q_OBJECT
public: public:
BinEditorInterface(BinEditor *parent) BinEditorInterface(BinEditor *editor)
: Core::IEditor(parent)
{ {
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
m_editor = parent; m_editor = editor;
m_file = new BinEditorFile(parent); m_file = new BinEditorFile(m_editor);
m_context << uidm->uniqueIdentifier(Core::Constants::K_DEFAULT_BINARY_EDITOR); m_context << uidm->uniqueIdentifier(Core::Constants::K_DEFAULT_BINARY_EDITOR);
m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR); m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR);
m_cursorPositionLabel = new Utils::LineColumnLabel; m_cursorPositionLabel = new Utils::LineColumnLabel;
...@@ -321,7 +320,9 @@ public: ...@@ -321,7 +320,9 @@ public:
connect(m_editor, SIGNAL(cursorPositionChanged(int)), this, SLOT(updateCursorPosition(int))); connect(m_editor, SIGNAL(cursorPositionChanged(int)), this, SLOT(updateCursorPosition(int)));
} }
~BinEditorInterface() {} ~BinEditorInterface() {
delete m_editor;
}
QWidget *widget() { return m_editor; } QWidget *widget() { return m_editor; }
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include "editormanager.h" #include "editormanager.h"
#include "editorview.h" #include "editorview.h"
#include <utils/qtcassert.h>
#include <QtGui/QHeaderView> #include <QtGui/QHeaderView>
Q_DECLARE_METATYPE(Core::Internal::EditorView*) Q_DECLARE_METATYPE(Core::Internal::EditorView*)
...@@ -201,11 +203,10 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE ...@@ -201,11 +203,10 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
foreach (const EditLocation &hi, view->editorHistory()) { foreach (const EditLocation &hi, view->editorHistory()) {
if (hi.file.isNull() || filesDone.contains(hi.file)) if (hi.file.isNull() || filesDone.contains(hi.file))
continue; continue;
QString title = model->displayNameForFile(hi.file);
QTC_ASSERT(!title.isEmpty(), continue;)
filesDone.insert(hi.file.data()); filesDone.insert(hi.file.data());
QTreeWidgetItem *item = new QTreeWidgetItem(); QTreeWidgetItem *item = new QTreeWidgetItem();
QString title = model->displayNameForFile(hi.file);
if (hi.file->isModified()) if (hi.file->isModified())
title += tr("*"); title += tr("*");
item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon); item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon);
......
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