From 4b66c244fc2ca167e550bc74d3c9f9ba87789ac9 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 17 Mar 2021 21:23:56 +0800 Subject: [PATCH] Minor improvement We could return in paintBackground(), so we may miss to call restore() Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- qtacryliceffecthelper.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/qtacryliceffecthelper.cpp b/qtacryliceffecthelper.cpp index 0a25ca9..b8d396c 100644 --- a/qtacryliceffecthelper.cpp +++ b/qtacryliceffecthelper.cpp @@ -177,14 +177,10 @@ void QtAcrylicEffectHelper::paintWindowBackground(QPainter *painter, const QRegi if (!checkWindow()) { return; } - // TODO: should we limit it to Win32 only? Or should we do something about the - // acrylic brush instead? - if (Utilities::disableExtraProcessingForBlur()) { - return; - } painter->save(); painter->setClipRegion(clip); paintBackground(painter, clip.boundingRect()); + painter->restore(); } void QtAcrylicEffectHelper::paintWindowBackground(QPainter *painter, const QRect &rect) @@ -197,14 +193,10 @@ void QtAcrylicEffectHelper::paintWindowBackground(QPainter *painter, const QRect if (!checkWindow()) { return; } - // TODO: should we limit it to Win32 only? Or should we do something about the - // acrylic brush instead? - if (Utilities::disableExtraProcessingForBlur()) { - return; - } painter->save(); painter->setClipRegion({rect}); paintBackground(painter, rect); + painter->restore(); } void QtAcrylicEffectHelper::paintBackground(QPainter *painter, const QRect &rect) @@ -217,6 +209,11 @@ void QtAcrylicEffectHelper::paintBackground(QPainter *painter, const QRect &rect if (!checkWindow()) { return; } + // TODO: should we limit it to Win32 only? Or should we do something about the + // acrylic brush instead? + if (Utilities::disableExtraProcessingForBlur()) { + return; + } if (Utilities::shouldUseTraditionalBlur()) { const QPainter::CompositionMode mode = painter->compositionMode(); painter->setCompositionMode(QPainter::CompositionMode_Clear); @@ -230,7 +227,6 @@ void QtAcrylicEffectHelper::paintBackground(QPainter *painter, const QRect &rect painter->setCompositionMode(QPainter::CompositionMode_SourceOver); painter->setOpacity(1); painter->fillRect(rect, m_acrylicBrush); - painter->restore(); } void QtAcrylicEffectHelper::paintWindowFrame(QPainter *painter, const QRect &rect)