Merge lp:~brandontschaefer/unity/fix-1046201-6.0 into lp:unity/6.0

Proposed by Brandon Schaefer
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: no longer in the source branch.
Merged at revision: 2790
Proposed branch: lp:~brandontschaefer/unity/fix-1046201-6.0
Merge into: lp:unity/6.0
Diff against target: 404 lines (+49/-42)
12 files modified
plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp (+1/-1)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.h (+6/-4)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp (+2/-2)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.h (+5/-3)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-window.h (+1/-1)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp (+3/-3)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.h (+8/-6)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp (+5/-6)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h (+8/-6)
plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp (+2/-2)
plugins/unity-mt-grab-handles/src/unity-mt-texture.h (+4/-3)
tests/test_grabhandle.cpp (+4/-5)
To merge this branch: bzr merge lp:~brandontschaefer/unity/fix-1046201-6.0
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
Review via email: mp+131140@code.launchpad.net

Commit message

Fix reference counting problem which leads to memory leaks and a crash in MT grab handles.

Description of the change

Revert the changes to 6.0 from boost -> std. The crash will still be fixed!

To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Ok, looking good to me, I checked and it seems all previous changes seem to be changed back. It also works and doesn't result in any crashes or visible problems.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp'
2--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp 2012-10-13 20:26:41 +0000
3+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp 2012-10-24 08:30:27 +0000
4@@ -40,7 +40,7 @@
5 }
6
7 void
8-unity::MT::GrabHandleGroup::raiseHandle(const std::shared_ptr <const unity::MT::GrabHandle> &h)
9+unity::MT::GrabHandleGroup::raiseHandle(const boost::shared_ptr <const unity::MT::GrabHandle> &h)
10 {
11 mOwner->raiseGrabHandle (h);
12 }
13
14=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.h'
15--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.h 2012-10-13 20:26:41 +0000
16+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.h 2012-10-24 08:30:27 +0000
17@@ -22,7 +22,9 @@
18 #include <Nux/Nux.h>
19 #include <glib.h>
20 #include <boost/noncopyable.hpp>
21-#include <memory>
22+#include <boost/shared_ptr.hpp>
23+#include <boost/enable_shared_from_this.hpp>
24+#include <boost/weak_ptr.hpp>
25
26 #include "unity-mt-grab-handle.h"
27 #include "unity-mt-texture.h"
28@@ -35,12 +37,12 @@
29 extern unsigned int FADE_MSEC;
30
31 class GrabHandleGroup :
32- public std::enable_shared_from_this <GrabHandleGroup>,
33+ public boost::enable_shared_from_this <GrabHandleGroup>,
34 boost::noncopyable
35 {
36 public:
37
38- typedef std::shared_ptr <GrabHandleGroup> Ptr;
39+ typedef boost::shared_ptr <GrabHandleGroup> Ptr;
40
41 static GrabHandleGroup::Ptr create (GrabHandleWindow *owner,
42 std::vector<TextureSize> &textures);
43@@ -57,7 +59,7 @@
44
45 void hide();
46 void show(unsigned int handles = ~0);
47- void raiseHandle (const std::shared_ptr <const unity::MT::GrabHandle> &);
48+ void raiseHandle (const boost::shared_ptr <const unity::MT::GrabHandle> &);
49
50 std::vector <TextureLayout> layout(unsigned int handles);
51
52
53=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp'
54--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp 2012-10-13 20:26:41 +0000
55+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp 2012-10-24 08:30:27 +0000
56@@ -19,9 +19,9 @@
57 #include "unity-mt-grab-handle-impl-factory.h"
58 #include "unity-mt-grab-handle.h"
59
60-std::shared_ptr <unity::MT::GrabHandle::ImplFactory> unity::MT::GrabHandle::ImplFactory::mDefault;
61+boost::shared_ptr <unity::MT::GrabHandle::ImplFactory> unity::MT::GrabHandle::ImplFactory::mDefault;
62
63-std::shared_ptr <unity::MT::GrabHandle::ImplFactory>
64+boost::shared_ptr <unity::MT::GrabHandle::ImplFactory>
65 unity::MT::GrabHandle::ImplFactory::Default()
66 {
67 return mDefault;
68
69=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.h'
70--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.h 2012-10-13 20:26:41 +0000
71+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.h 2012-10-24 08:30:27 +0000
72@@ -22,7 +22,9 @@
73 #include <Nux/Nux.h>
74 #include <glib.h>
75 #include <boost/noncopyable.hpp>
76-#include <memory>
77+#include <boost/shared_ptr.hpp>
78+#include <boost/enable_shared_from_this.hpp>
79+#include <boost/weak_ptr.hpp>
80
81 #include "unity-mt-grab-handle.h"
82
83@@ -36,7 +38,7 @@
84
85 virtual ~ImplFactory() {};
86
87- static std::shared_ptr <ImplFactory>
88+ static boost::shared_ptr <ImplFactory>
89 Default();
90
91 static void
92@@ -46,7 +48,7 @@
93
94 protected:
95
96- static std::shared_ptr <ImplFactory> mDefault;
97+ static boost::shared_ptr <ImplFactory> mDefault;
98
99 ImplFactory() {};
100 };
101
102=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-window.h'
103--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-window.h 2012-10-13 20:26:41 +0000
104+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-window.h 2012-10-24 08:30:27 +0000
105@@ -37,7 +37,7 @@
106 int y,
107 unsigned int direction,
108 unsigned int button) = 0;
109- virtual void raiseGrabHandle (const std::shared_ptr <const unity::MT::GrabHandle> &) = 0;
110+ virtual void raiseGrabHandle (const boost::shared_ptr <const unity::MT::GrabHandle> &) = 0;
111 };
112
113 };
114
115=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp'
116--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp 2012-10-13 20:26:41 +0000
117+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp 2012-10-24 08:30:27 +0000
118@@ -55,7 +55,7 @@
119 unity::MT::GrabHandle::raise () const
120 {
121 unity::MT::GrabHandleGroup::Ptr ghg = mOwner.lock ();
122- std::shared_ptr <const unity::MT::GrabHandle> gh = shared_from_this ();
123+ boost::shared_ptr <const unity::MT::GrabHandle> gh = shared_from_this ();
124 ghg->raiseHandle (gh);
125 }
126
127@@ -98,7 +98,7 @@
128 unity::MT::GrabHandle::GrabHandle(Texture::Ptr texture,
129 unsigned int width,
130 unsigned int height,
131- const std::shared_ptr <GrabHandleGroup> &owner,
132+ const boost::shared_ptr <GrabHandleGroup> &owner,
133 unsigned int id) :
134 mOwner(owner),
135 mTexture (texture),
136@@ -110,7 +110,7 @@
137
138 unity::MT::GrabHandle::Ptr
139 unity::MT::GrabHandle::create (Texture::Ptr texture, unsigned int width, unsigned int height,
140- const std::shared_ptr <GrabHandleGroup> &owner,
141+ const boost::shared_ptr <GrabHandleGroup> &owner,
142 unsigned int id)
143 {
144 unity::MT::GrabHandle::Ptr p (new unity::MT::GrabHandle (texture, width, height, owner, id));
145
146=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.h'
147--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.h 2012-10-13 20:26:41 +0000
148+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.h 2012-10-24 08:30:27 +0000
149@@ -21,8 +21,10 @@
150
151 #include <Nux/Nux.h>
152 #include <glib.h>
153-#include <memory>
154 #include <boost/noncopyable.hpp>
155+#include <boost/shared_ptr.hpp>
156+#include <boost/enable_shared_from_this.hpp>
157+#include <boost/weak_ptr.hpp>
158
159 #include "unity-mt-texture.h"
160 #include "unity-mt-grab-handle-window.h"
161@@ -77,17 +79,17 @@
162 class GrabHandleGroup;
163
164 class GrabHandle :
165- public std::enable_shared_from_this <GrabHandle>,
166+ public boost::enable_shared_from_this <GrabHandle>,
167 boost::noncopyable
168 {
169 public:
170
171- typedef std::shared_ptr <GrabHandle> Ptr;
172+ typedef boost::shared_ptr <GrabHandle> Ptr;
173
174 static GrabHandle::Ptr create (Texture::Ptr texture,
175 unsigned int width,
176 unsigned int height,
177- const std::shared_ptr <GrabHandleGroup> &owner,
178+ const boost::shared_ptr <GrabHandleGroup> &owner,
179 unsigned int id);
180 ~GrabHandle();
181
182@@ -158,10 +160,10 @@
183 GrabHandle(Texture::Ptr texture,
184 unsigned int width,
185 unsigned int height,
186- const std::shared_ptr <GrabHandleGroup> &owner,
187+ const boost::shared_ptr <GrabHandleGroup> &owner,
188 unsigned int id);
189
190- std::weak_ptr <GrabHandleGroup> mOwner;
191+ boost::weak_ptr <GrabHandleGroup> mOwner;
192 Texture::Ptr mTexture;
193 unsigned int mId;
194 nux::Geometry mRect;
195
196=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp'
197--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp 2012-10-13 20:26:41 +0000
198+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp 2012-10-24 08:30:27 +0000
199@@ -35,8 +35,7 @@
200 unity::MT::Texture::Ptr
201 unity::MT::X11TextureFactory::create ()
202 {
203- unity::MT::Texture::Ptr tp(static_cast<unity::MT::Texture*> (new unity::MT::X11Texture(mWrap)));
204- return tp;
205+ return boost::shared_static_cast <unity::MT::Texture> (unity::MT::X11Texture::Ptr (new unity::MT::X11Texture (mWrap)));
206 }
207
208 unity::MT::X11Texture::X11Texture (const GLTexture::List &t)
209@@ -152,7 +151,7 @@
210 }
211
212 void
213-UnityMTGrabHandlesWindow::raiseGrabHandle (const std::shared_ptr <const unity::MT::GrabHandle> &h)
214+UnityMTGrabHandlesWindow::raiseGrabHandle (const boost::shared_ptr <const unity::MT::GrabHandle> &h)
215 {
216 UnityMTGrabHandlesScreen::get (screen)->raiseHandle (h, window->frame ());
217 }
218@@ -203,7 +202,7 @@
219 }
220
221 void
222-UnityMTGrabHandlesScreen::raiseHandle (const std::shared_ptr <const unity::MT::GrabHandle> &h,
223+UnityMTGrabHandlesScreen::raiseHandle (const boost::shared_ptr <const unity::MT::GrabHandle> &h,
224 Window owner)
225 {
226 for (const auto &pair : mInputHandles)
227@@ -461,7 +460,7 @@
228 * region */
229 CompRegion reg = CompRegion(layout.second.x, layout.second.y, layout.second.width, layout.second.height);
230
231- for(GLTexture * tex : static_cast<unity::MT::X11Texture*>(layout.first.get())->get())
232+ for(GLTexture * tex : boost::shared_static_cast <unity::MT::X11Texture> (layout.first)->get ())
233 {
234 GLTexture::MatrixList matl;
235 GLTexture::Matrix mat = tex->matrix();
236@@ -778,7 +777,7 @@
237 GLTexture::List t = GLTexture::readImageToTexture(fname, pname,
238 size);
239
240- (static_cast<unity::MT::X11TextureFactory*>(unity::MT::Texture::Factory::Default().get())->setActiveWrap(t));
241+ (boost::shared_static_cast <unity::MT::X11TextureFactory> (unity::MT::Texture::Factory::Default ()))->setActiveWrap (t);
242
243 mHandleTextures.at(i).first = unity::MT::Texture::Factory::Default ()->create ();
244 mHandleTextures.at (i).second.width = size.width ();
245
246=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h'
247--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h 2012-10-13 20:26:41 +0000
248+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h 2012-10-24 08:30:27 +0000
249@@ -22,7 +22,9 @@
250 #include <composite/composite.h>
251 #include <opengl/opengl.h>
252 #include <boost/noncopyable.hpp>
253-#include <memory>
254+#include <boost/shared_ptr.hpp>
255+#include <boost/enable_shared_from_this.hpp>
256+#include <boost/weak_ptr.hpp>
257
258 #include <core/atoms.h>
259
260@@ -70,7 +72,7 @@
261 {
262 public:
263
264- typedef std::shared_ptr <X11Texture> Ptr;
265+ typedef boost::shared_ptr <X11Texture> Ptr;
266
267 X11Texture (const GLTexture::List &t);
268
269@@ -122,7 +124,7 @@
270
271 private:
272
273- std::weak_ptr <unity::MT::GrabHandle> mGrabHandle;
274+ boost::weak_ptr <unity::MT::GrabHandle> mGrabHandle;
275 Window mIpw;
276 Display *mDpy;
277 };
278@@ -173,7 +175,7 @@
279 void preparePaint(int);
280 void donePaint();
281
282- void raiseHandle (const std::shared_ptr <const unity::MT::GrabHandle> &,
283+ void raiseHandle (const boost::shared_ptr <const unity::MT::GrabHandle> &,
284 Window owner);
285
286 std::vector <unity::MT::TextureSize> & textures()
287@@ -186,7 +188,7 @@
288 std::list <unity::MT::GrabHandleGroup::Ptr> mGrabHandles;
289 std::vector <unity::MT::TextureSize> mHandleTextures;
290
291- std::map <Window, const std::weak_ptr <unity::MT::GrabHandle> > mInputHandles;
292+ std::map <Window, const boost::weak_ptr <unity::MT::GrabHandle> > mInputHandles;
293 CompWindowVector mLastClientListStacking;
294 Atom mCompResizeWindowAtom;
295
296@@ -241,7 +243,7 @@
297
298 protected:
299
300- void raiseGrabHandle (const std::shared_ptr <const unity::MT::GrabHandle> &h);
301+ void raiseGrabHandle (const boost::shared_ptr <const unity::MT::GrabHandle> &h);
302 void requestMovement (int x,
303 int y,
304 unsigned int direction,
305
306=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp'
307--- plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp 2012-10-13 20:26:41 +0000
308+++ plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp 2012-10-24 08:30:27 +0000
309@@ -18,7 +18,7 @@
310
311 #include "unity-mt-texture.h"
312
313-std::shared_ptr <unity::MT::Texture::Factory> unity::MT::Texture::Factory::mDefault;
314+boost::shared_ptr <unity::MT::Texture::Factory> unity::MT::Texture::Factory::mDefault;
315
316 unity::MT::Texture::Factory::Factory ()
317 {
318@@ -34,7 +34,7 @@
319 mDefault.reset (f);
320 }
321
322-std::shared_ptr <unity::MT::Texture::Factory>
323+boost::shared_ptr <unity::MT::Texture::Factory>
324 unity::MT::Texture::Factory::Default ()
325 {
326 return mDefault;
327
328=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-texture.h'
329--- plugins/unity-mt-grab-handles/src/unity-mt-texture.h 2012-10-13 20:26:41 +0000
330+++ plugins/unity-mt-grab-handles/src/unity-mt-texture.h 2012-10-24 08:30:27 +0000
331@@ -21,6 +21,7 @@
332
333 #include <Nux/Nux.h>
334 #include <boost/noncopyable.hpp>
335+#include <boost/shared_ptr.hpp>
336
337 namespace unity
338 {
339@@ -30,7 +31,7 @@
340 {
341 public:
342
343- typedef std::shared_ptr <Texture> Ptr;
344+ typedef boost::shared_ptr <Texture> Ptr;
345
346 virtual ~Texture ();
347
348@@ -47,7 +48,7 @@
349 static void
350 SetDefault (Factory *);
351
352- static std::shared_ptr <Factory>
353+ static boost::shared_ptr <Factory>
354 Default ();
355
356 protected:
357@@ -56,7 +57,7 @@
358
359 private:
360
361- static std::shared_ptr <unity::MT::Texture::Factory> mDefault;
362+ static boost::shared_ptr <unity::MT::Texture::Factory> mDefault;
363 };
364
365 protected:
366
367=== modified file 'tests/test_grabhandle.cpp'
368--- tests/test_grabhandle.cpp 2012-10-13 20:26:41 +0000
369+++ tests/test_grabhandle.cpp 2012-10-24 08:30:27 +0000
370@@ -7,7 +7,7 @@
371 #include <unity-mt-grab-handle-group.h>
372 #include <unity-mt-grab-handle-impl-factory.h>
373 #include <unity-mt-texture.h>
374-#include <memory>
375+#include <boost/shared_ptr.hpp>
376
377 unsigned int unity::MT::MaximizedHorzMask = (1 << 0);
378 unsigned int unity::MT::MaximizedVertMask = (1 << 1);
379@@ -95,7 +95,7 @@
380 class MockGrabHandleTexture : public unity::MT::Texture
381 {
382 public:
383- typedef std::shared_ptr <MockGrabHandleTexture> Ptr;
384+ typedef boost::shared_ptr <MockGrabHandleTexture> Ptr;
385 MockGrabHandleTexture () : unity::MT::Texture () {};
386 };
387
388@@ -112,14 +112,13 @@
389 public:
390 MockGrabHandleWindow () : GrabHandleWindow () {};
391 MOCK_METHOD4 (requestMovement, void (int, int, unsigned int, unsigned int));
392- MOCK_METHOD1 (raiseGrabHandle, void (const std::shared_ptr <const unity::MT::GrabHandle> &));
393+ MOCK_METHOD1 (raiseGrabHandle, void (const boost::shared_ptr <const unity::MT::GrabHandle> &));
394 };
395
396 Texture::Ptr
397 MockGrabHandleTextureFactory::create ()
398 {
399- Texture::Ptr pt(static_cast<unity::MT::Texture*>(new MockGrabHandleTexture()));
400- return pt;
401+ return boost::shared_static_cast <Texture> (MockGrabHandleTexture::Ptr (new MockGrabHandleTexture ()));
402 }
403
404 GrabHandle::Impl *

Subscribers

People subscribed via source and target branches