From 2656bf02e19f282ee963309a48ba497873e9fa40 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Fri, 6 Aug 2021 11:57:43 +0200
Subject: [PATCH] Require glib 2.36 and remove "do nothing" g_type_init

g_type_init deprecated and a no-op since glib 2.36

glib 2.36 was released in 2013, i think it's a reasonable min dependency
nowadays
---
 CMakeLists.txt                            | 2 +-
 agent/polkitqt1-agent-listener.cpp        | 4 ----
 agent/polkitqtlistener.cpp                | 1 -
 core/polkitqt1-actiondescription.cpp      | 2 --
 core/polkitqt1-authority.cpp              | 2 --
 core/polkitqt1-details.cpp                | 2 --
 core/polkitqt1-identity.cpp               | 2 --
 core/polkitqt1-subject.cpp                | 5 -----
 core/polkitqt1-temporaryauthorization.cpp | 1 -
 examples/agent/pkagentexample.cpp         | 2 --
 10 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a82f8cb..dd0977e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,7 +40,7 @@ set(POLKITQT-1_INCLUDE_PATH "polkit-qt5-1")
 
 pkg_check_modules(POLKIT_GOBJECT polkit-gobject-1 REQUIRED IMPORTED_TARGET)
 pkg_check_modules(POLKIT_AGENT polkit-agent-1 REQUIRED IMPORTED_TARGET)
-pkg_check_modules(GLIB2 glib-2.0 REQUIRED IMPORTED_TARGET)
+pkg_check_modules(GLIB2 glib-2.0>=2.36 REQUIRED IMPORTED_TARGET)
 pkg_check_modules(GOBJECT gobject-2.0 REQUIRED IMPORTED_TARGET)
 
 add_definitions(-DQT_NO_KEYWORDS)
diff --git a/agent/polkitqt1-agent-listener.cpp b/agent/polkitqt1-agent-listener.cpp
index cb99299..27348b1 100644
--- a/agent/polkitqt1-agent-listener.cpp
+++ b/agent/polkitqt1-agent-listener.cpp
@@ -34,8 +34,6 @@ public:
 Listener::Listener(QObject *parent)
         : QObject(parent), d(new ListenerPrivate)
 {
-    g_type_init();
-
     d->listener = polkit_qt_listener_new();
 
     qDebug() << "New PolkitAgentListener " << d->listener;
@@ -46,8 +44,6 @@ Listener::Listener(QObject *parent)
 Listener::Listener(PolkitAgentListener *listener, QObject *parent)
         : QObject(parent), d(new ListenerPrivate)
 {
-    g_type_init();
-
     d->listener = listener;
     
     if (d->listener != nullptr) {
diff --git a/agent/polkitqtlistener.cpp b/agent/polkitqtlistener.cpp
index 69c4f8a..e8713b5 100644
--- a/agent/polkitqtlistener.cpp
+++ b/agent/polkitqtlistener.cpp
@@ -49,7 +49,6 @@ G_DEFINE_TYPE(PolkitQtListener, polkit_qt_listener, POLKIT_AGENT_TYPE_LISTENER)
 
 static void polkit_qt_listener_init(PolkitQtListener *listener)
 {
-    g_type_init();
 }
 
 static void polkit_qt_listener_finalize(GObject *object)
diff --git a/core/polkitqt1-actiondescription.cpp b/core/polkitqt1-actiondescription.cpp
index f865c37..c08f5c4 100644
--- a/core/polkitqt1-actiondescription.cpp
+++ b/core/polkitqt1-actiondescription.cpp
@@ -55,8 +55,6 @@ ActionDescription::ActionDescription()
 ActionDescription::ActionDescription(PolkitActionDescription *polkitActionDescription)
         : d(new Data)
 {
-    g_type_init();
-
     d->actionId = QString::fromUtf8(polkit_action_description_get_action_id(polkitActionDescription));
     d->description = QString::fromUtf8(polkit_action_description_get_description(polkitActionDescription));
     d->message = QString::fromUtf8(polkit_action_description_get_message(polkitActionDescription));
diff --git a/core/polkitqt1-authority.cpp b/core/polkitqt1-authority.cpp
index a891b92..73dd97e 100644
--- a/core/polkitqt1-authority.cpp
+++ b/core/polkitqt1-authority.cpp
@@ -172,8 +172,6 @@ void Authority::Private::init()
     QDBusError error;
     QDBusError dbus_error;
 
-    g_type_init();
-
     m_systemBus = new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SystemBus,
                                                                     QStringLiteral("polkit_qt_system_bus")));
 
diff --git a/core/polkitqt1-details.cpp b/core/polkitqt1-details.cpp
index b9494f0..ba107b1 100644
--- a/core/polkitqt1-details.cpp
+++ b/core/polkitqt1-details.cpp
@@ -39,14 +39,12 @@ public:
 Details::Details()
         : d(new Data)
 {
-    g_type_init();
     d->polkitDetails = polkit_details_new();
 }
 
 Details::Details(PolkitDetails *pkDetails)
         : d(new Data)
 {
-    g_type_init();
     d->polkitDetails = pkDetails;
     
     if (d->polkitDetails != nullptr) {
diff --git a/core/polkitqt1-identity.cpp b/core/polkitqt1-identity.cpp
index 2489c33..0924c5a 100644
--- a/core/polkitqt1-identity.cpp
+++ b/core/polkitqt1-identity.cpp
@@ -39,13 +39,11 @@ public:
 Identity::Identity()
         : d(new Data)
 {
-    g_type_init();
 }
 
 Identity::Identity(PolkitIdentity *polkitIdentity)
         : d(new Data)
 {
-    g_type_init();
     d->identity = polkitIdentity;
 
     if (d->identity) {
diff --git a/core/polkitqt1-subject.cpp b/core/polkitqt1-subject.cpp
index 3d86437..3dae3bd 100644
--- a/core/polkitqt1-subject.cpp
+++ b/core/polkitqt1-subject.cpp
@@ -39,13 +39,11 @@ public:
 Subject::Subject()
         : d(new Data)
 {
-    g_type_init();
 }
 
 Subject::Subject(PolkitSubject *subject)
         : d(new Data)
 {
-    g_type_init();
     d->subject = subject;
     
     if (d->subject != nullptr) {
@@ -95,9 +93,6 @@ QString Subject::toString() const
 
 Subject Subject::fromString(const QString &string)
 {
-    // should be in polkit library!!! but for strange reason it's necessary to have it here
-    g_type_init();
-
     Subject subject;
     GError *error = nullptr;
     subject.d->subject = polkit_subject_from_string(string.toUtf8().data(), &error);
diff --git a/core/polkitqt1-temporaryauthorization.cpp b/core/polkitqt1-temporaryauthorization.cpp
index 64209ff..ae40f3b 100644
--- a/core/polkitqt1-temporaryauthorization.cpp
+++ b/core/polkitqt1-temporaryauthorization.cpp
@@ -38,7 +38,6 @@ public:
 TemporaryAuthorization::TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization)
         : d(new Data)
 {
-    g_type_init();
     d->id = QString::fromUtf8(polkit_temporary_authorization_get_id(pkTemporaryAuthorization));
     d->actionId = QString::fromUtf8(polkit_temporary_authorization_get_action_id(pkTemporaryAuthorization));
     d->subject = Subject::fromString(polkit_subject_to_string(polkit_temporary_authorization_get_subject(pkTemporaryAuthorization)));
diff --git a/examples/agent/pkagentexample.cpp b/examples/agent/pkagentexample.cpp
index 8b1128b..da555c7 100644
--- a/examples/agent/pkagentexample.cpp
+++ b/examples/agent/pkagentexample.cpp
@@ -9,8 +9,6 @@
 PkAgentExample::PkAgentExample(int &argc, char **argv)
         : QCoreApplication(argc, argv)
 {
-    g_type_init();
-
     PolkitQt1::UnixSessionSubject session(getpid());
 
     m_listener.registerListener(session, "/org/kde/PolicyKit1/AuthenticationAgent");
-- 
GitLab

