[kwin/kcmrules] Use a pointer for the KWindowInfo member variable

The reason for this change is that the default ctor of KWindowInfo
creates a broken object. Calling any method in it will result in a
crush. Thus it is scheduled for removal in kwindowsystem framework
causing this code to no longer compile.

The solution is to use a pointer and set it to null as long as the
window has not been detected yet. To ensure that this doesn't fail
badly an assert is added to the getter in DetectWidget.
This commit is contained in:
Martin Gräßlin 2014-01-30 10:35:35 +01:00
parent c96df87475
commit 823222567e
2 changed files with 11 additions and 10 deletions

View file

@ -78,19 +78,19 @@ void DetectDialog::readWindow(WId w)
emit detectionDone(false); emit detectionDone(false);
return; return;
} }
info = KWindowSystem::windowInfo(w, -1U, -1U); // read everything info.reset(new KWindowInfo(w, -1U, -1U)); // read everything
if (!info.valid()) { if (!info->valid()) {
emit detectionDone(false); emit detectionDone(false);
return; return;
} }
wmclass_class = info.windowClassClass(); wmclass_class = info->windowClassClass();
wmclass_name = info.windowClassName(); wmclass_name = info->windowClassName();
role = info.windowRole(); role = info->windowRole();
type = info.windowType(NET::NormalMask | NET::DesktopMask | NET::DockMask type = info->windowType(NET::NormalMask | NET::DesktopMask | NET::DockMask
| NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask
| NET::UtilityMask | NET::SplashMask); | NET::UtilityMask | NET::SplashMask);
title = info.name(); title = info->name();
machine = info.clientMachine(); machine = info->clientMachine();
executeDialog(); executeDialog();
} }

View file

@ -77,13 +77,14 @@ private:
QByteArray machine; QByteArray machine;
DetectWidget* widget; DetectWidget* widget;
QScopedPointer<QDialog> grabber; QScopedPointer<QDialog> grabber;
KWindowInfo info; QScopedPointer<KWindowInfo> info;
}; };
inline inline
const KWindowInfo& DetectDialog::windowInfo() const const KWindowInfo& DetectDialog::windowInfo() const
{ {
return info; Q_ASSERT(!info.isNull());
return *(info.data());
} }
} // namespace } // namespace