Nux

Merge lp:~thumper/nux/view-deletion-after-window-thread into lp:nux

Proposed by Tim Penhey
Status: Merged
Merged at revision: 485
Proposed branch: lp:~thumper/nux/view-deletion-after-window-thread
Merge into: lp:nux
Diff against target: 61 lines (+19/-7)
3 files modified
Nux/Layout.cpp (+5/-2)
Nux/View.cpp (+9/-4)
NuxGraphics/GLResourceManager.cpp (+5/-1)
To merge this branch: bzr merge lp:~thumper/nux/view-deletion-after-window-thread
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Jason Smith (community) Approve
Review via email: mp+77256@code.launchpad.net

Description of the change

This branch changes the hard dependency between views, layouts, resource data and the windows thread.

The view and layout destructors were getting traversing through the windows thread to unregister some internal stuff. However it is possible that the windows thread is destroyed before the views themselves, so they should check before attempting to call through.

The ResourceData class was also trying to go through an object that was in thread local storage. It now checks too.

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

Looking good

review: Approve
Revision history for this message
Jay Taoko (jaytaoko) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/Layout.cpp'
2--- Nux/Layout.cpp 2011-09-20 06:03:43 +0000
3+++ Nux/Layout.cpp 2011-09-28 01:19:24 +0000
4@@ -48,8 +48,11 @@
5
6 Layout::~Layout()
7 {
8- // It is possible that this layout object is in the refresh list. Remove it here before it is deleted.
9- GetWindowThread()->RemoveObjectFromLayoutQueue(this);
10+ // It is possible that this layout object is in the refresh list. Remove
11+ // it here before it is deleted.
12+ WindowThread* wt = GetWindowThread();
13+ if (wt)
14+ wt->RemoveObjectFromLayoutQueue(this);
15
16 std::list<Area *>::iterator it;
17
18
19=== modified file 'Nux/View.cpp'
20--- Nux/View.cpp 2011-09-20 06:03:43 +0000
21+++ Nux/View.cpp 2011-09-28 01:19:24 +0000
22@@ -49,13 +49,18 @@
23
24 View::~View()
25 {
26- if (GetFocused () && HasPassiveFocus() == false)
27+ // It is possible that the window thread has been deleted before the view
28+ // itself, so check prior to calling.
29+ WindowThread* wt = GetWindowThread();
30+ if (GetFocused() && HasPassiveFocus() == false && wt)
31 {
32- nux::GetWindowThread ()->SetFocusedArea (NULL);
33+ wt->SetFocusedArea (NULL);
34 }
35
36- // It is possible that the object is in the refresh list. Remove it here before it is deleted.
37- GetWindowThread()->RemoveObjectFromLayoutQueue(this);
38+ // It is possible that the object is in the refresh list. Remove it here
39+ // before it is deleted.
40+ if (wt)
41+ wt->RemoveObjectFromLayoutQueue(this);
42
43 RemoveLayout();
44 }
45
46=== modified file 'NuxGraphics/GLResourceManager.cpp'
47--- NuxGraphics/GLResourceManager.cpp 2011-09-20 06:03:43 +0000
48+++ NuxGraphics/GLResourceManager.cpp 2011-09-28 01:19:24 +0000
49@@ -46,7 +46,11 @@
50
51 ResourceData::~ResourceData ()
52 {
53- GetGraphicsDisplay()->GetGraphicsEngine()->FlushCachedResourceData(this);
54+ // If the windows thread is deleted before any texture type resource, the
55+ // graphics display will not exist.
56+ GraphicsDisplay* display = GetGraphicsDisplay();
57+ if (display)
58+ display->GetGraphicsEngine()->FlushCachedResourceData(this);
59 }
60
61 int ResourceData::GetResourceIndex() const

Subscribers

People subscribed via source and target branches