diff --git a/base/platform/linux/base_linux_gtk_integration.cpp b/base/platform/linux/base_linux_gtk_integration.cpp index d5967605..37b45139 100644 --- a/base/platform/linux/base_linux_gtk_integration.cpp +++ b/base/platform/linux/base_linux_gtk_integration.cpp @@ -18,13 +18,7 @@ namespace base { namespace Platform { - -using namespace Gtk; - -namespace { - -bool TriedToInit = false; -bool Loaded = false; +namespace Gtk { bool LoadLibrary(QLibrary &lib, const char *name, int version) { #ifdef LINK_TO_GTK @@ -57,6 +51,15 @@ bool LoadLibrary(QLibrary &lib, const char *name, int version) { #endif // !LINK_TO_GTK } +} // namespace Gtk + +namespace { + +using namespace Gtk; + +bool TriedToInit = false; +bool Loaded = false; + void GtkMessageHandler( const gchar *log_domain, GLogLevelFlags log_level, @@ -72,9 +75,9 @@ void GtkMessageHandler( } bool SetupGtkBase(QLibrary &lib) { - if (!LOAD_GTK_SYMBOL(lib, "gtk_init_check", gtk_init_check)) return false; + if (!LOAD_GTK_SYMBOL(lib, gtk_init_check)) return false; - if (LOAD_GTK_SYMBOL(lib, "gdk_set_allowed_backends", gdk_set_allowed_backends)) { + if (LOAD_GTK_SYMBOL(lib, gdk_set_allowed_backends)) { // We work only with Wayland and X11 GDK backends. // Otherwise we get segfault in Ubuntu 17.04 in gtk_init_check() call. // See https://github.com/telegramdesktop/tdesktop/issues/3176 @@ -288,8 +291,8 @@ void GtkIntegration::load() { } if (Loaded) { - LOAD_GTK_SYMBOL(_lib, "gtk_check_version", gtk_check_version); - LOAD_GTK_SYMBOL(_lib, "gtk_settings_get_default", gtk_settings_get_default); + LOAD_GTK_SYMBOL(_lib, gtk_check_version); + LOAD_GTK_SYMBOL(_lib, gtk_settings_get_default); SetIconTheme(); SetCursorSize(); diff --git a/base/platform/linux/base_linux_gtk_integration_p.h b/base/platform/linux/base_linux_gtk_integration_p.h index 214c3f2c..c481c992 100644 --- a/base/platform/linux/base_linux_gtk_integration_p.h +++ b/base/platform/linux/base_linux_gtk_integration_p.h @@ -20,15 +20,17 @@ extern "C" { #endif // DESKTOP_APP_USE_PACKAGED && !DESKTOP_APP_USE_PACKAGED_LAZY #ifdef LINK_TO_GTK -#define LOAD_GTK_SYMBOL(lib, name, func) (func = ::func) +#define LOAD_GTK_SYMBOL(lib, func) (func = ::func) #else // LINK_TO_GTK -#define LOAD_GTK_SYMBOL base::Platform::Gtk::LoadSymbol +#define LOAD_GTK_SYMBOL(lib, func) base::Platform::Gtk::LoadSymbol(lib, #func, func) #endif // !LINK_TO_GTK namespace base { namespace Platform { namespace Gtk { +bool LoadLibrary(QLibrary &lib, const char *name, int version); + template bool LoadSymbol(QLibrary &lib, const char *name, Function &func) { func = nullptr;