aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-20 23:56:21 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-20 23:56:21 +0200
commitf52a726031cc1e8c646c3d616a502b78d01099b0 (patch)
treed04ab88b35d10498e83be5f1968ff7cd9ef9acb3
parent5f98bb5930eb24de0d087b6201d3f58f0df55178 (diff)
downloadqtmips-f52a726031cc1e8c646c3d616a502b78d01099b0.tar.gz
qtmips-f52a726031cc1e8c646c3d616a502b78d01099b0.tar.bz2
qtmips-f52a726031cc1e8c646c3d616a502b78d01099b0.zip
Resolve emscripten problem with save as during close by queued connection.
It seems that directly connected one dialog result signal to method which created another modal dialog results in new dialog to be hidden when finished dialog closes under emscripten. Queued connection resolves this problem for simple case of source file close. It still does not resolve save as invocation during complete application close. Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
-rw-r--r--qtmips_gui/mainwindow.cpp23
-rw-r--r--qtmips_gui/mainwindow.h2
-rw-r--r--qtmips_gui/savechangeddialog.h2
-rw-r--r--qtmips_gui/srceditor.cpp4
-rw-r--r--qtmips_gui/srceditor.h1
5 files changed, 19 insertions, 13 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index b56fa85..cbee3e5 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -452,15 +452,20 @@ void MainWindow::closeEvent(QCloseEvent *event) {
QStringList list;
if (modified_file_list(list, true) && !ignore_unsaved) {
+ event->ignore();
SaveChnagedDialog *dialog = new SaveChnagedDialog(list, this);
- connect(dialog, SIGNAL(user_decision(bool,QStringList&)),
- this, SLOT(save_exit_or_ignore(bool,QStringList&)));
+ int id = qMetaTypeId<QStringList>();
+ if(!QMetaType::isRegistered(id)) {
+ qRegisterMetaType<QStringList>();
+ }
+ connect(dialog, SIGNAL(user_decision(bool,QStringList)),
+ this, SLOT(save_exit_or_ignore(bool,QStringList)),
+ Qt::QueuedConnection);
dialog->open();
- event->ignore();
}
}
-void MainWindow::save_exit_or_ignore(bool cancel, QStringList &tosavelist) {
+void MainWindow::save_exit_or_ignore(bool cancel, QStringList tosavelist) {
bool save_unnamed = false;
if (cancel)
return;
@@ -739,7 +744,7 @@ void MainWindow::save_source_as() {
dialog->setMinimumSize(QSize(200, 100));
dialog->setAttribute(Qt::WA_DeleteOnClose);
connect(dialog, SIGNAL(textValueSelected(QString)),
- this, SLOT(src_editor_save_to(QString)));
+ this, SLOT(src_editor_save_to(QString)), Qt::QueuedConnection);
dialog->open();
#endif
}
@@ -768,6 +773,7 @@ void MainWindow::save_source() {
#else
QHtml5File::save(current_srceditor->document()->toPlainText().toUtf8(),
current_srceditor->filename());
+ current_srceditor->setModified(false);
#endif
}
@@ -782,18 +788,13 @@ void MainWindow::close_source_check() {
QMessageBox *msgbox = new QMessageBox(this);
msgbox->setWindowTitle("Close unsaved source");
msgbox->setText("Close unsaved source.");
-#ifndef __EMSCRIPTEN__
msgbox->setInformativeText("Do you want to save your changes?");
msgbox->setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
-#else
- msgbox->setInformativeText("Discard your changes or cancel close?");
- msgbox->setStandardButtons(QMessageBox::Discard | QMessageBox::Cancel);
-#endif
msgbox->setDefaultButton(QMessageBox::Save);
msgbox->setMinimumSize(QSize(200, 150));
msgbox->setAttribute(Qt::WA_DeleteOnClose);
connect(msgbox, SIGNAL(finished(int)),
- this, SLOT(close_source_decided(int)));
+ this, SLOT(close_source_decided(int)), Qt::QueuedConnection);
msgbox->open();
}
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index 51e154b..13c8295 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -119,7 +119,7 @@ public slots:
void tab_widget_destroyed(QObject *obj);
void view_mnemonics_registers(bool enable);
void message_selected(messagetype::Type type, QString file, int line, int column, QString text, QString hint);
- void save_exit_or_ignore(bool cancel, QStringList &tosavelist);
+ void save_exit_or_ignore(bool cancel, QStringList tosavelist);
protected:
void closeEvent(QCloseEvent *event);
diff --git a/qtmips_gui/savechangeddialog.h b/qtmips_gui/savechangeddialog.h
index 34eb5cd..11af95f 100644
--- a/qtmips_gui/savechangeddialog.h
+++ b/qtmips_gui/savechangeddialog.h
@@ -49,7 +49,7 @@ public:
explicit SaveChnagedDialog(QStringList &changedlist, QWidget *parent= nullptr);
~SaveChnagedDialog();
signals:
- void user_decision(bool cancel, QStringList &tosavelist);
+ void user_decision(bool cancel, QStringList tosavelist);
private slots:
void cancel_clicked();
void ignore_clicked();
diff --git a/qtmips_gui/srceditor.cpp b/qtmips_gui/srceditor.cpp
index 298b9f2..2d4a5ec 100644
--- a/qtmips_gui/srceditor.cpp
+++ b/qtmips_gui/srceditor.cpp
@@ -132,6 +132,10 @@ bool SrcEditor::isModified() const {
return document()->isModified();
}
+void SrcEditor::setModified(bool val) {
+ document()->setModified(val);
+}
+
void SrcEditor::setSaveAsRequired(bool val) {
saveAsRequiredFl = val;
}
diff --git a/qtmips_gui/srceditor.h b/qtmips_gui/srceditor.h
index 328bfb1..f2426cb 100644
--- a/qtmips_gui/srceditor.h
+++ b/qtmips_gui/srceditor.h
@@ -56,6 +56,7 @@ public:
void setCursorToLine(int ln);
void setFileName(QString filename);
bool isModified() const;
+ void setModified(bool val);
void setSaveAsRequired(bool val);
bool saveAsRequired();
private: