From 9da4cbb329258070e540f9e1d497268e9debd047 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 18 Jul 2018 18:03:38 +0300 Subject: [PATCH] Resolved issue #864. Valentina crashes on Mac OS X after closing Variables Table dialog. --HG-- branch : develop --- .../valentina/dialogs/dialogincrements.cpp | 23 +++++++++++++++++++ src/app/valentina/dialogs/dialogincrements.h | 6 ++++- src/app/valentina/mainwindow.cpp | 16 ++++++------- src/app/valentina/mainwindow.ui | 2 +- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index 73c79ca12..1ecf9aaae 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -1320,6 +1320,8 @@ void DialogIncrements::closeEvent(QCloseEvent *event) ui->lineEditName->blockSignals(true); ui->plainTextEditDescription->blockSignals(true); + disconnect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); + emit UpdateProperties(); emit DialogClosed(QDialog::Accepted); event->accept(); @@ -1417,3 +1419,24 @@ DialogIncrements::~DialogIncrements() { delete ui; } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::RestoreAfterClose() +{ + // Because of bug on Mac OS with Qt 5.11 closing this dialog causes a crash. Instead of closing we will keep + // dialog in memory and reuse it again. This function redo some moves made after close. + + connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); + + ui->tabWidget->setCurrentIndex(0); + + if (ui->tableWidgetIncrement->rowCount() > 0) + { + ui->tableWidgetIncrement->selectRow(0); + } + + if (ui->tableWidgetPC->rowCount() > 0) + { + ui->tableWidgetPC->selectRow(0); + } +} diff --git a/src/app/valentina/dialogs/dialogincrements.h b/src/app/valentina/dialogs/dialogincrements.h index b96ac4407..ec3a549f4 100644 --- a/src/app/valentina/dialogs/dialogincrements.h +++ b/src/app/valentina/dialogs/dialogincrements.h @@ -52,9 +52,14 @@ public: DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent = nullptr); virtual ~DialogIncrements() override; + void RestoreAfterClose(); + signals: void UpdateProperties(); +public slots: + void FullUpdateFromFile(); + protected: virtual void closeEvent ( QCloseEvent * event ) override; virtual void changeEvent ( QEvent * event) override; @@ -72,7 +77,6 @@ private slots: void SaveIncrFormula(); void DeployFormula(); void Fx(); - void FullUpdateFromFile(); void RefreshPattern(); private: diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 8a62d6471..e3d5b861c 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -4246,24 +4246,22 @@ void MainWindow::CreateActions() connect(ui->actionExportIncrementsToCSV, &QAction::triggered, this, &MainWindow::ExportDataToCSV); connect(ui->actionExportFinalMeasurementsToCSV, &QAction::triggered, this, &MainWindow::ExportFMeasurementsToCSV); - connect(ui->actionTable, &QAction::triggered, this, [this](bool checked) + connect(ui->actionTable, &QAction::triggered, this, [this]() { - if (checked) + // Because of bug on Mac with Qt 5.11 closing this dialog causes a crash. Instead of closing we will keep + // dialog in memory. + if (dialogTable.isNull()) { dialogTable = new DialogIncrements(pattern, doc, this); connect(dialogTable.data(), &DialogIncrements::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); - connect(dialogTable.data(), &DialogIncrements::DialogClosed, this, [this]() - { - ui->actionTable->setChecked(false); - delete dialogTable; - }); dialogTable->show(); } else { - ui->actionTable->setChecked(true); - dialogTable->activateWindow(); + dialogTable->FullUpdateFromFile(); + dialogTable->RestoreAfterClose(); // Redo some moves after close + dialogTable->isVisible() ? dialogTable->activateWindow() : dialogTable->show(); } }); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index dc0db1d13..3ab5fefe9 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -2203,7 +2203,7 @@ - true + false false