diff --git a/src/App/ProjectFile.cpp b/src/App/ProjectFile.cpp index 601969e02f..cf56233bc5 100644 --- a/src/App/ProjectFile.cpp +++ b/src/App/ProjectFile.cpp @@ -66,6 +66,26 @@ using namespace App; namespace { + +class ZipTools +{ +public: + static std::unique_ptr open(const std::string& file) + { + std::unique_ptr project; + try { + project = std::make_unique(file); + if (!project->isValid()) { + project.reset(); + } + } + catch (const std::exception&) { + } + + return project; + } +}; + class DocumentMetadata { public: @@ -212,11 +232,12 @@ bool ProjectFile::loadDocument() return true; // already loaded } - zipios::ZipFile project(stdFile); - if (!project.isValid()) { + auto project = ZipTools::open(stdFile); + if (!project) { return false; } - std::unique_ptr str(project.getInputStream("Document.xml")); + + std::unique_ptr str(project->getInputStream("Document.xml")); if (str) { std::unique_ptr parser(new XercesDOMParser); parser->setValidationScheme(XercesDOMParser::Val_Auto); diff --git a/src/Mod/Start/Gui/StartView.cpp b/src/Mod/Start/Gui/StartView.cpp index 63ce17f892..8ef9dd78f3 100644 --- a/src/Mod/Start/Gui/StartView.cpp +++ b/src/Mod/Start/Gui/StartView.cpp @@ -417,8 +417,7 @@ void StartView::changeEvent(QEvent* event) _openFirstStart->setEnabled(true); Gui::Document* doc = Gui::Application::Instance->activeDocument(); if (doc) { - Gui::View3DInventor* view = static_cast(doc->getActiveView()); - if (view) { + if (auto view = dynamic_cast(doc->getActiveView())) { Gui::View3DInventorViewer* viewer = view->getViewer(); if (viewer->isEditing()) { _openFirstStart->setEnabled(false);