Merge pull request #21706 from 3x380V/fix_start

Start: Fix crash
This commit is contained in:
Chris Hennes
2025-06-02 09:45:09 -05:00
committed by GitHub
2 changed files with 25 additions and 5 deletions

View File

@@ -66,6 +66,26 @@ using namespace App;
namespace
{
class ZipTools
{
public:
static std::unique_ptr<zipios::ZipFile> open(const std::string& file)
{
std::unique_ptr<zipios::ZipFile> project;
try {
project = std::make_unique<zipios::ZipFile>(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<std::istream> str(project.getInputStream("Document.xml"));
std::unique_ptr<std::istream> str(project->getInputStream("Document.xml"));
if (str) {
std::unique_ptr<XercesDOMParser> parser(new XercesDOMParser);
parser->setValidationScheme(XercesDOMParser::Val_Auto);

View File

@@ -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<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
if (auto view = dynamic_cast<Gui::View3DInventor*>(doc->getActiveView())) {
Gui::View3DInventorViewer* viewer = view->getViewer();
if (viewer->isEditing()) {
_openFirstStart->setEnabled(false);