lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [6279] Keep the system usable even without proprietary gra


From: Greg Chicares
Subject: [lmi-commits] [6279] Keep the system usable even without proprietary graphics files
Date: Wed, 16 Sep 2015 21:07:51 +0000

Revision: 6279
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6279
Author:   chicares
Date:     2015-09-16 21:07:51 +0000 (Wed, 16 Sep 2015)
Log Message:
-----------
Keep the system usable even without proprietary graphics files

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/group_quote_pdf_gen_wx.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2015-09-16 20:41:17 UTC (rev 6278)
+++ lmi/trunk/ChangeLog 2015-09-16 21:07:51 UTC (rev 6279)
@@ -36763,3 +36763,18 @@
 Fix defect introduced 20110802T1517Z: wrong data-renderer type. See:
   http://lists.nongnu.org/archive/html/lmi/2015-08/msg00064.html
 
+20150916T2040Z <address@hidden> [477]
+
+  icon_monger.cpp
+Add a diagnostic message.
+
+20150916T2041Z <address@hidden> [477]
+
+  group_quote_pdf_gen_wx.cpp
+Rename graphics files.
+
+20150916T2107Z <address@hidden> [477]
+
+  group_quote_pdf_gen_wx.cpp
+Keep the system usable even without proprietary graphics files.
+

Modified: lmi/trunk/group_quote_pdf_gen_wx.cpp
===================================================================
--- lmi/trunk/group_quote_pdf_gen_wx.cpp        2015-09-16 20:41:17 UTC (rev 
6278)
+++ lmi/trunk/group_quote_pdf_gen_wx.cpp        2015-09-16 21:07:51 UTC (rev 
6279)
@@ -31,14 +31,18 @@
 #include "alert.hpp"
 #include "assert_lmi.hpp"
 #include "calendar_date.hpp"            // jdn_t()
+#include "data_directory.hpp"           // AddDataDir()
 #include "force_linking.hpp"
 #include "ledger.hpp"
 #include "ledger_invariant.hpp"
 #include "ledger_text_formats.hpp"      // ledger_format()
 #include "oecumenic_enumerations.hpp"   // oenum_format_style
+#include "path_utility.hpp"             // fs::path inserter
 #include "wx_table_generator.hpp"
 #include "wx_utility.hpp"               // ConvertDateToWx()
 
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/static_assert.hpp>
 
@@ -85,19 +89,46 @@
     return z;
 }
 
-/// Load the image from the given file. Throw on failure.
+/// Load the image from the given file.
+///
+/// Look for the file in the current working directory, or, if that
+/// fails, in lmi's data directory. Warn if it's not found in either
+/// of those locations, or if it's found but cannot be loaded.
+///
+/// Diagnosed failures are presented merely as warnings so that quotes
+/// can be produced even with a generic system built from svn only,
+/// with no (proprietary) images.
 
 wxImage load_image(char const* file)
 {
-    wxImage image(file);
+    fs::path image_path(file);
+    if(!fs::exists(image_path))
+        {
+        image_path = AddDataDir(file);
+        }
+    if(!fs::exists(image_path))
+        {
+        warning()
+            << "Unable to find image '"
+            << image_path
+            << "'. Try reinstalling."
+            << "\nA blank image will be used instead."
+            << LMI_FLUSH
+            ;
+        return wxImage();
+        }
+
+    wxImage image(image_path.string().c_str(), wxBITMAP_TYPE_PNG);
     if(!image.IsOk())
         {
-        fatal_error()
-            << "File '"
-            << file
-            << "' is required but could not be found. Try reinstalling."
+        warning()
+            << "Unable to load image '"
+            << image_path
+            << "'. Try reinstalling."
+            << "\nA blank image will be used instead."
             << LMI_FLUSH
             ;
+        return wxImage();
         }
 
     return image;




reply via email to

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