Resolved issue #864. Valentina crashes on Mac OS X after closing Variables

Table dialog.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-07-18 18:03:38 +03:00
parent 9fefa8d1b8
commit 9da4cbb329
4 changed files with 36 additions and 11 deletions

View File

@ -1320,6 +1320,8 @@ void DialogIncrements::closeEvent(QCloseEvent *event)
ui->lineEditName->blockSignals(true); ui->lineEditName->blockSignals(true);
ui->plainTextEditDescription->blockSignals(true); ui->plainTextEditDescription->blockSignals(true);
disconnect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
emit UpdateProperties(); emit UpdateProperties();
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
event->accept(); event->accept();
@ -1417,3 +1419,24 @@ DialogIncrements::~DialogIncrements()
{ {
delete ui; 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);
}
}

View File

@ -52,9 +52,14 @@ public:
DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent = nullptr); DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent = nullptr);
virtual ~DialogIncrements() override; virtual ~DialogIncrements() override;
void RestoreAfterClose();
signals: signals:
void UpdateProperties(); void UpdateProperties();
public slots:
void FullUpdateFromFile();
protected: protected:
virtual void closeEvent ( QCloseEvent * event ) override; virtual void closeEvent ( QCloseEvent * event ) override;
virtual void changeEvent ( QEvent * event) override; virtual void changeEvent ( QEvent * event) override;
@ -72,7 +77,6 @@ private slots:
void SaveIncrFormula(); void SaveIncrFormula();
void DeployFormula(); void DeployFormula();
void Fx(); void Fx();
void FullUpdateFromFile();
void RefreshPattern(); void RefreshPattern();
private: private:

View File

@ -4246,24 +4246,22 @@ void MainWindow::CreateActions()
connect(ui->actionExportIncrementsToCSV, &QAction::triggered, this, &MainWindow::ExportDataToCSV); connect(ui->actionExportIncrementsToCSV, &QAction::triggered, this, &MainWindow::ExportDataToCSV);
connect(ui->actionExportFinalMeasurementsToCSV, &QAction::triggered, this, &MainWindow::ExportFMeasurementsToCSV); 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); dialogTable = new DialogIncrements(pattern, doc, this);
connect(dialogTable.data(), &DialogIncrements::UpdateProperties, toolOptions, connect(dialogTable.data(), &DialogIncrements::UpdateProperties, toolOptions,
&VToolOptionsPropertyBrowser::RefreshOptions); &VToolOptionsPropertyBrowser::RefreshOptions);
connect(dialogTable.data(), &DialogIncrements::DialogClosed, this, [this]()
{
ui->actionTable->setChecked(false);
delete dialogTable;
});
dialogTable->show(); dialogTable->show();
} }
else else
{ {
ui->actionTable->setChecked(true); dialogTable->FullUpdateFromFile();
dialogTable->activateWindow(); dialogTable->RestoreAfterClose(); // Redo some moves after close
dialogTable->isVisible() ? dialogTable->activateWindow() : dialogTable->show();
} }
}); });

View File

@ -2203,7 +2203,7 @@
</action> </action>
<action name="actionTable"> <action name="actionTable">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>