Skip to content

Commit

Permalink
fix: resolve 2 memory leaks
Browse files Browse the repository at this point in the history
  resolve 2 memory lesks

Log: resolve 2 memory leaks
Bug: https://pms.uniontech.com/bug-view-239575.html
  • Loading branch information
starhcq committed Jan 26, 2024
1 parent 623b966 commit 5387043
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions deepin-system-monitor-main/model/accounts_info_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ AccountsInfoModel::AccountsInfoModel(QObject *parent): QObject(parent)
this, SLOT(onSessionNew(QString, QDBusObjectPath)));
}

AccountsInfoModel::~AccountsInfoModel()
{
qDeleteAll(m_userMap.values());
m_userMap.clear();
}

void AccountsInfoModel::onUserListChanged(const QStringList &userPathList)

Check warning on line 52 in deepin-system-monitor-main/model/accounts_info_model.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'onUserListChanged' is never used.
{
updateUserList(userPathList);
Expand Down
1 change: 1 addition & 0 deletions deepin-system-monitor-main/model/accounts_info_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class AccountsInfoModel : public QObject

public:
explicit AccountsInfoModel(QObject *parent = nullptr);
virtual ~AccountsInfoModel();
void updateUserList(const QStringList &userPathList);
QList<User *> userList() const;
User::UserType getCurrentUserType() const;
Expand Down
10 changes: 5 additions & 5 deletions deepin-system-monitor-main/process/process_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ void ProcessSet::scanProcess()

for (const pid_t &pid : m_curPid) {
if(!m_prePid.contains(pid)){ //add new process pid
Process *proc = new Process(pid);
proc->readProcessSimpleInfo();
Process proc(pid);
proc.readProcessSimpleInfo();
if(!m_simpleSet.contains(pid))
m_simpleSet.insert(proc->pid(), *proc);
m_simpleSet.insert(proc.pid(), proc);

if (proc->appType() == kFilterApps && !wmwindowList->isTrayApp(proc->pid())) {
m_pidMyApps << proc->pid();
if (proc.appType() == kFilterApps && !wmwindowList->isTrayApp(proc.pid())) {
m_pidMyApps << proc.pid();
}
}
}
Expand Down

0 comments on commit 5387043

Please sign in to comment.