From ccba29be5eb44d8ded17aa04f5e17f90774d4314 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 10 Dec 2010 00:05:30 +0000 Subject: [PATCH] Add Gnucash svn version to sql versions table. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19920 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/backend/sql/gnc-backend-sql.c | 8 ++++++++ src/core-utils/gnc-main.c | 8 ++++++++ src/core-utils/gnc-main.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/backend/sql/gnc-backend-sql.c b/src/backend/sql/gnc-backend-sql.c index a797461043..4e8815aaf4 100644 --- a/src/backend/sql/gnc-backend-sql.c +++ b/src/backend/sql/gnc-backend-sql.c @@ -73,6 +73,8 @@ #include "gnc-tax-table-sql.h" #include "gnc-vendor-sql.h" +#include "gnc-main.h" + #if defined( S_SPLINT_S ) #include "splint-defs.h" #endif @@ -482,6 +484,7 @@ gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book ) ENTER( "book=%p, primary=%p", book, be->primary_book ); (void)reset_version_info( be ); + gnc_sql_set_table_version( be, "Gnucash", gnc_get_svn_version() ); /* Create new tables */ be->is_pristine_db = TRUE; @@ -593,6 +596,7 @@ gnc_sql_commit_edit( GncSqlBackend *be, QofInstance *inst ) gboolean is_dirty; gboolean is_destroying; gboolean is_infant; + const gint gnc_version = gnc_get_svn_version(); g_return_if_fail( be != NULL ); g_return_if_fail( inst != NULL ); @@ -640,6 +644,10 @@ gnc_sql_commit_edit( GncSqlBackend *be, QofInstance *inst ) be_data.be = be; be_data.inst = inst; be_data.is_ok = TRUE; + /* Set/update the application version in the database */ + if (gnc_sql_get_table_version( be, "Gnucash") != gnc_version ) + gnc_sql_set_table_version( be, "Gnucash", gnc_version ); + qof_object_foreach_backend( GNC_SQL_BACKEND, commit_cb, &be_data ); if ( !be_data.is_known ) diff --git a/src/core-utils/gnc-main.c b/src/core-utils/gnc-main.c index fb613f8bfa..647bf529e1 100644 --- a/src/core-utils/gnc-main.c +++ b/src/core-utils/gnc-main.c @@ -21,8 +21,10 @@ * Boston, MA 02110-1301, USA gnu@gnu.org */ +#include #include "config.h" #include "gnc-main.h" +#include "gnome-utils/gnc-version.h" static gchar *namespace_regexp = NULL; static gboolean is_debugging = 0; @@ -80,3 +82,9 @@ gnc_get_gconf_path (void) { return gconf_path; } + +gint +gnc_get_svn_version (void) +{ + return strtol(GNUCASH_SVN_REV, NULL, 10); +} diff --git a/src/core-utils/gnc-main.h b/src/core-utils/gnc-main.h index 5766d3137b..442fd61949 100644 --- a/src/core-utils/gnc-main.h +++ b/src/core-utils/gnc-main.h @@ -40,4 +40,6 @@ void gnc_set_extra(gboolean enabled); void gnc_set_gconf_path(const gchar *prefix); const gchar *gnc_get_gconf_path(void); +gint gnc_get_svn_version(void); + #endif /* GNC_MAIN_H */