Do

Merge lp:~stevens-ischyrus/do/dev into lp:do

Proposed by ischyrus
Status: Needs review
Proposed branch: lp:~stevens-ischyrus/do/dev
Merge into: lp:do
Diff against target: 40 lines (+5/-3)
1 file modified
Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs (+5/-3)
To merge this branch: bzr merge lp:~stevens-ischyrus/do/dev
Reviewer Review Type Date Requested Status
Chris Halse Rogers Needs Information
Review via email: mp+44993@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Chris Halse Rogers (raof) wrote :

Thanks for your contribution!

This code is correct. However, I'm not sure that Do *should* continue to load when the keybindings won't work. Would this be useful for you? Do won't crash, but it also won't respond to anything but the DBus summon interface.

Probably the correct behaviour is to (a) not crash, but (b) throw up an error dialog.

review: Needs Information

Unmerged revisions

1333. By ischyrus

There is a check that ensures libdo is found\loaded, if not loaded the exception is handled and discarded.

Later on when a keybinding is added the application will crash. Because the state of libdo is already determined and RegisterOSKey\UnRegisterOSKey both return the result of the operation, the KeyBindingService should gracefully handle the scenario rather than throw an unhandled exception.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs'
2--- Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs 2009-08-08 05:48:10 +0000
3+++ Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs 2011-01-02 08:57:57 +0000
4@@ -24,6 +24,7 @@
5 public delegate void BindkeyHandler (string key, IntPtr user_data);
6
7 BindkeyHandler key_handler;
8+ bool libdoFound = false;
9
10 public KeyBindingService () : base ()
11 {
12@@ -31,6 +32,7 @@
13
14 try {
15 gnomedo_keybinder_init ();
16+ libdoFound = true;
17 } catch (DllNotFoundException) {
18 Log.Error ("libdo not found - keybindings will not work.");
19 }
20@@ -45,16 +47,16 @@
21
22 public override bool RegisterOSKey (string keyString, EventCallback cb)
23 {
24- if (string.IsNullOrEmpty (keyString) || cb == null)
25+ if (!libdoFound || string.IsNullOrEmpty (keyString) || cb == null)
26 return false;
27 return gnomedo_keybinder_bind (keyString, key_handler);
28 }
29
30 public override bool UnRegisterOSKey (string keyString)
31 {
32- if (Bindings.Any (k => k.KeyString == keyString))
33+ if (!libdoFound || Bindings.Any (k => k.KeyString == keyString))
34 return gnomedo_keybinder_unbind (keyString, key_handler);
35 return false;
36 }
37 }
38-}
39\ No newline at end of file
40+}