Changeset View
Changeset View
Standalone View
Standalone View
debian/patches/better-memory-handling.diff
- This file was added.
Author: Palo Kisa <palo.kisa@gmail.com> | |||||
Origin: https://github.com/lxqt/lxqt-policykit/commit/fc57746b8ccb62536ef158a1b01b47ef327c7fbd.patch | |||||
Description: PolicykitAgent: Add better memory handling | |||||
Don't delete the session in the slot as we can't be sure if any other | |||||
activity is done on the sender object after our slot finishes. | |||||
Bug: https://github.com/lxqt/lxqt-policykit/issues/105 | |||||
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxqt-policykit/+bug/1875774 | |||||
Last-Update: 2021-09-06 | |||||
--- | |||||
src/policykitagent.cpp | 13 ++++++++++--- | |||||
src/policykitagent.h | 3 +++ | |||||
2 files changed, 13 insertions(+), 3 deletions(-) | |||||
--- a/src/policykitagent.cpp | |||||
+++ b/src/policykitagent.cpp | |||||
@@ -59,6 +59,14 @@ PolicykitAgent::~PolicykitAgent() | |||||
if(m_infobox) { | |||||
delete m_infobox; | |||||
} | |||||
+ deleteSessions(); | |||||
+} | |||||
+ | |||||
+void PolicykitAgent::deleteSessions() | |||||
+{ | |||||
+ for (auto i = m_SessionIdentity.begin(), i_e = m_SessionIdentity.end(); i != i_e; ++i) | |||||
+ delete i.key(); | |||||
+ m_SessionIdentity.clear(); | |||||
} | |||||
@@ -76,7 +84,7 @@ void PolicykitAgent::initiateAuthenticat | |||||
return; | |||||
} | |||||
m_inProgress = true; | |||||
- m_SessionIdentity.clear(); | |||||
+ deleteSessions(); | |||||
if (m_gui) | |||||
{ | |||||
@@ -138,7 +146,7 @@ void PolicykitAgent::completed(bool gain | |||||
Q_ASSERT(session); | |||||
Q_ASSERT(m_gui); | |||||
- if (m_gui->identity() == m_SessionIdentity[session].toString()) | |||||
+ if (m_inProgress && m_gui->identity() == m_SessionIdentity[session].toString()) | |||||
{ | |||||
if (!gainedAuthorization) | |||||
{ | |||||
@@ -154,7 +162,6 @@ void PolicykitAgent::completed(bool gain | |||||
m_infobox->hide(); | |||||
delete m_infobox; | |||||
} | |||||
- delete session; | |||||
} | |||||
void PolicykitAgent::showError(const QString &text) | |||||
--- a/src/policykitagent.h | |||||
+++ b/src/policykitagent.h | |||||
@@ -68,6 +68,9 @@ public slots: | |||||
void showError(const QString &text); | |||||
void showInfo(const QString &text); | |||||
+protected: | |||||
+ void deleteSessions(); | |||||
+ | |||||
private: | |||||
bool m_inProgress; | |||||
PolicykitAgentGUI * m_gui; |