Skip to content

Commit b7b014c

Browse files
App/Gui: New restoreError Document status and Gui pop-up
======================================================== If the restore of Document.xml results in invalid Document.xml (because unhandled exceptions occurred), the document status Document::restoreError is set. The GUI or Mod/Web if a link was clicked, show a pop-up indicating this situation. This commit also shows an appropriate pop-up for the partialRestore when opening from the menu, that before only appeared when opening by clicking a link.
1 parent 5e51288 commit b7b014c

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

src/App/Document.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,7 @@ void Document::restore (void)
18611861
}
18621862
catch (const Base::Exception& e) {
18631863
Base::Console().Error("Invalid Document.xml: %s\n", e.what());
1864+
setStatus(Document::RestoreError, true);
18641865
}
18651866

18661867
// Special handling for Gui document, the view representations must already

src/App/Document.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class AppExport Document : public App::PropertyContainer
6969
Closable = 2,
7070
Restoring = 3,
7171
Recomputing = 4,
72-
PartialRestore = 5
72+
PartialRestore = 5,
73+
RestoreError = 10
7374
};
7475

7576
/** @name Properties */

src/Gui/CommandDoc.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ void StdCmdOpen::activated(int iMsg)
151151
else {
152152
for (SelectModule::Dict::iterator it = dict.begin(); it != dict.end(); ++it) {
153153
getGuiApplication()->open(it.key().toUtf8(), it.value().toLatin1());
154+
155+
App::Document *doc = App::GetApplication().getActiveDocument();
156+
157+
if(doc && doc->testStatus(App::Document::PartialRestore))
158+
QMessageBox::critical(getMainWindow(), QObject::tr("Error"), QObject::tr("There were errors while loading the file. Some data might have been modified or not recovered at all. Look in the report view for more specific information about the objects involved."));
159+
160+
if(doc && doc->testStatus(App::Document::RestoreError))
161+
QMessageBox::critical(getMainWindow(), QObject::tr("Error"), QObject::tr("There were serious errors while loading the file. Some data might have been modified or not recovered at all. Saving the project will most likely result in loss of data."));
154162
}
155163
}
156164
}

src/Mod/Web/Gui/BrowserView.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ void BrowserView::onLinkClicked (const QUrl & url)
341341
App::Document *doc = BaseView::getAppDocument();
342342
if(doc && doc->testStatus(App::Document::PartialRestore))
343343
QMessageBox::critical(this, tr("Error"), tr("There were errors while loading the file. Some data might have been modified or not recovered at all. Look in the report view for more specific information about the objects involved."));
344+
345+
if(doc && doc->testStatus(App::Document::RestoreError))
346+
QMessageBox::critical(this, tr("Error"), tr("There were serious errors while loading the file. Some data might have been modified or not recovered at all. Saving the project will most likely result in loss of data."));
344347
}
345348
}
346349
else {

0 commit comments

Comments
 (0)