[evolution-data-server/openismus-work-master: 59/72] EBookBackendSqliteDB: Reset internal locale when get_locale() is called
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master: 59/72] EBookBackendSqliteDB: Reset internal locale when get_locale() is called
- Date: Thu, 4 Jul 2013 19:14:04 +0000 (UTC)
commit 5acb441d477f50a4294c9f32c0478bf4df57384f
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Thu Jul 4 18:58:17 2013 +0900
EBookBackendSqliteDB: Reset internal locale when get_locale() is called
If get_locale() returns a locale that is not the currently known locale,
then rebuild the ECollator.
.../libedata-book/e-book-backend-sqlitedb.c | 29 +++++++++++++++-----
1 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb.c
b/addressbook/libedata-book/e-book-backend-sqlitedb.c
index d536a28..25e1ee9 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -90,7 +90,8 @@ struct _EBookBackendSqliteDBPrivate {
guint have_attr_list : 1;
IndexFlags attr_list_indexes;
- ECollator *collator;/* The ECollator to create sort keys for all fields */
+ ECollator *collator; /* The ECollator to create sort keys for all fields */
+ gchar *locale; /* The current locale */
};
G_DEFINE_TYPE (EBookBackendSqliteDB, e_book_backend_sqlitedb, G_TYPE_OBJECT)
@@ -231,6 +232,7 @@ e_book_backend_sqlitedb_finalize (GObject *object)
g_free (priv->path);
g_free (priv->summary_fields);
+ g_free (priv->locale);
if (priv->collator)
e_collator_unref (priv->collator);
@@ -5060,16 +5062,23 @@ sqlitedb_set_locale_internal (EBookBackendSqliteDB *ebsdb,
const gchar *locale,
GError **error)
{
+ EBookBackendSqliteDBPrivate *priv = ebsdb->priv;
ECollator *collator;
- collator = e_collator_new (locale, error);
- if (!collator)
- return FALSE;
+ if (g_strcmp0 (priv->locale, locale) != 0) {
+
+ collator = e_collator_new (locale, error);
+ if (!collator)
+ return FALSE;
+
+ g_free (priv->locale);
+ priv->locale = g_strdup (locale);
- if (ebsdb->priv->collator)
- e_collator_unref (ebsdb->priv->collator);
+ if (ebsdb->priv->collator)
+ e_collator_unref (ebsdb->priv->collator);
- ebsdb->priv->collator = collator;
+ ebsdb->priv->collator = collator;
+ }
return TRUE;
}
@@ -5180,6 +5189,7 @@ e_book_backend_sqlitedb_get_locale (EBookBackendSqliteDB *ebsdb,
{
gchar *stmt;
gboolean success;
+ GError *local_error = NULL;
g_return_val_if_fail (E_IS_BOOK_BACKEND_SQLITEDB (ebsdb), FALSE);
g_return_val_if_fail (folderid && folderid[0], FALSE);
@@ -5193,6 +5203,11 @@ e_book_backend_sqlitedb_get_locale (EBookBackendSqliteDB *ebsdb,
ebsdb->priv->db, stmt, get_string_cb, lc_collate_out, error);
sqlite3_free (stmt);
+ if (!sqlitedb_set_locale_internal (ebsdb, *lc_collate_out, &local_error)) {
+ g_warning ("Error loading new locale: %s", local_error->message);
+ g_clear_error (&local_error);
+ }
+
UNLOCK_MUTEX (&ebsdb->priv->lock);
return success;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]