forked from qt-creator/qt-creator
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 cd8bc8a207
)
This commit is contained in:
@@ -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; }
|
||||
|
||||
|
@@ -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;
|
||||
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);
|
||||
|
Reference in New Issue
Block a user