Fix calling virtual methods in Window destructor
When a window is removed from the deleted list, some effects can perform cleanup. In its turn, it means that they can call some Window methods. If those methods happen to be virtual, kwin can crash because calling virtual methods in the destructor of a base class has undefined behavior.
This commit is contained in:
parent
8c87cd913e
commit
baac61b8e5
1 changed files with 6 additions and 5 deletions
|
@ -104,9 +104,6 @@ Window::Window()
|
|||
|
||||
Window::~Window()
|
||||
{
|
||||
if (m_deleted) {
|
||||
workspace()->removeDeleted(this);
|
||||
}
|
||||
if (m_tile) {
|
||||
m_tile->removeWindow(this);
|
||||
}
|
||||
|
@ -121,9 +118,13 @@ void Window::ref()
|
|||
void Window::unref()
|
||||
{
|
||||
--m_refCount;
|
||||
if (m_refCount == 0) {
|
||||
delete this;
|
||||
if (m_refCount) {
|
||||
return;
|
||||
}
|
||||
if (m_deleted) {
|
||||
workspace()->removeDeleted(this);
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const Window *window)
|
||||
|
|
Loading…
Reference in a new issue