[evolution-data-server/openismus-work-master: 56/134] 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: 56/134] EBookBackendSqliteDB: Reset internal locale when get_locale() is called
- Date: Sat, 19 Oct 2013 19:01:43 +0000 (UTC)
commit 18109673841106f4557b5aafc5a191e8b9e4e407
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 cfb77b6..877224e 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -93,7 +93,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)
@@ -234,6 +235,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);
@@ -5071,16 +5073,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;
}
@@ -5191,6 +5200,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);
@@ -5204,6 +5214,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]