gdk: No displays before init
Don't allow to create displays before gdk has been initialized. Note that this error triggers in nautilus 47.0, but we consider what it is doing unsupported and broken. Related: #7035
This commit is contained in:
13
gdk/gdk.c
13
gdk/gdk.c
@@ -113,6 +113,12 @@ static int gdk_initialized = 0; /* 1 if the library is initi
|
||||
* 0 otherwise.
|
||||
*/
|
||||
|
||||
gboolean
|
||||
gdk_is_initialized (void)
|
||||
{
|
||||
return gdk_initialized != 0;
|
||||
}
|
||||
|
||||
static const GdkDebugKey gdk_debug_keys[] = {
|
||||
{ "misc", GDK_DEBUG_MISC, "Miscellaneous information" },
|
||||
{ "events", GDK_DEBUG_EVENTS, "Information about events" },
|
||||
@@ -360,13 +366,10 @@ gdk_display_open_default (void)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
|
||||
g_return_val_if_fail (gdk_initialized, NULL);
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
if (display)
|
||||
return display;
|
||||
|
||||
display = gdk_display_open (NULL);
|
||||
if (!display)
|
||||
display = gdk_display_open (NULL);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "gdkdisplaymanagerprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkprivate.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
@@ -294,6 +295,8 @@ gdk_display_manager_get (void)
|
||||
{
|
||||
static GdkDisplayManager *manager = NULL;
|
||||
|
||||
gdk_ensure_initialized ();
|
||||
|
||||
if (manager == NULL)
|
||||
manager = g_object_new (GDK_TYPE_DISPLAY_MANAGER, NULL);
|
||||
|
||||
|
||||
@@ -5,6 +5,13 @@
|
||||
/* Private API for use in GTK+ */
|
||||
|
||||
void gdk_pre_parse (void);
|
||||
gboolean gdk_is_initialized (void);
|
||||
|
||||
#define gdk_ensure_initialized() \
|
||||
G_STMT_START { \
|
||||
if (!gdk_is_initialized ()) \
|
||||
g_error ("%s() was called before gtk_init()", G_STRFUNC); \
|
||||
} G_STMT_END
|
||||
|
||||
gboolean gdk_running_in_sandbox (void);
|
||||
gboolean gdk_should_use_portal (void);
|
||||
|
||||
Reference in New Issue
Block a user