Use smart pointers to protect access to TabBoxClient
author Martin Gräßlin
()
committer Martin Gräßlin
()
commit 19c0fa5abd90a46de2ef6949a15de31111f930f4
tree 2e86f61ab0610272f1ecdbfdd6a6eefc38ccad23
parent 01565511497b32b35c69228616abdf07f035c34c
Use smart pointers to protect access to TabBoxClient

Client holds a SharedPointer to the TabBoxClient and only
provides access to a WeakPointer which is passed to TabBox.
ClientModel is adjusted to hold a list of WeakPointers instead
of the direct pointers.

This fixes the following reproducable crash:
1. Configure both primary and secondary TabBox with different
layouts
2. Use primary TabBox
3. Close a window, best the one which used to be active
4. Use secondary TabBox
-> Crash

The reason is that the ClientModel still contains the pointer
to the deleted TabBoxClient in step 3 and while creating the
layout access to the TabBoxClient is needed to get the Client's
icon.

By using the weak pointer it can be ensured that we don't try
to dereference the deleted pointer and prevent the crash.

Cherry-Picked from 05a3420175c88c7a106a245071d4bb3a75694e00

BUG: 290482
BUG: 285747
CCBUG: 237345
FIXED-IN: 4.8.4
REVIEW: 105000
REVIEW: 105069
kwin/client.cpp
kwin/client.h
kwin/tabbox/clientmodel.cpp
kwin/tabbox/clientmodel.h
kwin/tabbox/desktopitemdelegate.cpp
kwin/tabbox/tabbox.cpp
kwin/tabbox/tabbox.h
kwin/tabbox/tabboxhandler.cpp
kwin/tabbox/tabboxhandler.h