From b81404d7e05c7a5307f490d543301fed5a12d36f Mon Sep 17 00:00:00 2001 From: liuxinhao Date: Fri, 25 Nov 2022 11:04:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E6=97=B6=E5=88=86=E9=85=8DQPalette=E7=9A=84=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-fix-Memory-leak-Fix-the-memory-leak.patch | 64 +++++++++++++++++++ kiran-qt5-integration.spec | 6 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 0001-fix-Memory-leak-Fix-the-memory-leak.patch diff --git a/0001-fix-Memory-leak-Fix-the-memory-leak.patch b/0001-fix-Memory-leak-Fix-the-memory-leak.patch new file mode 100644 index 0000000..17c02ce --- /dev/null +++ b/0001-fix-Memory-leak-Fix-the-memory-leak.patch @@ -0,0 +1,64 @@ +From eae79d3e1836ed1aa31a92e32235f33515e4e584 Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Tue, 8 Nov 2022 17:41:39 +0800 +Subject: [PATCH] fix(Memory leak): Fix the memory leak +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +修复切换主题时分配QPalette的内存泄漏 +--- + platformtheme/kiran-theme.cpp | 8 ++++++++ + style/src/render-helper.cpp | 3 ++- + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/platformtheme/kiran-theme.cpp b/platformtheme/kiran-theme.cpp +index 1955fc4..bf48006 100644 +--- a/platformtheme/kiran-theme.cpp ++++ b/platformtheme/kiran-theme.cpp +@@ -335,6 +335,7 @@ void KiranTheme::handleThemeChanged() + { + // NOTE: SchemeLoader会接收KiranAppearanceMonitor的GTK主题改变信号,重新加载配色方案 + // 此处只需等到下一个事件循环,通知QGuiApplication重新更新palette ++ + // clang-format off + QTimer::singleShot(0, [this] { + // 此事件会促使QGuiApplication重新从QPlatformTheme中获取系统级别的QPalette +@@ -356,8 +357,15 @@ void KiranTheme::handleThemeChanged() + ///FIXME: + ///1.后续看是否有更好的方式能应用更新系统级别QPalette + ///2.加入判断是否外部自定义设置Application palette,若外部自定义设置了,则应不做处理 ++ ++ QPalette* oldPalette = nullptr; ++ oldPalette = QGuiApplicationPrivate::app_pal; ++ + QGuiApplicationPrivate::app_pal = new QPalette(*palette(SystemPalette)); + ++ if( oldPalette ) ++ delete oldPalette; ++ + // 该接口原本用于windows通知窗口主题变化时使用,现用来通知调用QGuiApplicationPrivate::notifyThemeChanged + QGuiApplicationPrivate::processThemeChanged(&event); + emit qApp->paletteChanged(*palette(SystemPalette)); +diff --git a/style/src/render-helper.cpp b/style/src/render-helper.cpp +index 60f66e3..1a48998 100644 +--- a/style/src/render-helper.cpp ++++ b/style/src/render-helper.cpp +@@ -313,6 +313,7 @@ QPixmap RenderHelper::changeSVGFillColor(const QString &svgFile, const QColor &f + tinyDoc->draw(&tempPainter); + tempPainter.end(); + ++ delete tinyDoc; + return tempPixmap; + } + +@@ -381,4 +382,4 @@ void RenderHelper::renderTabBarTab(QPainter *painter, + painter->drawPath(painterPath); + } + +-} // namespace Kiran +\ No newline at end of file ++} // namespace Kiran +-- +2.33.0 + diff --git a/kiran-qt5-integration.spec b/kiran-qt5-integration.spec index 650b57d..f7dc920 100644 --- a/kiran-qt5-integration.spec +++ b/kiran-qt5-integration.spec @@ -1,10 +1,11 @@ Name: kiran-qt5-integration Version: 2.4.0 -Release: 1 +Release: 2 Summary: Kiran desktop platform integration plugin. License: MulanPSL-2.0 Source0: %{name}-%{version}.tar.gz +Patch0001: 0001-fix-Memory-leak-Fix-the-memory-leak.patch BuildRequires: cmake >= 3.2 BuildRequires: gcc-c++ @@ -60,6 +61,9 @@ make %{?_smp_mflags} %{_libdir}/pkgconfig/kiran-style-helper.pc %changelog +* Fri Nov 25 2022 liuxinhao - 2.4.0-2 +- KYOS-F:Fix the memory leak of change theme + * Mon Oct 31 2022 liuxinhao - 2.4.0-1 - KYOS-F: Modify the color table and add new color types, and support the 2.4 color block design of the control center