[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] (no subject)
From: |
Greg Chicares |
Subject: |
[lmi-commits] (no subject) |
Date: |
Wed, 15 Jun 2016 23:33:07 +0000 (UTC) |
branch: master
commit 553d619341074333f6550376e33b4d3f69a4eac0
Author: Gregory W. Chicares <address@hidden>
Date: Wed Jun 15 23:10:04 2016 +0000
Improve error messages for invalid default-input file
Customization of input parameters is optional: it is all right to
specify the default-input file as an empty string or an invalid path,
causing lmi to fall back silently on built-in defaults. However,
attempting to edit a nonexistent file with "File | Default..."
elicited wx error messages such as
(using empty path with wxDOC_SILENT doesn't make sense)
which might be unclear to end users, so now lmi issues its own
diagnostic instead.
---
skeleton.cpp | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/skeleton.cpp b/skeleton.cpp
index 80b40d9..145b43a 100644
--- a/skeleton.cpp
+++ b/skeleton.cpp
@@ -65,6 +65,7 @@
#include "miscellany.hpp"
#include "msw_workarounds.hpp" // PreloadDesignatedDlls()
#include "mvc_controller.hpp"
+#include "path_utility.hpp" // fs::path inserter
#include "policy_document.hpp"
#include "policy_view.hpp"
#include "preferences_model.hpp"
@@ -486,10 +487,22 @@ void Skeleton::UponDropFiles(wxDropFilesEvent& event)
void Skeleton::UponEditDefaultCell(wxCommandEvent&)
{
- doc_manager_->CreateDocument
- (configurable_settings::instance().default_input_filename()
- ,wxDOC_SILENT
- );
+ configurable_settings& z = configurable_settings::instance();
+ fs::path const p(z.default_input_filename());
+
+ if(p.empty() || !fs::exists(p) || fs::is_directory(p))
+ {
+ fatal_error()
+ << "The default input file, '"
+ << p
+ << "', could not be read.\n\n"
+ << "Use the \"Preferences\" dialog to select any saved"
+ << " illustration-input file as the default."
+ << LMI_FLUSH
+ ;
+ }
+
+ doc_manager_->CreateDocument(p.string(), wxDOC_SILENT);
}
/// Display user manual in default browser.