Skip to content

Commit

Permalink
Merge 27c4eb9 into 8a52fe4
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Apr 3, 2019
2 parents 8a52fe4 + 27c4eb9 commit 61a8a91
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
Expand Up @@ -2426,10 +2426,8 @@ void SimulationExperimentViewSimulationWidget::sedmlExportCombineArchive(const Q

// Let the user know about any error that may have occurred

if (!errorMessage.isEmpty()) {
Core::warningMessageBox(tr("Export To COMBINE Archive"),
errorMessage);
}
if (!errorMessage.isEmpty())
Core::warningMessageBox(tr("Export To COMBINE Archive"), errorMessage);

// Reinitialise our trackers, if we are neither dealing with a CellML
// file nor a SED-ML file
Expand Down
38 changes: 20 additions & 18 deletions src/plugins/support/SEDMLSupport/src/sedmlfile.cpp
Expand Up @@ -145,25 +145,33 @@ libsedml::SedDocument * SedmlFile::sedmlDocument()

//==============================================================================

bool SedmlFile::hasErrors() const
{
// Return whether our current SED-ML document has errors, be they normal
// errors or fatal errors

return mSedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_ERROR)
|| mSedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_FATAL);
}

//==============================================================================

bool SedmlFile::load()
{
// Check whether the file is already loaded and without any (fatal) errors

if (!mLoadingNeeded) {
return !mSedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_ERROR)
&& !mSedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_FATAL);
}
if (!mLoadingNeeded)
return !hasErrors();

mLoadingNeeded = false;

// Create a new SED-ML document, if needed, or try to load our file
// Create a new L1V3 SED-ML document, if needed, or try to load our file

mSedmlDocument = mNew?
new libsedml::SedDocument():
new libsedml::SedDocument(1, 3):
libsedml::readSedML(mFileName.toUtf8().constData());

return !mSedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_ERROR)
&& !mSedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_FATAL);
return !hasErrors();
}

//==============================================================================
Expand All @@ -172,11 +180,8 @@ bool SedmlFile::save(const QString &pFileName)
{
// Make sure that we are properly loaded and have no (fatal) errors

if ( mLoadingNeeded
|| mSedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_ERROR)
|| mSedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_FATAL)) {
if (mLoadingNeeded || hasErrors())
return false;
}

// Save ourselves, after having reformatted ourselves, and stop considering
// ourselves as new anymore (in case we were), if the saving went fine
Expand Down Expand Up @@ -264,10 +269,8 @@ bool SedmlFile::isValid(const QString &pFileContents, SedmlFileIssues &pIssues)
file.close();
}

libsedml::SedErrorLog *errorLog = sedmlDocument->getErrorLog();

for (uint i = 0, iMax = errorLog->getNumErrors(); i < iMax; ++i) {
const libsedml::SedError *error = errorLog->getError(i);
for (uint i = 0, iMax = sedmlDocument->getNumErrors(); i < iMax; ++i) {
const libsedml::SedError *error = sedmlDocument->getError(i);
SedmlFileIssue::Type issueType = SedmlFileIssue::Unknown;

switch (error->getSeverity()) {
Expand Down Expand Up @@ -301,8 +304,7 @@ bool SedmlFile::isValid(const QString &pFileContents, SedmlFileIssues &pIssues)

// Only consider our SED-ML document valid if it has no (fatal) errors

bool res = !sedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_ERROR)
&& !sedmlDocument->getNumErrors(libsedml::LIBSEDML_SEV_FATAL);
bool res = !hasErrors();

if (!pFileContents.isEmpty())
delete sedmlDocument;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/support/SEDMLSupport/src/sedmlfile.h
Expand Up @@ -147,6 +147,8 @@ class SEDMLSUPPORT_EXPORT SedmlFile : public StandardSupport::StandardFile

void reset() override;

bool hasErrors() const;

bool validListPropertyValue(const libsbml::XMLNode &pPropertyNode,
const QString &pPropertyNodeValue,
const QString &pPropertyName,
Expand Down

0 comments on commit 61a8a91

Please sign in to comment.