Perform test for unique id after parsing.
In most cases this is very rare issue. Many checs will cover this case anyway. Instead of wait we will perform check when calculation done. --HG-- branch : develop
This commit is contained in:
parent
f44484a364
commit
bac4e0872b
|
@ -88,6 +88,8 @@
|
|||
#include <QDoubleSpinBox>
|
||||
#include <QProgressBar>
|
||||
#include <QGlobalStatic>
|
||||
#include <QFuture>
|
||||
#include <QtConcurrent>
|
||||
|
||||
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
||||
#include <QWinTaskbarButton>
|
||||
|
@ -3003,51 +3005,45 @@ void MainWindow::FullParseFile()
|
|||
qCDebug(vMainWindow, "Full parsing file");
|
||||
|
||||
toolOptions->ClearPropertyBrowser();
|
||||
QFuture<void> futureTestUniqueId;
|
||||
|
||||
auto WaitForFutureFinish = [](QFuture<void> &futureTestUniqueId)
|
||||
{
|
||||
try
|
||||
{
|
||||
futureTestUniqueId.waitForFinished();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
futureTestUniqueId = QtConcurrent::run(static_cast<VDomDocument *>(doc), &VDomDocument::TestUniqueId);
|
||||
}
|
||||
|
||||
SetEnabledGUI(true);
|
||||
doc->Parse(Document::FullParse);
|
||||
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
futureTestUniqueId.waitForFinished();
|
||||
}
|
||||
}
|
||||
catch (const VExceptionUndo &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
/* If user want undo last operation before undo we need finish broken redo operation. For those we post event
|
||||
* myself. Later in method customEvent call undo.*/
|
||||
QApplication::postEvent(this, new UndoEvent());
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionObjectError &e)
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
SetEnabledGUI(false);
|
||||
if (not VApplication::IsGUIMode())
|
||||
try
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionConversionError &e)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
SetEnabledGUI(false);
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionEmptyParameter &e)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
SetEnabledGUI(false);
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
}
|
||||
return;
|
||||
futureTestUniqueId.waitForFinished();
|
||||
}
|
||||
catch (const VExceptionWrongId &e)
|
||||
{
|
||||
|
@ -3060,11 +3056,79 @@ void MainWindow::FullParseFile()
|
|||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
QApplication::postEvent(this, new UndoEvent());
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionObjectError &e)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
SetEnabledGUI(false);
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
WaitForFutureFinish(futureTestUniqueId);
|
||||
}
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionConversionError &e)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
SetEnabledGUI(false);
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
WaitForFutureFinish(futureTestUniqueId);
|
||||
}
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionEmptyParameter &e)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
SetEnabledGUI(false);
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
WaitForFutureFinish(futureTestUniqueId);
|
||||
}
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionWrongId &e)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
SetEnabledGUI(false);
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
WaitForFutureFinish(futureTestUniqueId);
|
||||
}
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
SetEnabledGUI(false);
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
WaitForFutureFinish(futureTestUniqueId);
|
||||
}
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
|
@ -3075,6 +3139,10 @@ void MainWindow::FullParseFile()
|
|||
{
|
||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
|
||||
SetEnabledGUI(false);
|
||||
if (qApp->getOpeningPattern())
|
||||
{
|
||||
WaitForFutureFinish(futureTestUniqueId);
|
||||
}
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_DATAERR);
|
||||
|
@ -4566,9 +4634,6 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
|
|||
#endif
|
||||
|
||||
FullParseFile();
|
||||
/* Collect garbage only after successfully parse. This way wrongly accused items have one more time to restore
|
||||
* a reference. */
|
||||
doc->GarbageCollector(true);
|
||||
|
||||
m_progressBar->setVisible(false);
|
||||
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
||||
|
@ -4578,6 +4643,10 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
|
|||
|
||||
if (guiEnabled)
|
||||
{ // No errors occurred
|
||||
/* Collect garbage only after successfully parse. This way wrongly accused items have one more time to restore
|
||||
* a reference. */
|
||||
doc->GarbageCollector(true);
|
||||
|
||||
patternReadOnly = doc->IsReadOnly();
|
||||
SetEnableWidgets(true);
|
||||
setCurrentFile(fileName);
|
||||
|
|
|
@ -4239,7 +4239,6 @@ void VPattern::PrepareForParse(const Document &parse)
|
|||
SCASSERT(sceneDetail != nullptr)
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
TestUniqueId();
|
||||
RefreshElementIdCache();
|
||||
sceneDraw->clear();
|
||||
sceneDraw->InitOrigins();
|
||||
|
|
|
@ -134,12 +134,12 @@ public:
|
|||
QVector<VLabelTemplateLine> GetLabelTemplate(const QDomElement &element) const;
|
||||
void SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines);
|
||||
|
||||
void TestUniqueId() const;
|
||||
|
||||
protected:
|
||||
bool setTagText(const QString &tag, const QString &text);
|
||||
bool setTagText(const QDomElement &domElement, const QString &text);
|
||||
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
|
||||
|
||||
void TestUniqueId() const;
|
||||
void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
|
||||
|
||||
protected slots:
|
||||
|
|
Loading…
Reference in New Issue
Block a user