diff --git a/kdecoration/breezebutton.cpp b/kdecoration/breezebutton.cpp --- a/kdecoration/breezebutton.cpp +++ b/kdecoration/breezebutton.cpp @@ -55,7 +55,7 @@ setIconSize(QSize( height, height )); // connections - connect(decoration->client().data(), SIGNAL(iconChanged(QIcon)), this, SLOT(update())); + connect(decoration->client().toStrongRef().data(), SIGNAL(iconChanged(QIcon)), this, SLOT(update())); connect(decoration->settings().data(), &KDecoration2::DecorationSettings::reconfigured, this, &Button::reconfigure); connect( this, &KDecoration2::DecorationButton::hoveredChanged, this, &Button::updateAnimationState ); @@ -83,32 +83,32 @@ { case DecorationButtonType::Close: - b->setVisible( d->client().data()->isCloseable() ); - QObject::connect(d->client().data(), &KDecoration2::DecoratedClient::closeableChanged, b, &Breeze::Button::setVisible ); + b->setVisible( d->client().toStrongRef().data()->isCloseable() ); + QObject::connect(d->client().toStrongRef().data(), &KDecoration2::DecoratedClient::closeableChanged, b, &Breeze::Button::setVisible ); break; case DecorationButtonType::Maximize: - b->setVisible( d->client().data()->isMaximizeable() ); - QObject::connect(d->client().data(), &KDecoration2::DecoratedClient::maximizeableChanged, b, &Breeze::Button::setVisible ); + b->setVisible( d->client().toStrongRef().data()->isMaximizeable() ); + QObject::connect(d->client().toStrongRef().data(), &KDecoration2::DecoratedClient::maximizeableChanged, b, &Breeze::Button::setVisible ); break; case DecorationButtonType::Minimize: - b->setVisible( d->client().data()->isMinimizeable() ); - QObject::connect(d->client().data(), &KDecoration2::DecoratedClient::minimizeableChanged, b, &Breeze::Button::setVisible ); + b->setVisible( d->client().toStrongRef().data()->isMinimizeable() ); + QObject::connect(d->client().toStrongRef().data(), &KDecoration2::DecoratedClient::minimizeableChanged, b, &Breeze::Button::setVisible ); break; case DecorationButtonType::ContextHelp: - b->setVisible( d->client().data()->providesContextHelp() ); - QObject::connect(d->client().data(), &KDecoration2::DecoratedClient::providesContextHelpChanged, b, &Breeze::Button::setVisible ); + b->setVisible( d->client().toStrongRef().data()->providesContextHelp() ); + QObject::connect(d->client().toStrongRef().data(), &KDecoration2::DecoratedClient::providesContextHelpChanged, b, &Breeze::Button::setVisible ); break; case DecorationButtonType::Shade: - b->setVisible( d->client().data()->isShadeable() ); - QObject::connect(d->client().data(), &KDecoration2::DecoratedClient::shadeableChanged, b, &Breeze::Button::setVisible ); + b->setVisible( d->client().toStrongRef().data()->isShadeable() ); + QObject::connect(d->client().toStrongRef().data(), &KDecoration2::DecoratedClient::shadeableChanged, b, &Breeze::Button::setVisible ); break; case DecorationButtonType::Menu: - QObject::connect(d->client().data(), &KDecoration2::DecoratedClient::iconChanged, b, [b]() { b->update(); }); + QObject::connect(d->client().toStrongRef().data(), &KDecoration2::DecoratedClient::iconChanged, b, [b]() { b->update(); }); break; default: break; @@ -142,7 +142,7 @@ { const QRectF iconRect( geometry().topLeft(), m_iconSize ); - decoration()->client().data()->icon().paint(painter, iconRect.toRect()); + decoration()->client().toStrongRef().data()->icon().paint(painter, iconRect.toRect()); } else { @@ -404,7 +404,7 @@ } - auto c = d->client().data(); + auto c = d->client().toStrongRef().data(); if( isPressed() ) { if( type() == DecorationButtonType::Close ) return c->color( ColorGroup::Warning, ColorRole::Foreground ); diff --git a/kdecoration/breezedecoration.h b/kdecoration/breezedecoration.h --- a/kdecoration/breezedecoration.h +++ b/kdecoration/breezedecoration.h @@ -169,28 +169,28 @@ } bool Decoration::isMaximized() const - { return client().data()->isMaximized() && !m_internalSettings->drawBorderOnMaximizedWindows(); } + { return client().toStrongRef().data()->isMaximized() && !m_internalSettings->drawBorderOnMaximizedWindows(); } bool Decoration::isMaximizedHorizontally() const - { return client().data()->isMaximizedHorizontally() && !m_internalSettings->drawBorderOnMaximizedWindows(); } + { return client().toStrongRef().data()->isMaximizedHorizontally() && !m_internalSettings->drawBorderOnMaximizedWindows(); } bool Decoration::isMaximizedVertically() const - { return client().data()->isMaximizedVertically() && !m_internalSettings->drawBorderOnMaximizedWindows(); } + { return client().toStrongRef().data()->isMaximizedVertically() && !m_internalSettings->drawBorderOnMaximizedWindows(); } bool Decoration::isLeftEdge() const - { return (client().data()->isMaximizedHorizontally() || client().data()->adjacentScreenEdges().testFlag( Qt::LeftEdge ) ) && !m_internalSettings->drawBorderOnMaximizedWindows(); } + { return (client().toStrongRef().data()->isMaximizedHorizontally() || client().toStrongRef().data()->adjacentScreenEdges().testFlag( Qt::LeftEdge ) ) && !m_internalSettings->drawBorderOnMaximizedWindows(); } bool Decoration::isRightEdge() const - { return (client().data()->isMaximizedHorizontally() || client().data()->adjacentScreenEdges().testFlag( Qt::RightEdge ) ) && !m_internalSettings->drawBorderOnMaximizedWindows(); } + { return (client().toStrongRef().data()->isMaximizedHorizontally() || client().toStrongRef().data()->adjacentScreenEdges().testFlag( Qt::RightEdge ) ) && !m_internalSettings->drawBorderOnMaximizedWindows(); } bool Decoration::isTopEdge() const - { return (client().data()->isMaximizedVertically() || client().data()->adjacentScreenEdges().testFlag( Qt::TopEdge ) ) && !m_internalSettings->drawBorderOnMaximizedWindows(); } + { return (client().toStrongRef().data()->isMaximizedVertically() || client().toStrongRef().data()->adjacentScreenEdges().testFlag( Qt::TopEdge ) ) && !m_internalSettings->drawBorderOnMaximizedWindows(); } bool Decoration::isBottomEdge() const - { return (client().data()->isMaximizedVertically() || client().data()->adjacentScreenEdges().testFlag( Qt::BottomEdge ) ) && !m_internalSettings->drawBorderOnMaximizedWindows(); } + { return (client().toStrongRef().data()->isMaximizedVertically() || client().toStrongRef().data()->adjacentScreenEdges().testFlag( Qt::BottomEdge ) ) && !m_internalSettings->drawBorderOnMaximizedWindows(); } bool Decoration::hideTitleBar() const - { return m_internalSettings->hideTitleBar() && !client().data()->isShaded(); } + { return m_internalSettings->hideTitleBar() && !client().toStrongRef().data()->isShaded(); } } diff --git a/kdecoration/breezedecoration.cpp b/kdecoration/breezedecoration.cpp --- a/kdecoration/breezedecoration.cpp +++ b/kdecoration/breezedecoration.cpp @@ -192,7 +192,7 @@ QColor Decoration::titleBarColor() const { - auto c = client().data(); + auto c = client().toStrongRef().data(); if( hideTitleBar() ) return c->color( ColorGroup::Inactive, ColorRole::TitleBar ); else if( m_animation->state() == QAbstractAnimation::Running ) { @@ -208,7 +208,7 @@ QColor Decoration::outlineColor() const { - auto c( client().data() ); + auto c( client().toStrongRef().data() ); if( !m_internalSettings->drawTitleBarSeparator() ) return QColor(); if( m_animation->state() == QAbstractAnimation::Running ) { @@ -223,7 +223,7 @@ QColor Decoration::fontColor() const { - auto c = client().data(); + auto c = client().toStrongRef().data(); if( m_animation->state() == QAbstractAnimation::Running ) { return KColorUtils::mix( @@ -237,7 +237,7 @@ //________________________________________________________________ void Decoration::init() { - auto c = client().data(); + auto c = client().toStrongRef().data(); // active state change animation // It is important start and end value are of the same type, hence 0.0 and not just 0 @@ -297,7 +297,7 @@ void Decoration::updateTitleBar() { auto s = settings(); - auto c = client().data(); + auto c = client().toStrongRef().data(); const bool maximized = isMaximized(); const int width = maximized ? c->width() : c->width() - 2*s->largeSpacing()*Metrics::TitleBar_SideMargin; const int height = maximized ? borderTop() : borderTop() - s->smallSpacing()*Metrics::TitleBar_TopMargin; @@ -312,7 +312,7 @@ if( m_internalSettings->animationsEnabled() ) { - auto c = client().data(); + auto c = client().toStrongRef().data(); m_animation->setDirection( c->isActive() ? QAbstractAnimation::Forward : QAbstractAnimation::Backward ); if( m_animation->state() != QAbstractAnimation::Running ) m_animation->start(); @@ -326,7 +326,7 @@ //________________________________________________________________ void Decoration::updateSizeGripVisibility() { - auto c = client().data(); + auto c = client().toStrongRef().data(); if( m_sizeGrip ) { m_sizeGrip->setVisible( c->isResizeable() && !isMaximized() && !c->isShaded() ); } } @@ -393,7 +393,7 @@ //________________________________________________________________ void Decoration::recalculateBorders() { - auto c = client().data(); + auto c = client().toStrongRef().data(); auto s = settings(); // left, right and bottom borders @@ -521,7 +521,7 @@ void Decoration::paint(QPainter *painter, const QRect &repaintRegion) { // TODO: optimize based on repaintRegion - auto c = client().data(); + auto c = client().toStrongRef().data(); auto s = settings(); // paint background @@ -562,7 +562,7 @@ //________________________________________________________________ void Decoration::paintTitleBar(QPainter *painter, const QRect &repaintRegion) { - const auto c = client().data(); + const auto c = client().toStrongRef().data(); const QRect titleRect(QPoint(0, 0), QSize(size().width(), borderTop())); if ( !titleRect.intersects(repaintRegion) ) return; @@ -660,7 +660,7 @@ if( hideTitleBar() ) return qMakePair( QRect(), Qt::AlignCenter ); else { - auto c = client().data(); + auto c = client().toStrongRef().data(); const int leftOffset = m_leftButtons->buttons().isEmpty() ? Metrics::TitleBar_SideMargin*settings()->smallSpacing(): m_leftButtons->geometry().x() + m_leftButtons->geometry().width() + Metrics::TitleBar_SideMargin*settings()->smallSpacing(); @@ -804,7 +804,7 @@ if( !QX11Info::isPlatformX11() ) return; // access client - auto c = client().data(); + auto c = client().toStrongRef().data(); if( !c ) return; if( c->windowId() != 0 ) diff --git a/kdecoration/breezesettingsprovider.cpp b/kdecoration/breezesettingsprovider.cpp --- a/kdecoration/breezesettingsprovider.cpp +++ b/kdecoration/breezesettingsprovider.cpp @@ -75,7 +75,7 @@ QString className; // get the client - auto client = decoration->client().data(); + auto client = decoration->client().toStrongRef().data(); foreach( auto internalSettings, m_exceptions ) { diff --git a/kdecoration/breezesizegrip.cpp b/kdecoration/breezesizegrip.cpp --- a/kdecoration/breezesizegrip.cpp +++ b/kdecoration/breezesizegrip.cpp @@ -62,7 +62,7 @@ updatePosition(); // connections - auto c = decoration->client().data(); + auto c = decoration->client().toStrongRef().data(); connect( c, &KDecoration2::DecoratedClient::widthChanged, this, &SizeGrip::updatePosition ); connect( c, &KDecoration2::DecoratedClient::heightChanged, this, &SizeGrip::updatePosition ); connect( c, &KDecoration2::DecoratedClient::activeChanged, this, &SizeGrip::updateActiveState ); @@ -99,7 +99,7 @@ #if BREEZE_HAVE_X11 if( !QX11Info::isPlatformX11() ) return; - auto c = m_decoration.data()->client().data(); + auto c = m_decoration.data()->client().toStrongRef().data(); xcb_window_t windowId = c->windowId(); if( windowId ) @@ -191,7 +191,7 @@ #if BREEZE_HAVE_X11 if( !QX11Info::isPlatformX11() ) return; - auto c = m_decoration.data()->client().data(); + auto c = m_decoration.data()->client().toStrongRef().data(); QPoint position( c->width() - GripSize - Offset, c->height() - GripSize - Offset ); @@ -213,7 +213,7 @@ auto connection( QX11Info::connection() ); // client - auto c = m_decoration.data()->client().data(); + auto c = m_decoration.data()->client().toStrongRef().data(); /* get root position matching position