Merge lp:~3v1n0/unity/scale-window-cast-protection into lp:unity

Proposed by Marco Trevisan (Treviño) on 2017-02-28
Status: Merged
Approved by: Andrea Azzarone on 2017-02-28
Approved revision: 4221
Merged at revision: 4223
Proposed branch: lp:~3v1n0/unity/scale-window-cast-protection
Merge into: lp:unity
Diff against target: 56 lines (+17/-6)
1 file modified
plugins/unityshell/src/unityshell.cpp (+17/-6)
To merge this branch: bzr merge lp:~3v1n0/unity/scale-window-cast-protection
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) 2017-02-28 Approve on 2017-02-28
Review via email: mp+318516@code.launchpad.net

Commit message

UnityWindow: safely check validity of UnityWindow from scaled one

To post a comment you must log in.
Andrea Azzarone (azzar1) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2017-01-09 15:09:26 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2017-02-28 17:20:41 +0000
4@@ -587,12 +587,14 @@
5
6 for (auto const& swin : sScreen->getWindows())
7 {
8- if (filtered_windows.find(swin->window->id()) != filtered_windows.end())
9+ if (!swin->window || filtered_windows.find(swin->window->id()) != filtered_windows.end())
10 continue;
11
12- auto* uwin = UnityWindow::get(swin->window);
13- uwin->OnTerminateSpread();
14- fake_decorated_windows_.erase(uwin);
15+ if (UnityWindow* uwin = UnityWindow::get(swin->window))
16+ {
17+ uwin->OnTerminateSpread();
18+ fake_decorated_windows_.erase(uwin);
19+ }
20 }
21
22 for (auto xid : filtered_windows)
23@@ -606,6 +608,9 @@
24
25 for (auto const& swin : sScreen->getWindows())
26 {
27+ if (!swin->window)
28+ continue;
29+
30 auto* uwin = UnityWindow::get(swin->window);
31 fake_decorated_windows_.insert(uwin);
32 uwin->OnInitiateSpread();
33@@ -617,7 +622,13 @@
34 spread_widgets_.reset();
35
36 for (auto const& swin : sScreen->getWindows())
37- UnityWindow::get(swin->window)->OnTerminateSpread();
38+ {
39+ if (!swin->window)
40+ continue;
41+
42+ if (UnityWindow* uwin = UnityWindow::get(swin->window))
43+ uwin->OnTerminateSpread();
44+ }
45
46 fake_decorated_windows_.clear();
47 }
48@@ -3859,7 +3870,7 @@
49
50 for (ScaleWindow *sw : scaled_windows)
51 {
52- if (sw->window->outputDevice() == static_cast<int>(output.id()))
53+ if (sw->window && sw->window->outputDevice() == static_cast<int>(output.id()))
54 {
55 UnityWindow::get(sw->window)->deco_win_->scaled = true;
56 layout_windows.emplace_back(std::make_shared<LayoutWindow>(sw->window->id()));