mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
fix "referencing nonexistant file" bug
improve internal error message
This commit is contained in:
@@ -103,11 +103,12 @@ public:
|
||||
/// Tell all listeners about an action
|
||||
void tellListeners(const Action&, bool undone);
|
||||
|
||||
private:
|
||||
/// Actions to be undone.
|
||||
vector<unique_ptr<Action>> undo_actions;
|
||||
/// Actions to be redone
|
||||
vector<unique_ptr<Action>> redo_actions;
|
||||
vector<unique_ptr<Action>> redo_actions;
|
||||
|
||||
private:
|
||||
/// Point at which the file was saved, corresponds to the top of the undo stack at that point
|
||||
const Action* save_point;
|
||||
/// Was the last thing the user did addAction? (as opposed to undo/redo)
|
||||
|
||||
+6
-4
@@ -110,10 +110,12 @@ String Error::what() const {
|
||||
|
||||
InternalError::InternalError(const String& str)
|
||||
: Error(
|
||||
_("An internal error occured:\n\n") +
|
||||
str + _("\n")
|
||||
_("Please save your work (use 'save as' to so you don't overwrite things)\n")
|
||||
_("and restart Magic Set Editor.\n\n")
|
||||
_("An internal error occurred:\n\n") +
|
||||
str + _("\n\n")
|
||||
_("Please save your work (use 'save as' so you don't overwrite things)\n")
|
||||
_("and restart Magic Set Editor.\n")
|
||||
_("You can also find a backup of your set in the same folder as your set file\n")
|
||||
_("called 'SETNAME.mse-set.bak'. Rename it to 'SETNAME-backup.mse-set' to open it.\n")
|
||||
_("You should leave a bug report on https://github.com/twanvl/MagicSetEditor2/issues/\n")
|
||||
_("Press Ctrl+C to copy this message to the clipboard.")
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <util/error.hpp>
|
||||
#include <script/to_value.hpp> // for reflection
|
||||
#include <script/profiler.hpp> // for PROFILER
|
||||
#include <data/set.hpp>
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/zipstrm.h>
|
||||
#include <wx/dir.h>
|
||||
@@ -19,7 +20,7 @@
|
||||
// ----------------------------------------------------------------------------- : Package : outside
|
||||
|
||||
IMPLEMENT_DYNAMIC_ARG(Package*, writing_package, nullptr);
|
||||
IMPLEMENT_DYNAMIC_ARG(Package*, clipboard_package, nullptr);
|
||||
IMPLEMENT_DYNAMIC_ARG(Package*, clipboard_package, nullptr);
|
||||
|
||||
Package::Package()
|
||||
: zipStream (nullptr)
|
||||
@@ -97,7 +98,8 @@ void Package::save(bool remove_unused) {
|
||||
saveAs(filename, remove_unused);
|
||||
}
|
||||
|
||||
void Package::saveAs(const String& name, bool remove_unused, bool as_directory) {
|
||||
void Package::saveAs(const String& name, bool remove_unused, bool as_directory) {
|
||||
if (Set* s = dynamic_cast<Set*>(this)) s->referenceActionStackFiles();
|
||||
// type of package
|
||||
if (wxDirExists(name) || as_directory) {
|
||||
saveToDirectory(name, remove_unused, false);
|
||||
@@ -109,7 +111,8 @@ void Package::saveAs(const String& name, bool remove_unused, bool as_directory)
|
||||
reopen();
|
||||
}
|
||||
|
||||
void Package::saveCopy(const String& name) {
|
||||
void Package::saveCopy(const String& name) {
|
||||
if (Set* s = dynamic_cast<Set*>(this)) s->referenceActionStackFiles();
|
||||
saveToZipfile(name, true, true);
|
||||
clearKeepFlag();
|
||||
}
|
||||
@@ -298,7 +301,7 @@ LocalFileName Package::newFileName(const String& prefix, const String& suffix) {
|
||||
void Package::referenceFile(const String& file) {
|
||||
if (file.empty()) return;
|
||||
FileInfos::iterator it = files.find(file);
|
||||
if (it == files.end()) throw InternalError(_("referencing a nonexistant file"));
|
||||
if (it == files.end()) throw InternalError(_("Referencing an inexistant file!"));
|
||||
it->second.keep = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user