[meld] Check for working gconf and add fallback trigger key (closes bgo#666136)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Check for working gconf and add fallback trigger key (closes bgo#666136)
- Date: Thu, 29 Aug 2013 21:09:10 +0000 (UTC)
commit f2d6584294321c87726ea2049120da72ee58445b
Author: Daniel Richard G <skunk iskunk org>
Date: Fri Aug 30 06:38:56 2013 +1000
Check for working gconf and add fallback trigger key (closes bgo#666136)
Meld presently just checks whether gconf is importable before using it,
which misses some cases where gconf can't talk to the bus or isn't
running.
This patch actually checks for functioning gconf by trying to write a
key, and also adds a file that, if present, forces the ini-file
fallback. This second feature is to avoid switching between
configuration backends in situations where gconf sometimes works and
sometimes fails.
meld/ui/historyentry.py | 8 +++++++-
meld/util/prefs.py | 19 +++++++++++++++----
2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/meld/ui/historyentry.py b/meld/ui/historyentry.py
index d3c4eb6..ad97ccf 100644
--- a/meld/ui/historyentry.py
+++ b/meld/ui/historyentry.py
@@ -18,6 +18,7 @@
import os
import sys
+import glib
import gio
import gtk
import gobject
@@ -286,7 +287,12 @@ class HistoryEntry(gtk.ComboBoxEntry, HistoryWidget):
try:
import gconf
-except ImportError:
+ # Verify that gconf is actually working (bgo#666136)
+ client = gconf.client_get_default()
+ key = '/apps/meld/gconf-test'
+ client.set_int(key, os.getpid())
+ client.unset(key)
+except (ImportError, glib.GError):
do_nothing = lambda *args: None
for m in ('_save_history', '_load_history', '_get_gconf_client'):
setattr(HistoryWidget, m, do_nothing)
diff --git a/meld/util/prefs.py b/meld/util/prefs.py
index 9867e47..841b0f3 100644
--- a/meld/util/prefs.py
+++ b/meld/util/prefs.py
@@ -270,10 +270,21 @@ class ConfigParserPreferences(object):
# Prefer gconf, falling back to configparser
-try:
- import gconf
- Preferences = GConfPreferences
-except ImportError:
+Preferences = None
+
+if sys.platform != 'win32' and not os.path.exists(os.path.join(glib.get_user_config_dir(), 'meld',
'use-rc-prefs')):
+ try:
+ import gconf
+ # Verify that gconf is actually working (bgo#666136)
+ client = gconf.client_get_default()
+ key = '/apps/meld/gconf-test'
+ client.set_int(key, os.getpid())
+ client.unset(key)
+ Preferences = GConfPreferences
+ except (ImportError, glib.GError):
+ pass
+
+if Preferences == None:
try:
import configparser
except ImportError:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]