gnucash maint: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Mon Mar 8 04:56:31 EST 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/a9dcf0d8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/43c2b7e9 (commit)
	from  https://github.com/Gnucash/gnucash/commit/3739d912 (commit)



commit a9dcf0d81dfda4f417bf4d39477d6b7e3a2b873c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed Feb 24 14:52:46 2021 +0000

    Last modified file text missing for files like Comité.gnucash on Windows
    
    This is down to the use of stat so changed to use GFile to get the last
    modified date.

diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index a792e02bc..a9f58e885 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -1737,40 +1737,41 @@ static gchar *generate_statusbar_lastmodified_message()
     {
         if (gnc_uri_targets_local_fs (uri))
         {
-#ifdef HAVE_SYS_STAT_H
             /* The filename is a true file. */
             gchar *filepath = gnc_uri_get_path ( uri );
             gchar *filename = g_path_get_basename ( filepath );
+            GFile *file = g_file_new_for_uri (uri);
+            GFileInfo *info = g_file_query_info (file,
+                                                 G_FILE_ATTRIBUTE_TIME_MODIFIED,
+                                                 G_FILE_QUERY_INFO_NONE,
+                                                 NULL, NULL);
+
+            if (info && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
             {
-                // Access the mtime information through stat(2)
-                struct stat statbuf;
-                int r = stat(filepath, &statbuf);
-                if (r == 0)
-                {
-                    /* Translators: This is the date and time that is shown in
-                    the status bar after opening a file: The date and time of
-                    last modification. The string is a format string using
-                    boost::date_time's format flags, see the boost docs for an
-                    explanation of the modifiers. */
-                    char *time_string = gnc_print_time64(statbuf.st_mtime,
-                     _("Last modified on %a, %b %d, %Y at %I:%M %p"));
-                    //g_warning("got time %ld, str=%s\n", mtime, time_string);
-                    /* Translators: This message appears in the status bar after opening the file. */
-                    message = g_strdup_printf(_("File %s opened. %s"),
-                                              filename, time_string);
-                    free(time_string);
-                }
-                else
-                {
-                    g_warning("Unable to read mtime for file %s\n", filepath);
-                    // message is still NULL
-                }
+                guint64 modtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+
+                /* Translators: This is the date and time that is shown in
+                the status bar after opening a file: The date and time of
+                last modification. The string is a format string using
+                boost::date_time's format flags, see the boost docs for an
+                explanation of the modifiers. */
+                char *time_string = gnc_print_time64 (modtime,
+                 _("Last modified on %a, %b %d, %Y at %I:%M %p"));
+                //g_warning("got time %ld, str=%s\n", mtime, time_string);
+                /* Translators: This message appears in the status bar after opening the file. */
+                message = g_strdup_printf(_("File %s opened. %s"),
+                                          filename, time_string);
+                free(time_string);
+            }
+            else
+            {
+                g_warning("Unable to read mtime for file %s\n", filepath);
+                // message is still NULL
             }
             g_free(filename);
             g_free(filepath);
-#else
-            return NULL;
-#endif
+            g_object_unref (info);
+            g_object_unref (file);
         }
         // If the URI is not a file but a database, we can maybe also show
         // something useful, but I have no idea how to obtain this information.

commit 43c2b7e9d7c0bda58cf57bc560e2e921837eccc8
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Feb 6 12:51:00 2021 +0000

    Bug 797997 - Gnucash File can not be found on Windows from command line.
    
    If the path to the Gnucash file is like C:\Temp\Comité\myfile.gnucash on
    a Windows PC, the file will not be found. This also applies to the log
    file when --logto C:\Temp\Comité\mylog.txt

diff --git a/gnucash/gnucash-cli.cpp b/gnucash/gnucash-cli.cpp
index 20f78ff8a..a679b5af6 100644
--- a/gnucash/gnucash-cli.cpp
+++ b/gnucash/gnucash-cli.cpp
@@ -38,6 +38,9 @@ extern "C" {
 
 #include <boost/locale.hpp>
 #include <boost/optional.hpp>
+#ifdef __MINGW32__
+#include <boost/nowide/args.hpp>
+#endif
 #include <iostream>
 
 namespace bl = boost::locale;
@@ -195,7 +198,9 @@ int
 main(int argc, char **argv)
 {
     Gnucash::GnucashCli application (argv[0]);
-
+#ifdef __MINGW32__
+    boost::nowide::args a(argc, argv); // Fix arguments - make them UTF-8
+#endif
     application.parse_command_line (argc, argv);
     application.start (argc, argv);
 
diff --git a/gnucash/gnucash-core-app.cpp b/gnucash/gnucash-core-app.cpp
index 4559ddf46..08aecad1f 100644
--- a/gnucash/gnucash-core-app.cpp
+++ b/gnucash/gnucash-core-app.cpp
@@ -345,24 +345,14 @@ load_user_config(void)
     try_load_config_array(stylesheet_files);
 }
 
-
 static void
 gnc_log_init (const std::vector <std::string> log_flags,
               const boost::optional <std::string> &log_to_filename)
 {
     if (log_to_filename && !log_to_filename->empty())
     {
-#ifdef __MINGW64__
-        auto *utf8_filename = g_utf16_to_utf8 (log_to_filename->c_str(), -1, NULL, NULL, NULL);
-#else
         auto utf8_filename = log_to_filename->c_str();
-#endif
-
         qof_log_init_filename_special (utf8_filename);
-
-#ifdef __MINGW64__
-        g_free (utf8_filename);
-#endif
     }
     else
     {
diff --git a/gnucash/gnucash.cpp b/gnucash/gnucash.cpp
index b51684099..d7b00ff87 100644
--- a/gnucash/gnucash.cpp
+++ b/gnucash/gnucash.cpp
@@ -61,6 +61,9 @@ extern "C" {
 
 #include <boost/locale.hpp>
 #include <boost/optional.hpp>
+#ifdef __MINGW32__
+#include <boost/nowide/args.hpp>
+#endif
 #include <iostream>
 #include <gnc-locale-utils.hpp>
 
@@ -387,7 +390,9 @@ int
 main(int argc, char ** argv)
 {
     Gnucash::Gnucash application (argv[0]);
-
+#ifdef __MINGW32__
+    boost::nowide::args a(argc, argv); // Fix arguments - make them UTF-8
+#endif
     /* We need to initialize gtk before looking up all modules */
     if(!gtk_init_check (&argc, &argv))
     {



Summary of changes:
 gnucash/gnome-utils/gnc-main-window.c | 55 ++++++++++++++++++-----------------
 gnucash/gnucash-cli.cpp               |  7 ++++-
 gnucash/gnucash-core-app.cpp          | 10 -------
 gnucash/gnucash.cpp                   |  7 ++++-
 4 files changed, 40 insertions(+), 39 deletions(-)



More information about the gnucash-changes mailing list