effects: Guard against InputMethod being nullptr or not enabled

Apparently InputMethod can be nullptr, in which case we end up
dereferencing nullptr when we try to get the input panel.
This commit is contained in:
Arjen Hiemstra 2022-03-11 10:16:30 +01:00
parent 44184f4700
commit bd920fb28c

View file

@ -1814,6 +1814,10 @@ qreal EffectsHandlerImpl::renderTargetScale() const
KWin::EffectWindow *EffectsHandlerImpl::inputPanel() const
{
if (!InputMethod::self() || !InputMethod::self()->isEnabled()) {
return nullptr;
}
auto panel = InputMethod::self()->panel();
if (panel) {
return panel->effectWindow();
@ -1823,6 +1827,10 @@ KWin::EffectWindow *EffectsHandlerImpl::inputPanel() const
bool EffectsHandlerImpl::isInputPanelOverlay() const
{
if (!InputMethod::self() || !InputMethod::self()->isEnabled()) {
return true;
}
auto panel = InputMethod::self()->panel();
if (panel) {
return panel->mode() == InputPanelV1Client::Overlay;