Skip to content

Commit 365f7da

Browse files
[EZGL][Warnings] Removed Use of Deprecated Enum
The G_APPLICATION_FLAGS_NONE enum was deprecated in recent versions of GLib and was replaced by G_APPLICATION_DEFAULT_FLAGS; however, the replacement enum was not introduced until GLib 2.74. Added code that will select which enum to use depending on the GLib version to keep EZGL backwards compatible.
1 parent a6b2f89 commit 365f7da

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

libs/EXTERNAL/libezgl/src/application.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818

1919
#include "ezgl/application.hpp"
2020

21+
// GLib deprecated G_APPLICATION_FLAGS_NONE and replaced it with G_APPLICATION_DEFAULT_FLAGS,
22+
// however, this enum was not introduced until GLib 2.74. These lines of code allow EZGL
23+
// to be backwards compatible with older versions of GLib, while not using the deprecated
24+
// enum.
25+
#if GLIB_CHECK_VERSION(2, 74, 0)
26+
static constexpr GApplicationFlags EZGL_APPLICATION_DEFAULT_FLAGS = G_APPLICATION_DEFAULT_FLAGS;
27+
#else
28+
static constexpr GApplicationFlags EZGL_APPLICATION_DEFAULT_FLAGS = G_APPLICATION_FLAGS_NONE;
29+
#endif
30+
2131
namespace ezgl {
2232

2333
// A flag to disable event loop (default is false)
@@ -86,7 +96,7 @@ application::application(application::settings s)
8696
, m_window_id(s.window_identifier)
8797
, m_canvas_id(s.canvas_identifier)
8898
, m_application_id(s.application_identifier)
89-
, m_application(gtk_application_new(s.application_identifier.c_str(), G_APPLICATION_FLAGS_NONE))
99+
, m_application(gtk_application_new(s.application_identifier.c_str(), EZGL_APPLICATION_DEFAULT_FLAGS))
90100
, m_builder(gtk_builder_new())
91101
, m_register_callbacks(s.setup_callbacks)
92102
{
@@ -205,7 +215,7 @@ int application::run(setup_callback_fn initial_setup_user_callback,
205215
g_object_unref(m_builder);
206216

207217
// Reconstruct the GTK application
208-
m_application = (gtk_application_new(m_application_id.c_str(), G_APPLICATION_FLAGS_NONE));
218+
m_application = (gtk_application_new(m_application_id.c_str(), EZGL_APPLICATION_DEFAULT_FLAGS));
209219
m_builder = (gtk_builder_new());
210220
g_signal_connect(m_application, "startup", G_CALLBACK(startup), this);
211221
g_signal_connect(m_application, "activate", G_CALLBACK(activate), this);
@@ -478,4 +488,4 @@ void set_disable_event_loop(bool new_setting)
478488
{
479489
disable_event_loop = new_setting;
480490
}
481-
}
491+
}

0 commit comments

Comments
 (0)