Guarded g_object_ref/unref to avoid warning messages when the pointer is NULL.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 3 years ago
parent 8b90718b72
commit 5a4577efe2
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -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 )

@ -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
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
if (d->result)
{
g_object_unref(d->result);
}
d->result = NULL;
}

@ -67,8 +67,11 @@ ActionDescription::List actionsToListAndFree(GList *glist)
{
gpointer i = glist2->data;
result.append(ActionDescription(static_cast<PolkitActionDescription*>(i)));
if (i)
{
g_object_unref(i);
}
}
g_list_free(glist);
return result;
}
@ -120,16 +123,40 @@ class Authority::Private
};
Authority::Private::~Private()
{
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()
{
@ -184,8 +211,11 @@ Authority::Authority(TQObject *parent) : TQObject(parent), d(new Private(this))
}
Authority::~Authority()
{
if (d->pkAuthority)
{
g_object_unref(d->pkAuthority);
}
delete d;
}
@ -634,8 +664,11 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con
for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2))
{
result.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
if (glist2->data)
{
g_object_unref(glist2->data);
}
}
g_list_free(glist);
return result;
}
@ -667,8 +700,11 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec
for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2))
{
res.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
if (glist2->data)
{
g_object_unref(glist2->data);
}
}
g_list_free(glist);
emit authority->enumerateTemporaryAuthorizationsFinished(res);
}

@ -42,19 +42,28 @@ class Details::Data : public TQShared
}
Data(const Data &other) : details(other.details)
{
if (details)
{
g_object_ref(details);
}
}
Data(PolkitDetails *_details) : details(_details)
{
if (details)
{
g_object_ref(details);
}
}
~Data()
{
if (details)
{
g_object_unref(details);
}
}
PolkitDetails *details;
};

@ -41,19 +41,28 @@ class Identity::Data : public TQShared
}
Data(const Data &other) : identity(other.identity)
{
if (identity)
{
g_object_ref(identity);
}
}
Data(PolkitIdentity *_identity) : identity(_identity)
{
if (identity)
{
g_object_ref(identity);
}
}
~Data()
{
if (identity)
{
g_object_unref(identity);
}
}
PolkitIdentity *identity;
};
@ -110,10 +119,16 @@ PolkitIdentity* Identity::identity() const
void Identity::setIdentity(PolkitIdentity *identity)
{
if (d->identity != identity)
{
if (d->identity)
{
g_object_unref(d->identity);
}
d->identity = identity;
g_object_ref(identity);
if (d->identity)
{
g_object_ref(d->identity);
}
}
}

@ -41,19 +41,28 @@ class Subject::Data : public TQShared
}
Data(const Data &other) : subject(other.subject)
{
if (subject)
{
g_object_ref(subject);
}
}
Data(PolkitSubject *_subject) : subject(_subject)
{
if (subject)
{
g_object_ref(subject);
}
}
~Data()
{
if (subject)
{
g_object_unref(subject);
}
}
PolkitSubject *subject;
};
@ -110,10 +119,16 @@ PolkitSubject* Subject::subject() const
void Subject::setSubject(PolkitSubject *subject)
{
if (d->subject != subject)
{
if (d->subject)
{
g_object_unref(d->subject);
}
d->subject = subject;
g_object_ref(subject);
if (d->subject)
{
g_object_ref(d->subject);
}
}
}

Loading…
Cancel
Save