Skip to content

Commit

Permalink
Mapping check file type
Browse files Browse the repository at this point in the history
Added a type of file check to assure no crash when the file isn't readable
  • Loading branch information
LafCorentin committed Jul 22, 2020
1 parent cb9fd78 commit 221aaf0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 181 deletions.
12 changes: 12 additions & 0 deletions src/plugins/editing/MappingView/src/mappingviewplugin.cpp
Expand Up @@ -24,6 +24,7 @@ along with this program. If not, see <https://gnu.org/licenses>.
#include "coreguiutils.h"
#include "mappingviewplugin.h"
#include "mappingviewwidget.h"
#include "filemanager.h"

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

Expand Down Expand Up @@ -294,6 +295,17 @@ QWidget * MappingViewPlugin::viewWidget(const QString &pFileName)
{
// Update and return our Mapping view widget using the given file

// Make sure that we are not dealing with a new file, but a CellML 1.0/1.1
// file

CellMLSupport::CellmlFile::Version cellmlVersion = CellMLSupport::CellmlFile::fileVersion(pFileName);

if ( Core::FileManager::instance()->isNew(pFileName)
|| ( (cellmlVersion != CellMLSupport::CellmlFile::Version::Cellml_1_0)
&& (cellmlVersion != CellMLSupport::CellmlFile::Version::Cellml_1_1))) {
return nullptr;
}

mFileName = pFileName;

mViewWidget->update(pFileName);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/editing/MappingView/src/mappingviewwidget.cpp
Expand Up @@ -119,7 +119,7 @@ void MappingViewWidget::update(const QString &pFileName)
// Retrieve the requested CellML file

mCellmlFile = CellMLSupport::CellmlFileManager::instance()->cellmlFile(pFileName);

//TODO can be null
populateCellmlModel();
}

Expand Down
180 changes: 0 additions & 180 deletions src/plugins/editing/MappingView/src/mappingviewwidget.cpp.autosave

This file was deleted.

0 comments on commit 221aaf0

Please sign in to comment.