- fix: editors disappeared when close/close all

This commit is contained in:
royqh1979@gmail.com 2021-10-06 00:05:07 +08:00
parent 8e4c20a2a3
commit f75c9f26cf
3 changed files with 13 additions and 11 deletions

View File

@ -22,6 +22,7 @@ Version 0.6.0
- enhancement: show pinyin when input chinese characters - enhancement: show pinyin when input chinese characters
- fix: add mutex lock to prevent rare conditions when editor is modifying and the content is read - fix: add mutex lock to prevent rare conditions when editor is modifying and the content is read
- fix: makefile generated for static / dynamic library projects not right - fix: makefile generated for static / dynamic library projects not right
- fix: editors disappeared when close/close all
Version 0.5.0 Version 0.5.0
- enhancement: support C++ using type alias; - enhancement: support C++ using type alias;

View File

@ -86,10 +86,6 @@ Editor* EditorList::getEditor(int index, QTabWidget* tabsWidget) const {
} }
bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) { bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) {
beginUpdate();
auto end = finally([this] {
this->endUpdate();
});
if (editor == NULL) if (editor == NULL)
return false; return false;
if (force) { if (force) {
@ -97,7 +93,7 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) {
} else if ( (editor->modified()) && (!editor->empty())) { } else if ( (editor->modified()) && (!editor->empty())) {
// ask user if he wants to save // ask user if he wants to save
QMessageBox::StandardButton reply; QMessageBox::StandardButton reply;
reply = QMessageBox::question(pMainWindow,QObject::tr("Save"), reply = QMessageBox::question(editor,QObject::tr("Save"),
QString(QObject::tr("Save changes to %1?")).arg(editor->filename()), QString(QObject::tr("Save changes to %1?")).arg(editor->filename()),
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
if (reply == QMessageBox::Cancel) { if (reply == QMessageBox::Cancel) {
@ -109,6 +105,11 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) {
} }
} }
beginUpdate();
auto end = finally([this] {
this->endUpdate();
});
if (transferFocus && (editor->pageControl()->currentWidget()==editor)) { if (transferFocus && (editor->pageControl()->currentWidget()==editor)) {
//todo: activate & focus the previous editor //todo: activate & focus the previous editor
} }
@ -226,10 +227,10 @@ Editor *EditorList::operator[](int index)
} }
bool EditorList::closeAll(bool force) { bool EditorList::closeAll(bool force) {
beginUpdate(); // beginUpdate();
auto end = finally([this] { // auto end = finally([this] {
this->endUpdate(); // this->endUpdate();
}); // });
while (mLeftPageWidget->count()>0) { while (mLeftPageWidget->count()>0) {
if (!closeEditor(getEditor(0,mLeftPageWidget),false,force)) { if (!closeEditor(getEditor(0,mLeftPageWidget),false,force)) {
return false; return false;

View File

@ -2603,7 +2603,7 @@ void MainWindow::on_actionSave_triggered()
if (editor->inProject() && (mProject)) if (editor->inProject() && (mProject))
mProject->saveAll(); mProject->saveAll();
} catch(FileError e) { } catch(FileError e) {
QMessageBox::critical(this,tr("Error"),e.reason()); QMessageBox::critical(editor,tr("Error"),e.reason());
} }
} }
} }
@ -2615,7 +2615,7 @@ void MainWindow::on_actionSaveAs_triggered()
try { try {
editor->saveAs(); editor->saveAs();
} catch(FileError e) { } catch(FileError e) {
QMessageBox::critical(this,tr("Error"),e.reason()); QMessageBox::critical(editor,tr("Error"),e.reason());
} }
} }
} }