Some work towards handling a CellML API crash when when trying to generate code for a malformed CellML file (#340) [ci skip].

This seems to be working fine on Windows and OS X. On Linux, if we try
to switch to the Simulation view for the first time (for the CellML
file mentioned in the issue), then it’s OK, but then if we switch to
another view and then come back, then OpenCOR crashes!?