From bfbb20fac5a07651aed970624fe9c5d919791760 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sat, 8 Aug 2020 16:30:55 -0400
Subject: [PATCH] Supress warnings from GTK deprecation

---
 .../linux_crash_logger/llcrashloggerlinux.cpp | 17 +++-
 indra/llwindow/llwindowsdl.cpp                | 86 +++++++++++--------
 indra/newview/llappviewerlinux.cpp            |  6 ++
 indra/newview/llfilepicker.h                  | 11 ++-
 4 files changed, 80 insertions(+), 40 deletions(-)

diff --git a/indra/linux_crash_logger/llcrashloggerlinux.cpp b/indra/linux_crash_logger/llcrashloggerlinux.cpp
index 4092d43fc5f..76e36a86e48 100644
--- a/indra/linux_crash_logger/llcrashloggerlinux.cpp
+++ b/indra/linux_crash_logger/llcrashloggerlinux.cpp
@@ -38,10 +38,25 @@
 #include "lldir.h"
 #include "llsdserialize.h"
 
+#if LL_GNUC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #if LL_GTK
-# include "gtk/gtk.h"
+extern "C" {
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#if GTK_CHECK_VERSION(2, 24, 0)
+#include <gdk/gdkx.h>
+#endif
+}
 #endif // LL_GTK
 
+#if LL_GNUC
+#pragma GCC diagnostic pop
+#endif
+
 #define MAX_LOADSTRING 100
 
 // These need to be localized.
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index c20e639fc74..f3d10aee222 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -40,13 +40,26 @@
 #include "lldir.h"
 #include "llfindlocale.h"
 
+#if LL_GNUC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #if LL_GTK
 extern "C" {
-# include "gtk/gtk.h"
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#if GTK_CHECK_VERSION(2, 24, 0)
+#include <gdk/gdkx.h>
+#endif
 }
 #include <locale.h>
 #endif // LL_GTK
 
+#if LL_GNUC
+#pragma GCC diagnostic pop
+#endif
+
 extern "C" {
 # include "fontconfig/fontconfig.h"
 }
@@ -119,7 +132,6 @@ bool LLWindowSDL::ll_try_gtk_init(void)
 	if (!tried_gtk_init)
 	{
 		tried_gtk_init = TRUE;
-		if (!g_thread_supported ()) g_thread_init (NULL);
 		maybe_lock_display();
 		gtk_is_good = gtk_init_check(NULL, NULL);
 		maybe_unlock_display();
@@ -1404,36 +1416,36 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
 		mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS];
 		mNumSupportedResolutions = 0;
 
-        SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
-        if ( (modes != NULL) && (modes != ((SDL_Rect **) -1)) )
-        {
-            int count = 0;
-            while (*modes && count<MAX_NUM_RESOLUTIONS)  // they're sorted biggest to smallest, so find end...
-            {
-                modes++;
-                count++;
-            }
+		SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
+		if ( (modes != NULL) && (modes != ((SDL_Rect **) -1)) )
+		{
+			int count = 0;
+			while (*modes && count<MAX_NUM_RESOLUTIONS)  // they're sorted biggest to smallest, so find end...
+			{
+				modes++;
+				count++;
+			}
 
-            while (count--)
-            {
-                modes--;
-                SDL_Rect *r = *modes;
-                int w = r->w;
-                int h = r->h;
-                if ((w >= 800) && (h >= 600))
-                {
-                    // make sure we don't add the same resolution multiple times!
-                    if ( (mNumSupportedResolutions == 0) ||
-                         ((mSupportedResolutions[mNumSupportedResolutions-1].mWidth != w) &&
-                          (mSupportedResolutions[mNumSupportedResolutions-1].mHeight != h)) )
-                    {
-                        mSupportedResolutions[mNumSupportedResolutions].mWidth = w;
-                        mSupportedResolutions[mNumSupportedResolutions].mHeight = h;
-                        mNumSupportedResolutions++;
-                    }
-                }
-            }
-        }
+			while (count--)
+			{
+				modes--;
+				SDL_Rect *r = *modes;
+				int w = r->w;
+				int h = r->h;
+				if ((w >= 800) && (h >= 600))
+				{
+					// make sure we don't add the same resolution multiple times!
+					if ( (mNumSupportedResolutions == 0) ||
+						 ((mSupportedResolutions[mNumSupportedResolutions-1].mWidth != w) &&
+						  (mSupportedResolutions[mNumSupportedResolutions-1].mHeight != h)) )
+					{
+						mSupportedResolutions[mNumSupportedResolutions].mWidth = w;
+						mSupportedResolutions[mNumSupportedResolutions].mHeight = h;
+						mNumSupportedResolutions++;
+					}
+				}
+			}
+		}
 	}
 
 	num_resolutions = mNumSupportedResolutions;
@@ -1442,8 +1454,8 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
 
 BOOL LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to)
 {
-    if (!to)
-        return FALSE;
+	if (!to)
+		return FALSE;
 
 	to->mX = from.mX;
 	to->mY = mWindow->h - from.mY - 1;
@@ -1453,8 +1465,8 @@ BOOL LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to)
 
 BOOL LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to)
 {
-    if (!to)
-        return FALSE;
+	if (!to)
+		return FALSE;
 
 	to->mX = from.mX;
 	to->mY = mWindow->h - from.mY - 1;
@@ -1464,13 +1476,13 @@ BOOL LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to)
 
 BOOL LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordWindow* to)
 {
-    if (!to)
+	if (!to)
 		return FALSE;
 
 	// In the fullscreen case, window and screen coordinates are the same.
 	to->mX = from.mX;
 	to->mY = from.mY;
-    return (TRUE);
+	return (TRUE);
 }
 
 BOOL LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordScreen *to)
diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp
index 6f32aab851e..bea2a6c13ac 100644
--- a/indra/newview/llappviewerlinux.cpp
+++ b/indra/newview/llappviewerlinux.cpp
@@ -122,11 +122,13 @@ LLAppViewerLinux::~LLAppViewerLinux()
 
 bool LLAppViewerLinux::init()
 {
+#if !GLIB_CHECK_VERSION(2, 32, 0)
 	// g_thread_init() must be called before *any* use of glib, *and*
 	// before any mutexes are held, *and* some of our third-party
 	// libraries likes to use glib functions; in short, do this here
 	// really early in app startup!
 	if (!g_thread_supported ()) g_thread_init (NULL);
+#endif
 	
 	bool success = LLAppViewer::init();
 
@@ -266,7 +268,9 @@ bool LLAppViewerLinux::initSLURLHandler()
 		return false; // failed
 	}
 
+#if !GLIB_CHECK_VERSION(2, 36, 0)
 	g_type_init();
+#endif
 
 	//ViewerAppAPI *api_server = (ViewerAppAPI*)
 	g_object_new(viewerappapi_get_type(), NULL);
@@ -286,7 +290,9 @@ bool LLAppViewerLinux::sendURLToOtherInstance(const std::string& url)
 	DBusGConnection *bus;
 	GError *error = NULL;
 
+#if !GLIB_CHECK_VERSION(2, 36, 0)
 	g_type_init();
+#endif
 	
 	bus = lldbus_g_bus_get (DBUS_BUS_SESSION, &error);
 	if (bus)
diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h
index bc8c6eaf5a6..ffd937ce8ef 100644
--- a/indra/newview/llfilepicker.h
+++ b/indra/newview/llfilepicker.h
@@ -54,12 +54,19 @@
 #include <commdlg.h>
 #endif
 
+#if LL_GTK
+#if LL_GNUC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
 extern "C" {
 // mostly for Linux, possible on others
-#if LL_GTK
 # include "gtk/gtk.h"
-#endif // LL_GTK
 }
+#if LL_GNUC
+#pragma GCC diagnostic pop
+#endif // LL_GNUC
+#endif // LL_GTK
 
 class LLFilePicker
 {
-- 
GitLab