Fix crash while synchronize measurements.

(cherry picked from commit 1b5705388c)
This commit is contained in:
Roman Telezhynskyi 2020-10-30 12:52:39 +02:00
parent 42afd0e2f6
commit ec17a82cdc
3 changed files with 21 additions and 11 deletions

View File

@ -3,6 +3,7 @@
- Fix issue in VAbstractCurve::CurveIntersectAxis.
- Improve editing a spline path through control points for locked angles.
- [smart-pattern/valentina#73] Notes for tools.
- Fix crash while synchronize measurements.
# Version 0.7.36 October 24, 2020
- [#892] Show tooltip for piece node point.
@ -101,6 +102,7 @@
- Elide a variable description in the formula wizard.
- Fix removing a pin in the Seam Allowance tool dialog.
- Fix label size for case with two pins.
- Fix crash while synchronize measurements.
# Version 0.6.1 October 23, 2018
- [#885] Regression. Broken support for multi size measurements.

View File

@ -200,7 +200,11 @@ MainWindow::MainWindow(QWidget *parent)
comboBoxDraws(nullptr), patternPieceLabel(nullptr),
currentDrawIndex(0), currentToolBoxIndex(0),
drawMode(true),
leftGoToStage(nullptr), rightGoToStage(nullptr), autoSaveTimer(nullptr), guiEnabled(true),
leftGoToStage(nullptr),
rightGoToStage(nullptr),
autoSaveTimer(nullptr),
measurementsSyncTimer(new QTimer(this)),
guiEnabled(true),
toolOptions(nullptr),
groupsWidget(nullptr),
detailsWidget(nullptr),
@ -265,16 +269,20 @@ MainWindow::MainWindow(QWidget *parent)
ui->dockWidgetLayoutPages->setVisible(false);
connect(watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged);
connect(qApp, &QApplication::focusChanged, this, [this](QWidget *old, QWidget *now)
measurementsSyncTimer->setTimerType(Qt::VeryCoarseTimer);
connect(measurementsSyncTimer, &QTimer::timeout, this, [this]()
{
if (isActiveWindow())
{
if (old == nullptr && isAncestorOf(now) == true)
{// focus IN
static bool asking = false;
if (not asking && mChanges && not mChangesAsked)
{
asking = true;
mChangesAsked = true;
const auto answer = QMessageBox::question(this, tr("Measurements"),
measurementsSyncTimer->stop();
const auto answer =
QMessageBox::question(this, tr("Measurements"),
tr("Measurements were changed. Do you want to sync measurements now?"),
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::Yes)
@ -284,10 +292,6 @@ MainWindow::MainWindow(QWidget *parent)
asking = false;
}
}
// In case we will need it
// else if (isAncestorOf(old) == true && now == nullptr)
// focus OUT
});
#if defined(Q_OS_MAC)
@ -1968,6 +1972,7 @@ void MainWindow::MeasurementsChanged(const QString &path)
{
mChanges = true;
mChangesAsked = false;
measurementsSyncTimer->start(1500);
}
else
{
@ -1977,6 +1982,7 @@ void MainWindow::MeasurementsChanged(const QString &path)
{
mChanges = true;
mChangesAsked = false;
measurementsSyncTimer->start(1500);
break;
}
else
@ -2009,6 +2015,7 @@ void MainWindow::SyncMeasurements()
doc->LiteParseTree(Document::FullLiteParse);
mChanges = false;
mChangesAsked = true;
measurementsSyncTimer->stop();
UpdateWindowTitle();
ui->actionSyncMeasurements->setEnabled(mChanges);
}

View File

@ -271,6 +271,7 @@ private:
QLabel *leftGoToStage;
QLabel *rightGoToStage;
QTimer *autoSaveTimer;
QTimer *measurementsSyncTimer;
bool guiEnabled;
QPointer<QComboBox> dimensionA{nullptr};
QPointer<QComboBox> dimensionB{nullptr};