Nux

Merge lp:~thomir-deactivatedaccount/nux/textentry-memory-leak-fix into lp:nux/2.0

Proposed by Thomi Richards
Status: Superseded
Proposed branch: lp:~thomir-deactivatedaccount/nux/textentry-memory-leak-fix
Merge into: lp:nux/2.0
Diff against target: 204 lines (+32/-24) (has conflicts)
1 file modified
Nux/TextEntry.cpp (+32/-24)
Text conflict in Nux/TextEntry.cpp
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/nux/textentry-memory-leak-fix
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+99864@code.launchpad.net

This proposal has been superseded by a proposal from 2012-03-29.

Commit message

Don't leak the Layout instance when the TextEntry is destroyed.

Description of the change

Don't leak the Layout instance when the TextEntry is destroyed.

To post a comment you must log in.
607. By Thomi Richards

Don't leak the Canvas or Layout objects when the Text Entry is destroyed.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/TextEntry.cpp'
2--- Nux/TextEntry.cpp 2012-03-17 08:50:58 +0000
3+++ Nux/TextEntry.cpp 2012-03-29 04:14:23 +0000
4@@ -155,7 +155,7 @@
5 #if defined(NUX_OS_LINUX)
6 , caret_cursor_(None)
7 , ime_(new IBusIMEContext(this))
8-#endif
9+#endif
10 , ime_active_(false)
11 , text_input_mode_(false)
12 , key_nav_mode_(false)
13@@ -201,6 +201,10 @@
14 if (ime_)
15 delete ime_;
16 #endif
17+
18+ delete canvas_;
19+
20+ ResetLayout();
21 }
22
23 void TextEntry::PreLayoutManagement()
24@@ -315,11 +319,15 @@
25 cursor_blink_status_ = 4;
26
27 // FIXME Have to get the current event fot he x11_keycode for ibus-hangul/korean input
28- nux::Event cur_event = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent();
29- KeyEvent event((NuxEventType)event_type, keysym,cur_event.x11_keycode, state, character);
30+ nux::Event cur_event = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent();
31+ KeyEvent event((NuxEventType)event_type, keysym,cur_event.x11_keycode, state, character);
32
33 #if defined(NUX_OS_LINUX)
34+<<<<<<< TREE
35 im_filtered = ime_->FilterKeyEvent(event);
36+=======
37+ retval = ime_->FilterKeyEvent(event);
38+>>>>>>> MERGE-SOURCE
39 #endif
40
41 if ((!multiline_) && (!lose_key_focus_on_key_nav_direction_up_) && (keysym == NUX_VK_UP))
42@@ -336,8 +344,8 @@
43
44 if (event_type == NUX_KEYUP)
45 return;
46-
47-
48+
49+
50 // we need to ignore some characters
51 if (keysym == NUX_VK_TAB)
52 return;
53@@ -497,7 +505,7 @@
54 {
55 ProcessMouseEvent(NUX_MOUSE_MOVE, x, y, dx, dy, button_flags, key_flags);
56 }
57-
58+
59 void TextEntry::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
60 {
61 #if defined(NUX_OS_LINUX)
62@@ -505,7 +513,7 @@
63 {
64 Display* display = nux::GetGraphicsDisplay()->GetX11Display();
65 nux::BaseWindow* window = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());
66-
67+
68 if (display && window)
69 {
70 caret_cursor_ = XCreateFontCursor(display, XC_xterm);
71@@ -514,7 +522,7 @@
72 }
73 #endif
74 }
75-
76+
77 void TextEntry::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
78 {
79 #if defined(NUX_OS_LINUX)
80@@ -522,7 +530,7 @@
81 {
82 Display* display = nux::GetGraphicsDisplay()->GetX11Display();
83 nux::BaseWindow* window = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());
84-
85+
86 if (display && window)
87 {
88 XUndefineCursor(display, window->GetInputWindowId());
89@@ -608,7 +616,7 @@
90
91 bool TextEntry::HandledDeadKeys(int keysym, int state, const char* character)
92 {
93-#if defined(NUX_OS_LINUX)
94+#if defined(NUX_OS_LINUX)
95 /* Checks if the keysym between the first and last dead key */
96 if ((keysym >= XK_dead_grave) && (keysym <= XK_dead_stroke) && !dead_key_mode_)
97 {
98@@ -619,7 +627,7 @@
99 {
100 composition_mode_ = true;
101 composition_string_.clear();
102-
103+
104 dead_key_string_ = character;
105
106 std::string dead_key;
107@@ -636,7 +644,7 @@
108 return false;
109 #else
110 return false;
111-#endif
112+#endif
113 }
114
115 bool TextEntry::HandledComposition(int keysym, const char* character)
116@@ -664,9 +672,9 @@
117 composition_string_.clear();
118 return true;
119 }
120-
121+
122 composition_string_ += character;
123-
124+
125 std::string composition_match;
126
127 int match = LookForMatch(composition_match);
128@@ -692,11 +700,11 @@
129
130 return true;
131 }
132- }
133+ }
134 return false;
135 #else
136 return false;
137-#endif
138+#endif
139 }
140
141 void TextEntry::SetText(const char* text)
142@@ -840,7 +848,7 @@
143 need_im_reset_ = true;
144 #if defined(NUX_OS_LINUX)
145 ime_->Focus();
146-#endif
147+#endif
148 //gtk_im_context_focus_in(im_context_);
149 //UpdateIMCursorLocation();
150 }
151@@ -860,7 +868,7 @@
152 if (!readonly_ /*&& im_context_*/)
153 {
154 need_im_reset_ = true;
155-#if defined(NUX_OS_LINUX)
156+#if defined(NUX_OS_LINUX)
157 ime_->Blur();
158 #endif
159 //gtk_im_context_focus_out(im_context_);
160@@ -1260,7 +1268,7 @@
161 {
162 if (nux_compose_seqs_compact[i].compare(composition_string_) == 0)
163 {
164- // advance to the next sequence after ::
165+ // advance to the next sequence after ::
166 while (nux_compose_seqs_compact[++i].compare("::") != 0)
167 {
168 }
169@@ -1418,7 +1426,7 @@
170 }
171 if (!completion_.empty() && !wrap_)
172 {
173- attr = pango_attr_foreground_new(65535 * completion_color_.red,
174+ attr = pango_attr_foreground_new(65535 * completion_color_.red,
175 65535 * completion_color_.green,
176 65535 * completion_color_.blue);
177 attr->start_index = static_cast<guint>(pre_completion_length);
178@@ -2331,14 +2339,14 @@
179 // This will move the cursor one line up.
180 return true;
181 }
182-
183+
184 if (multiline_ && (key_sym == NUX_VK_DOWN))
185 {
186 // Navigate between the lines of the text entry.
187- // This will move the cursor one line down.
188+ // This will move the cursor one line down.
189 return true;
190 }
191-
192+
193 if ((!multiline_) && (!lose_key_focus_on_key_nav_direction_up_) && (key_sym == NUX_VK_UP))
194 {
195 // By returning true, the text entry signals that it want to receive the signal for this event.
196@@ -2415,7 +2423,7 @@
197 void TextEntry::SetLoseKeyFocusOnKeyNavDirectionDown(bool b)
198 {
199 lose_key_focus_on_key_nav_direction_down_ = b;
200- }
201+ }
202
203 bool TextEntry::GetLoseKeyFocusOnKeyNavDirectionDown() const
204 {

Subscribers

People subscribed via source and target branches

to all changes: