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->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);
}
}

View File

@ -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:

View File

@ -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();
}
});

View File

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