Nux

Merge lp:~brandontschaefer/nux/input-method-memory-leak-fix into lp:nux

Proposed by Brandon Schaefer
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 858
Merged at revision: 860
Proposed branch: lp:~brandontschaefer/nux/input-method-memory-leak-fix
Merge into: lp:nux
Diff against target: 43 lines (+8/-2)
1 file modified
Nux/InputMethodIBus.cpp (+8/-2)
To merge this branch: bzr merge lp:~brandontschaefer/nux/input-method-memory-leak-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+257133@code.launchpad.net

Commit message

Need to unref the bus, and need to free the keybindings when we are done.

Description of the change

Need to unref the bus, and need to free the keybindings when we are done.

To post a comment you must log in.
858. By Brandon Schaefer

* Clean up the memory leak fixes to be better. Thanks Trevinho!

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Good catch.
+1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/InputMethodIBus.cpp'
2--- Nux/InputMethodIBus.cpp 2014-03-23 09:59:47 +0000
3+++ Nux/InputMethodIBus.cpp 2015-04-22 16:48:57 +0000
4@@ -32,7 +32,6 @@
5 {
6 DECLARE_LOGGER(logger, "nux.inputmethod.ibus");
7 }
8-
9 std::vector<Event> IBusIMEContext::hotkeys_;
10
11 IBusBus* IBusIMEContext::bus_ = NULL;
12@@ -44,10 +43,15 @@
13 , is_focused_(false)
14 {
15 // init ibus
16- if (!bus_)
17+ if (!G_OBJECT(bus_))
18 {
19 ibus_init();
20 bus_ = ibus_bus_new();
21+ g_object_add_weak_pointer(G_OBJECT(bus_), reinterpret_cast<gpointer*>(&bus_));
22+ }
23+ else
24+ {
25+ g_object_ref(bus_);
26 }
27
28 // connect bus signals
29@@ -69,6 +73,7 @@
30 DestroyContext();
31 g_signal_handlers_disconnect_by_data(bus_, this);
32 g_object_unref(cancellable_);
33+ g_object_unref(bus_);
34 }
35
36 void IBusIMEContext::Focus()
37@@ -503,6 +508,7 @@
38 hotkeys_ = ParseIBusHotkeys(keybindings);
39
40 g_variant_unref(val);
41+ g_free(keybindings);
42 }
43 }
44

Subscribers

People subscribed via source and target branches