gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Thu Dec 10 14:47:50 EST 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/b2ced3d7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a3cb28a2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c559d281 (commit)
	from  https://github.com/Gnucash/gnucash/commit/568bfa02 (commit)



commit b2ced3d7197aa7574e14aef703f818609f5e434a
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Thu Dec 10 20:47:36 2015 +0100

    Bug 745101 - No warning when quitting with unsaved file
    
    Improved fix: mark session dirty in qof_commit_edit_part2
    instead of delegating this to the backends. This way
    a session is also properly marked dirty (and hence the
    save button enabled) when no backend is chosen yet
    (that is, when in a new file that's never saved yet).
    
    For the xml backend this means there's nothing to do anymore
    at commit time, so the xml_commit_edit callback is removed.

diff --git a/src/backend/xml/gnc-backend-xml.c b/src/backend/xml/gnc-backend-xml.c
index 6d9274e..8c2f32a 100644
--- a/src/backend/xml/gnc-backend-xml.c
+++ b/src/backend/xml/gnc-backend-xml.c
@@ -1083,33 +1083,6 @@ xml_rollback_edit (QofBackend *be, QofInstance *inst)
 #endif
 }
 
-static void
-xml_commit_edit (QofBackend *be, QofInstance *inst)
-{
-    if (qof_instance_get_dirty(inst) && qof_get_alt_dirty_mode() &&
-            !(qof_instance_get_infant(inst) && qof_instance_get_destroying(inst)))
-    {
-        qof_collection_mark_dirty(qof_instance_get_collection(inst));
-        qof_book_mark_session_dirty(qof_instance_get_book(inst));
-    }
-#if BORKEN_FOR_NOW
-    FileBackend *fbe = (FileBackend *) be;
-    QofBook *book = gp;
-    const char * filepath;
-
-    if (strcmp (GNC_ID_PERIOD, typ)) return;
-    filepath = build_period_filepath(fbe, book);
-    PINFO (" ====================== book=%p filepath=%s\n", book, filepath);
-    gnc_xml_be_write_to_file(fbe, book, filepath, FALSE);
-
-    /* We want to force a save of the current book at this point,
-     * because if we don't, and the user forgets to do so, then
-     * there'll be the same transactions in the closed book,
-     * and also in the current book. */
-    gnc_xml_be_write_to_file (fbe, fbe->primary_book, fbe->fullpath, TRUE);
-#endif
-}
-
 /* ---------------------------------------------------------------------- */
 
 
@@ -1233,7 +1206,7 @@ gnc_backend_new(void)
 
     /* The file backend treats accounting periods transactionally. */
     be->begin = xml_begin_edit;
-    be->commit = xml_commit_edit;
+    be->commit = NULL;
     be->rollback = xml_rollback_edit;
 
     /* The file backend always loads all data ... */
diff --git a/src/libqof/qof/qofinstance.c b/src/libqof/qof/qofinstance.c
index 0327596..f61d107 100644
--- a/src/libqof/qof/qofinstance.c
+++ b/src/libqof/qof/qofinstance.c
@@ -1002,6 +1002,12 @@ qof_commit_edit_part2(QofInstance *inst,
 
     priv = GET_PRIVATE(inst);
 
+    if (priv->dirty && qof_get_alt_dirty_mode() &&
+        !(priv->infant && priv->do_free)) {
+      qof_collection_mark_dirty(priv->collection);
+      qof_book_mark_session_dirty(priv->book);
+    }
+
     /* See if there's a backend.  If there is, invoke it. */
     be = qof_book_get_backend(priv->book);
     if (be && qof_backend_commit_exists(be))
@@ -1031,11 +1037,6 @@ qof_commit_edit_part2(QofInstance *inst,
         /* XXX the backend commit code should clear dirty!! */
         priv->dirty = FALSE;
     }
-//    if (dirty && qof_get_alt_dirty_mode() &&
-//        !(priv->infant && priv->do_free)) {
-//      qof_collection_mark_dirty(priv->collection);
-//      qof_book_mark_dirty(priv->book);
-//    }
     priv->infant = FALSE;
 
     if (priv->do_free)

commit a3cb28a2fed132c71f10150e81904fbf62522ce1
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Thu Dec 10 20:23:21 2015 +0100

    Disable a couple of debug tests in python
    
    They would trigger a file save during start up on the temporary new session that's
    created and destroyed after the following commit.

diff --git a/src/python/init.py b/src/python/init.py
index 59a49c1..7248e8a 100644
--- a/src/python/init.py
+++ b/src/python/init.py
@@ -24,16 +24,14 @@ if noisy:
     print "test", sys.modules.keys()
     print "test2", dir(_sw_app_utils)
 
-root = _sw_app_utils.gnc_get_current_root_account()
+   #root = _sw_app_utils.gnc_get_current_root_account()
 
-if noisy:
-    print "test", dir(root), root.__class__
-    print "test2", dir(gnucash_core_c)
+   #print "test", dir(root), root.__class__
+    print "test3", dir(gnucash_core_c)
 
-acct = Account(instance = root)
+   #acct = Account(instance = root)
 
-if noisy:
-    print "test3", dir(acct)
+   #print "test3", dir(acct)
    #print acct.GetName()
    #print acct.GetBalance()
    #print acct.GetSplitList()

commit c559d28139d34ef237373bf9ff1415b7b924dcc9
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Thu Dec 10 19:47:00 2015 +0100

    Revert "Bug 745101 - No warning when quitting with unsaved file"
    
    This reverts commit 568bfa0282ca9c8d196f69df7dfa98982530214d.

diff --git a/src/libqof/qof/qofsession.c b/src/libqof/qof/qofsession.c
index 7d936c4..76e085b 100644
--- a/src/libqof/qof/qofsession.c
+++ b/src/libqof/qof/qofsession.c
@@ -96,12 +96,6 @@ unregister_all_providers (void)
     }
 }
 
-#define DEFAULT_BACKEND "xml"
-
-static void
-qof_session_load_backend(QofSession * session, const char * access_method);
-
-
 /* ====================================================================== */
 
 void
@@ -264,7 +258,6 @@ qof_session_init (QofSession *session)
     session->backend = NULL;
     session->lock = 1;
 
-    qof_session_load_backend(session, DEFAULT_BACKEND);
     qof_session_clear_error (session);
 }
 
@@ -362,34 +355,25 @@ qof_session_load_backend(QofSession * session, const char * access_method)
         /* Does this provider handle the desired access method? */
         if (0 == g_ascii_strcasecmp (access_method, prov->access_method))
         {
-            /* If this is a completely new session (that is, not associated with a file or db yet)
-             * go for the default backend and skip further type checking.
-             * This should prevent unintended data loss when a user starts a new book without
-             * going via the hierarchy assistant.
-             * See https://bugzilla.gnome.org/show_bug.cgi?id=745101
-             */
-            if (session->book_id || (0 != g_ascii_strcasecmp (DEFAULT_BACKEND, prov->access_method)))
+            /* More than one backend could provide this
+            access method, check file type compatibility. */
+            type_check = (gboolean (*)(const char*)) prov->check_data_type;
+            if (type_check)
             {
-                /* More than one backend could provide this
-                   access method, check file type compatibility. */
-                type_check = (gboolean (*)(const char*)) prov->check_data_type;
-                if (type_check)
-                {
-                    prov_type = (type_check)(session->book_id);
-                    if (!prov_type)
-                    {
-                        PINFO(" %s not usable", prov->provider_name);
-                        p = p->next;
-                        continue;
-                    }
-                }
-                PINFO (" selected %s", prov->provider_name);
-                if (NULL == prov->backend_new)
+                prov_type = (type_check)(session->book_id);
+                if (!prov_type)
                 {
+                    PINFO(" %s not usable", prov->provider_name);
                     p = p->next;
                     continue;
                 }
             }
+            PINFO (" selected %s", prov->provider_name);
+            if (NULL == prov->backend_new)
+            {
+                p = p->next;
+                continue;
+            }
             /* Use the providers creation callback */
             session->backend = (*(prov->backend_new))();
             session->backend->provider = prov;
diff --git a/src/python/init.py b/src/python/init.py
index da9c1a0..59a49c1 100644
--- a/src/python/init.py
+++ b/src/python/init.py
@@ -24,13 +24,15 @@ if noisy:
     print "test", sys.modules.keys()
     print "test2", dir(_sw_app_utils)
 
-    root = _sw_app_utils.gnc_get_current_root_account()
+root = _sw_app_utils.gnc_get_current_root_account()
 
+if noisy:
     print "test", dir(root), root.__class__
     print "test2", dir(gnucash_core_c)
 
-    acct = Account(instance = root)
+acct = Account(instance = root)
 
+if noisy:
     print "test3", dir(acct)
    #print acct.GetName()
    #print acct.GetBalance()



Summary of changes:
 src/backend/xml/gnc-backend-xml.c | 29 +--------------------------
 src/libqof/qof/qofinstance.c      | 11 +++++-----
 src/libqof/qof/qofsession.c       | 42 ++++++++++++---------------------------
 src/python/init.py                | 10 +++++-----
 4 files changed, 25 insertions(+), 67 deletions(-)



More information about the gnucash-changes mailing list