From 23dc81334a9e05e3384768218ded8607fa9a80a1 Mon Sep 17 00:00:00 2001 From: winnerym Date: Wed, 12 Apr 2023 09:46:15 +0800 Subject: [PATCH] fix(free mem): release QSettings pointer memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 释放qsettings指针内存 Log: I5M3SK 内存泄露 --- screensaver/screensaver.cpp | 18 ++++++++++++------ screensaver/screensaver.h | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/screensaver/screensaver.cpp b/screensaver/screensaver.cpp index 5c06727..fb5acd0 100644 --- a/screensaver/screensaver.cpp +++ b/screensaver/screensaver.cpp @@ -637,6 +637,10 @@ void Screensaver::setUpdateCenterWidget() QString languageDirPath=cwdPath+"language/"; QString defaultLanguageFilePath=languageDirPath+"screensaver-en_US.ini"; qDebug()<<"homePath="<childGroups(); @@ -1197,6 +1201,8 @@ void Screensaver::setPreviewText(bool bVisible) void Screensaver::setCenterWidget() { + if (!qsettings) + return ; QStringList qlist = qsettings->childGroups(); if(qlist.count()<1) return; diff --git a/screensaver/screensaver.h b/screensaver/screensaver.h index 39bb7a1..e010fe1 100644 --- a/screensaver/screensaver.h +++ b/screensaver/screensaver.h @@ -111,7 +111,7 @@ private: QPushButton *settingsButton; QPushButton *WallpaperButton; QWidget *buttonWidget; - QSettings *qsettings; + QSettings *qsettings = nullptr; MBackground *m_background;