diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | agent/polkit-tqt-agent-session.cpp | 10 | ||||
-rw-r--r-- | core/polkit-tqt-authority.cpp | 60 | ||||
-rw-r--r-- | core/polkit-tqt-details.cpp | 59 | ||||
-rw-r--r-- | core/polkit-tqt-identity.cpp | 25 | ||||
-rw-r--r-- | core/polkit-tqt-subject.cpp | 25 |
6 files changed, 130 insertions, 51 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index fb52aa96c..ba276505b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,6 @@ cmake_minimum_required( VERSION 2.8.12 ) include( FindPkgConfig ) include( CheckCXXSourceCompiles ) include( CheckSymbolExists ) - -set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ) include( TDEMacros ) diff --git a/agent/polkit-tqt-agent-session.cpp b/agent/polkit-tqt-agent-session.cpp index b65bb90b2..eb8460be4 100644 --- a/agent/polkit-tqt-agent-session.cpp +++ b/agent/polkit-tqt-agent-session.cpp @@ -62,7 +62,10 @@ void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authoriz emit(session)->completed(gained_authorization); //free session here as polkit documentation asks - g_object_unref(session->d->polkitAgentSession); + if (session->d->polkitAgentSession) + { + g_object_unref(session->d->polkitAgentSession); + } session->d->polkitAgentSession = 0; } @@ -171,7 +174,10 @@ void AsyncResult::setCompleted() } g_simple_async_result_complete(d->result); // Assure that completed won't be called twice - g_object_unref(d->result); + if (d->result) + { + g_object_unref(d->result); + } d->result = NULL; } diff --git a/core/polkit-tqt-authority.cpp b/core/polkit-tqt-authority.cpp index 3bdfe9bf9..d8e4aa297 100644 --- a/core/polkit-tqt-authority.cpp +++ b/core/polkit-tqt-authority.cpp @@ -67,7 +67,10 @@ ActionDescription::List actionsToListAndFree(GList *glist) { gpointer i = glist2->data; result.append(ActionDescription(static_cast<PolkitActionDescription*>(i))); - g_object_unref(i); + if (i) + { + g_object_unref(i); + } } g_list_free(glist); return result; @@ -121,14 +124,38 @@ class Authority::Private Authority::Private::~Private() { - g_object_unref(m_checkAuthorizationCancellable); - g_object_unref(m_enumerateActionsCancellable); - g_object_unref(m_registerAuthenticationAgentCancellable); - g_object_unref(m_unregisterAuthenticationAgentCancellable); - g_object_unref(m_authenticationAgentResponseCancellable); - g_object_unref(m_enumerateTemporaryAuthorizationsCancellable); - g_object_unref(m_revokeTemporaryAuthorizationsCancellable); - g_object_unref(m_revokeTemporaryAuthorizationCancellable); + if (m_checkAuthorizationCancellable) + { + g_object_unref(m_checkAuthorizationCancellable); + } + if (m_enumerateActionsCancellable) + { + g_object_unref(m_enumerateActionsCancellable); + } + if (m_registerAuthenticationAgentCancellable) + { + g_object_unref(m_registerAuthenticationAgentCancellable); + } + if (m_unregisterAuthenticationAgentCancellable) + { + g_object_unref(m_unregisterAuthenticationAgentCancellable); + } + if (m_authenticationAgentResponseCancellable) + { + g_object_unref(m_authenticationAgentResponseCancellable); + } + if (m_enumerateTemporaryAuthorizationsCancellable) + { + g_object_unref(m_enumerateTemporaryAuthorizationsCancellable); + } + if (m_revokeTemporaryAuthorizationsCancellable) + { + g_object_unref(m_revokeTemporaryAuthorizationsCancellable); + } + if (m_revokeTemporaryAuthorizationCancellable) + { + g_object_unref(m_revokeTemporaryAuthorizationCancellable); + } } void Authority::Private::init() @@ -185,7 +212,10 @@ Authority::Authority(TQObject *parent) : TQObject(parent), d(new Private(this)) Authority::~Authority() { - g_object_unref(d->pkAuthority); + if (d->pkAuthority) + { + g_object_unref(d->pkAuthority); + } delete d; } @@ -634,7 +664,10 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2)) { result.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data)); - g_object_unref(glist2->data); + if (glist2->data) + { + g_object_unref(glist2->data); + } } g_list_free(glist); return result; @@ -667,7 +700,10 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2)) { res.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data)); - g_object_unref(glist2->data); + if (glist2->data) + { + g_object_unref(glist2->data); + } } g_list_free(glist); emit authority->enumerateTemporaryAuthorizationsFinished(res); diff --git a/core/polkit-tqt-details.cpp b/core/polkit-tqt-details.cpp index 8fd8efa14..245ce2577 100644 --- a/core/polkit-tqt-details.cpp +++ b/core/polkit-tqt-details.cpp @@ -38,22 +38,31 @@ class Details::Data : public TQShared { public: Data() : details(NULL) - { - } + { + } Data(const Data &other) : details(other.details) { - g_object_ref(details); + if (details) + { + g_object_ref(details); + } } Data(PolkitDetails *_details) : details(_details) { - g_object_ref(details); + if (details) + { + g_object_ref(details); + } } ~Data() { - g_object_unref(details); + if (details) + { + g_object_unref(details); + } } PolkitDetails *details; @@ -65,7 +74,7 @@ class Details::Data : public TQShared Details::Details() : d(new Data) { - d->details = polkit_details_new(); + d->details = polkit_details_new(); } Details::Details(PolkitDetails *pkDetails) : d(new Data(pkDetails)) @@ -101,33 +110,33 @@ Details::~Details() TQString Details::lookup(const TQString &key) const { - const gchar *result = polkit_details_lookup(d->details, key.utf8().data()); - if (result != NULL) - { - return TQString::fromUtf8(result); - } - else - { - return TQString::null; - } + const gchar *result = polkit_details_lookup(d->details, key.utf8().data()); + if (result != NULL) + { + return TQString::fromUtf8(result); + } + else + { + return TQString::null; + } } void Details::insert(const TQString &key, const TQString &value) { - polkit_details_insert(d->details, key.utf8().data(), value.utf8().data()); + polkit_details_insert(d->details, key.utf8().data(), value.utf8().data()); } TQStringList Details::keys() const { - gchar **result = polkit_details_get_keys(d->details); - TQStringList list; - int len = g_strv_length(result); - for (int i = 0; i < len; i++) - { - list.append(TQString::fromUtf8(result[i])); - } - g_strfreev(result); - return list; + gchar **result = polkit_details_get_keys(d->details); + TQStringList list; + int len = g_strv_length(result); + for (int i = 0; i < len; i++) + { + list.append(TQString::fromUtf8(result[i])); + } + g_strfreev(result); + return list; } } diff --git a/core/polkit-tqt-identity.cpp b/core/polkit-tqt-identity.cpp index 2649e21f5..1415d5d7f 100644 --- a/core/polkit-tqt-identity.cpp +++ b/core/polkit-tqt-identity.cpp @@ -42,17 +42,26 @@ class Identity::Data : public TQShared Data(const Data &other) : identity(other.identity) { - g_object_ref(identity); + if (identity) + { + g_object_ref(identity); + } } Data(PolkitIdentity *_identity) : identity(_identity) { - g_object_ref(identity); + if (identity) + { + g_object_ref(identity); + } } ~Data() { - g_object_unref(identity); + if (identity) + { + g_object_unref(identity); + } } PolkitIdentity *identity; @@ -111,9 +120,15 @@ void Identity::setIdentity(PolkitIdentity *identity) { if (d->identity != identity) { - g_object_unref(d->identity); + if (d->identity) + { + g_object_unref(d->identity); + } d->identity = identity; - g_object_ref(identity); + if (d->identity) + { + g_object_ref(d->identity); + } } } diff --git a/core/polkit-tqt-subject.cpp b/core/polkit-tqt-subject.cpp index 1fa8d710f..3d9e99b7a 100644 --- a/core/polkit-tqt-subject.cpp +++ b/core/polkit-tqt-subject.cpp @@ -42,17 +42,26 @@ class Subject::Data : public TQShared Data(const Data &other) : subject(other.subject) { - g_object_ref(subject); + if (subject) + { + g_object_ref(subject); + } } Data(PolkitSubject *_subject) : subject(_subject) { - g_object_ref(subject); + if (subject) + { + g_object_ref(subject); + } } ~Data() { - g_object_unref(subject); + if (subject) + { + g_object_unref(subject); + } } PolkitSubject *subject; @@ -111,9 +120,15 @@ void Subject::setSubject(PolkitSubject *subject) { if (d->subject != subject) { - g_object_unref(d->subject); + if (d->subject) + { + g_object_unref(d->subject); + } d->subject = subject; - g_object_ref(subject); + if (d->subject) + { + g_object_ref(d->subject); + } } } |