lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 0c2d6b4 30/33: Revert "Revert "Trap exception


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 0c2d6b4 30/33: Revert "Revert "Trap exceptions from filesystem library""
Date: Mon, 3 May 2021 08:15:56 -0400 (EDT)

branch: master
commit 0c2d6b415b881858794a2a9713eac962f8f54a45
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Revert "Revert "Trap exceptions from filesystem library""
    
    This reverts commit dab074e388422f328933752ae6965560e2c9a62e.
    
    Apparently that commit was intended as a simplification only: it removed
    complicated code that couldn't actually have any effect. Normally, that
    would be accepted without question. Furthermore, the code it removed
    made configurable_settings fragile, as discussed in this thread:
      https://lists.nongnu.org/archive/html/lmi/2020-10/msg00037.html
    and, normally, that would cause it to be embraced with enthusiasm.
    
    However, given '/opt/lmi/data/configurable_settings.xml' contents:
      <default_input_filename>Z:/etc/opt/lmi/default.ill</default_input_...
      <print_directory>Z:/opt/lmi/print</print_directory>
    lmi-gtk's GUI now shows
      Input defaults: /opt/lmi/bin/Z:/etc/opt/lmi/default.ill
      Printout directory: /opt/lmi/print
    where one textcontrol is as intended but the other is not. It is not
    clear whether the reverted commit has anything to do with that, but
    it seems wise to back it out temporarily pending investigation of this
    anomaly. The present commit can be reverted (enthusiastically) later.
---
 configurable_settings.cpp | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/configurable_settings.cpp b/configurable_settings.cpp
index df5e574..2eb49ee 100644
--- a/configurable_settings.cpp
+++ b/configurable_settings.cpp
@@ -143,12 +143,26 @@ configurable_settings::configurable_settings()
     ascribe_members();
     load();
 
-    default_input_filename_ = fs::absolute(default_input_filename_  ).string();
-    print_directory_        = remove_alien_msw_root(print_directory_).string();
-    print_directory_        = fs::absolute(print_directory_         ).string();
+    try
+        {
+        default_input_filename_ = 
fs::absolute(default_input_filename_).string();
+// Performing this test seems like a good idea, but it would flag
+// an empty path as an error.
+//      validate_filepath(default_input_filename_, "Default input file");
+        }
+    catch(...)
+        {
+        report_exception();
+        // Silently replace invalid path with an empty string,
+        // which will produce an informative diagnostic when
+        // a default is needed.
+        default_input_filename_ = {};
+        }
 
     try
         {
+        print_directory_ = remove_alien_msw_root(print_directory_).string();
+        print_directory_ = fs::absolute(print_directory_).string();
         validate_directory(print_directory_, "Print directory");
         }
     catch(...)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]