Commit f0218b8f authored by mae's avatar mae
Browse files

fix occasionally broken link to the modified state of the editor

parent c6eced4c
......@@ -72,6 +72,9 @@ QList<IEditor *> OpenEditorsModel::editors() const
void OpenEditorsModel::addEditor(IEditor *editor, bool isDuplicate)
{
if (!editor)
return;
if (isDuplicate) {
m_duplicateEditors.append(editor);
return;
......@@ -195,7 +198,7 @@ int OpenEditorsModel::restoredEditorCount() const
bool OpenEditorsModel::isDuplicate(IEditor *editor) const
{
return m_duplicateEditors.contains(editor);
return editor && m_duplicateEditors.contains(editor);
}
IEditor *OpenEditorsModel::originalForDuplicate(IEditor *duplicate) const
......@@ -219,13 +222,15 @@ QList<IEditor *> OpenEditorsModel::duplicatesFor(IEditor *editor) const
void OpenEditorsModel::makeOriginal(IEditor *duplicate)
{
Q_ASSERT(isDuplicate(duplicate));
Q_ASSERT(duplicate && isDuplicate(duplicate));
IEditor *original = originalForDuplicate(duplicate);
Q_ASSERT(original);
int i = findEditor(original);
m_editors[i].editor = duplicate;
m_duplicateEditors.removeOne(duplicate);
m_duplicateEditors.append(original);
disconnect(original, SIGNAL(changed()), this, SLOT(itemChanged()));
connect(duplicate, SIGNAL(changed()), this, SLOT(itemChanged()));
}
void OpenEditorsModel::emitDataChanged(IEditor *editor)
......
......@@ -199,14 +199,14 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
QSet<IFile*> filesDone;
foreach (const EditLocation &hi, view->editorHistory()) {
if (hi.file == 0 || filesDone.contains(hi.file))
if (hi.file.isNull() || filesDone.contains(hi.file))
continue;
filesDone.insert(hi.file.data());
QTreeWidgetItem *item = new QTreeWidgetItem();
QString title = model->displayNameForFile(hi.file);
if (hi.file && hi.file->isModified())
if (hi.file->isModified())
title += tr("*");
item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon);
item->setText(0, title);
......@@ -226,20 +226,21 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
// add missing editors from the main view
if (mainView != view) {
foreach (const EditLocation &hi, mainView->editorHistory()) {
if (hi.file == 0 || filesDone.contains(hi.file))
if (hi.file.isNull() || filesDone.contains(hi.file))
continue;
filesDone.insert(hi.file.data());
QTreeWidgetItem *item = new QTreeWidgetItem();
QString title = model->displayNameForFile(hi.file);
if (hi.file && hi.file->isModified())
if (hi.file->isModified())
title += tr("*");
item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon);
item->setText(0, title);
item->setToolTip(0, hi.file->fileName());
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.file.data()));
item->setData(0, Qt::UserRole+1, QVariant::fromValue(view));
item->setData(0, Qt::UserRole+2, QVariant::fromValue(hi.kind));
item->setTextAlignment(0, Qt::AlignLeft);
m_editorList->addTopLevelItem(item);
......
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