Resolved issue #976. The pattern does not open.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-08-20 15:23:31 +03:00
parent 4355d18fb3
commit 030c513784
3 changed files with 37 additions and 12 deletions

View file

@ -4745,23 +4745,41 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
m_curFileFormatVersion = converter->GetCurrentFormatVersion();
m_curFileFormatVersionStr = converter->GetFormatVersionStr();
doc->setXMLContent(converter->Convert());
if (!customMeasureFile.isEmpty())
{
doc->SetMPath(RelativeMPath(fileName, customMeasureFile));
}
qApp->setPatternUnit(doc->MUnit());
}
else
if (!customMeasureFile.isEmpty())
{
if (!customMeasureFile.isEmpty())
{
doc->SetMPath(RelativeMPath(fileName, customMeasureFile));
}
qApp->setPatternUnit(doc->MUnit());
doc->SetMPath(RelativeMPath(fileName, customMeasureFile));
}
const QString path = AbsoluteMPath(fileName, doc->MPath());
qApp->setPatternUnit(doc->MUnit());
QString path = AbsoluteMPath(fileName, doc->MPath());
QString fixedMPath;
// See issue #976. Pattern can lost link to measurements
if (path.isEmpty() && doc->RequiresMeasurements())
{
const QString fakeName = QStringLiteral("unknown_measurements.vit");
// Check if exist
fixedMPath = CheckPathToMeasurements(fileName, fakeName);
if (fixedMPath.isEmpty())
{
qApp->setOpeningPattern();// End opening file
Clear();
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.")
.arg(fakeName)));
if (not VApplication::IsGUIMode())
{
qApp->exit(V_EX_NOINPUT);
}
return false;
}
else
{
path = AbsoluteMPath(fileName, doc->MPath());
}
}
if (not path.isEmpty())
{
// Check if exist

View file

@ -298,6 +298,12 @@ VAbstractPattern::~VAbstractPattern()
toolsOnRemove.clear();
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::RequiresMeasurements() const
{
return not ListMeasurements().isEmpty();
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListMeasurements() const
{

View file

@ -86,6 +86,7 @@ public:
explicit VAbstractPattern(QObject *parent = nullptr);
virtual ~VAbstractPattern();
bool RequiresMeasurements() const;
QStringList ListMeasurements() const;
QVector<VFormulaField> ListExpressions() const;
QVector<VFormulaField> ListIncrementExpressions() const;