Commit b70abe38 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

prevent gdk_init() from segfaulting when invoked with (NULL, NULL); (this

Wed Jun 10 06:25:17 1998  Tim Janik  <timj@gtk.org>

        * gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
        invoked with (NULL, NULL); (this worked sometime ago).

        * gtk/gtktypeutils.h:
        * gtk/gtktypeutils.c: enum and flags type creation can now be done
        through gtk_type_register_enum() and gtk_type_register_flags(),
        which allow to specify the enum value arrays directly.
        the NULL terminated value arrays can be retrived through
        gtk_type_enum_get_values() and gtk_type_flags_get_values();
        (gtk_type_children_types): new function to query derived types.
parent 6430ad63
Wed Jun 10 06:25:17 1998 Tim Janik <timj@gtk.org>
* gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
invoked with (NULL, NULL); (this worked sometime ago).
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: enum and flags type creation can now be done
through gtk_type_register_enum() and gtk_type_register_flags(),
which allow to specify the enum value arrays directly.
the NULL terminated value arrays can be retrived through
gtk_type_enum_get_values() and gtk_type_flags_get_values();
(gtk_type_children_types): new function to query derived types.
1998-06-09 Raja R Harinath <harinath@cs.umn.edu>
......
Wed Jun 10 06:25:17 1998 Tim Janik <timj@gtk.org>
* gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
invoked with (NULL, NULL); (this worked sometime ago).
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: enum and flags type creation can now be done
through gtk_type_register_enum() and gtk_type_register_flags(),
which allow to specify the enum value arrays directly.
the NULL terminated value arrays can be retrived through
gtk_type_enum_get_values() and gtk_type_flags_get_values();
(gtk_type_children_types): new function to query derived types.
1998-06-09 Raja R Harinath <harinath@cs.umn.edu>
......
Wed Jun 10 06:25:17 1998 Tim Janik <timj@gtk.org>
* gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
invoked with (NULL, NULL); (this worked sometime ago).
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: enum and flags type creation can now be done
through gtk_type_register_enum() and gtk_type_register_flags(),
which allow to specify the enum value arrays directly.
the NULL terminated value arrays can be retrived through
gtk_type_enum_get_values() and gtk_type_flags_get_values();
(gtk_type_children_types): new function to query derived types.
1998-06-09 Raja R Harinath <harinath@cs.umn.edu>
......
Wed Jun 10 06:25:17 1998 Tim Janik <timj@gtk.org>
* gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
invoked with (NULL, NULL); (this worked sometime ago).
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: enum and flags type creation can now be done
through gtk_type_register_enum() and gtk_type_register_flags(),
which allow to specify the enum value arrays directly.
the NULL terminated value arrays can be retrived through
gtk_type_enum_get_values() and gtk_type_flags_get_values();
(gtk_type_children_types): new function to query derived types.
1998-06-09 Raja R Harinath <harinath@cs.umn.edu>
......
Wed Jun 10 06:25:17 1998 Tim Janik <timj@gtk.org>
* gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
invoked with (NULL, NULL); (this worked sometime ago).
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: enum and flags type creation can now be done
through gtk_type_register_enum() and gtk_type_register_flags(),
which allow to specify the enum value arrays directly.
the NULL terminated value arrays can be retrived through
gtk_type_enum_get_values() and gtk_type_flags_get_values();
(gtk_type_children_types): new function to query derived types.
1998-06-09 Raja R Harinath <harinath@cs.umn.edu>
......
Wed Jun 10 06:25:17 1998 Tim Janik <timj@gtk.org>
* gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
invoked with (NULL, NULL); (this worked sometime ago).
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: enum and flags type creation can now be done
through gtk_type_register_enum() and gtk_type_register_flags(),
which allow to specify the enum value arrays directly.
the NULL terminated value arrays can be retrived through
gtk_type_enum_get_values() and gtk_type_flags_get_values();
(gtk_type_children_types): new function to query derived types.
1998-06-09 Raja R Harinath <harinath@cs.umn.edu>
......
Wed Jun 10 06:25:17 1998 Tim Janik <timj@gtk.org>
* gdk/gdk.c (gdk_init): prevent gdk_init() from segfaulting when
invoked with (NULL, NULL); (this worked sometime ago).
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: enum and flags type creation can now be done
through gtk_type_register_enum() and gtk_type_register_flags(),
which allow to specify the enum value arrays directly.
the NULL terminated value arrays can be retrived through
gtk_type_enum_get_values() and gtk_type_flags_get_values();
(gtk_type_children_types): new function to query derived types.
1998-06-09 Raja R Harinath <harinath@cs.umn.edu>
......
......@@ -160,7 +160,7 @@ static void gdk_ic_cleanup (void);
/* Private variable declarations
*/
static int initialized = 0; /* 1 if the library is initialized,
static int gdk_initialized = 0; /* 1 if the library is initialized,
* 0 otherwise.
*/
static int connection_number = 0; /* The file descriptor number of our
......@@ -268,13 +268,21 @@ gdk_init (int *argc,
gint synchronize;
gint i, j, k;
XClassHint *class_hint;
gint argc_orig = *argc;
gchar **argv_orig;
gchar **argv_orig = NULL;
gint argc_orig = 0;
argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
for (i = 0; i < argc_orig; i++)
argv_orig[i] = g_strdup ((*argv)[i]);
argv_orig[argc_orig] = NULL;
if (gdk_initialized)
return;
if (argc && argv)
{
argc_orig = *argc;
argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
for (i = 0; i < argc_orig; i++)
argv_orig[i] = g_strdup ((*argv)[i]);
argv_orig[argc_orig] = NULL;
}
X_GETTIMEOFDAY (&start);
......@@ -316,8 +324,6 @@ gdk_init (int *argc,
gdk_progname = g_strdup (d + 1);
else
gdk_progname = g_strdup ((*argv)[0]);
GDK_NOTE (MISC,
g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
}
for (i = 1; i < *argc;)
......@@ -484,6 +490,8 @@ gdk_init (int *argc,
gdk_progname = "<unknown>";
}
GDK_NOTE (MISC, g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
gdk_display = XOpenDisplay (gdk_display_name);
if (!gdk_display)
{
......@@ -579,7 +587,7 @@ gdk_init (int *argc,
gdk_im_open (NULL, NULL, NULL);
#endif
initialized = 1;
gdk_initialized = 1;
}
/*
......@@ -3159,10 +3167,11 @@ gdk_exit_func (void)
/* This is to avoid an infinite loop if a program segfaults in
an atexit() handler (and yes, it does happen, especially if a program
has trounced over memory too badly for even g_print to work) */
if(in_gdk_exit_func == TRUE) return;
if (in_gdk_exit_func == TRUE)
return;
in_gdk_exit_func = TRUE;
if (initialized)
if (gdk_initialized)
{
#ifdef USE_XIM
/* cleanup IC */
......@@ -3175,7 +3184,7 @@ gdk_exit_func (void)
gdk_key_repeat_restore ();
XCloseDisplay (gdk_display);
initialized = 0;
gdk_initialized = 0;
}
}
......
......@@ -160,7 +160,7 @@ static void gdk_ic_cleanup (void);
/* Private variable declarations
*/
static int initialized = 0; /* 1 if the library is initialized,
static int gdk_initialized = 0; /* 1 if the library is initialized,
* 0 otherwise.
*/
static int connection_number = 0; /* The file descriptor number of our
......@@ -268,13 +268,21 @@ gdk_init (int *argc,
gint synchronize;
gint i, j, k;
XClassHint *class_hint;
gint argc_orig = *argc;
gchar **argv_orig;
gchar **argv_orig = NULL;
gint argc_orig = 0;
argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
for (i = 0; i < argc_orig; i++)
argv_orig[i] = g_strdup ((*argv)[i]);
argv_orig[argc_orig] = NULL;
if (gdk_initialized)
return;
if (argc && argv)
{
argc_orig = *argc;
argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
for (i = 0; i < argc_orig; i++)
argv_orig[i] = g_strdup ((*argv)[i]);
argv_orig[argc_orig] = NULL;
}
X_GETTIMEOFDAY (&start);
......@@ -316,8 +324,6 @@ gdk_init (int *argc,
gdk_progname = g_strdup (d + 1);
else
gdk_progname = g_strdup ((*argv)[0]);
GDK_NOTE (MISC,
g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
}
for (i = 1; i < *argc;)
......@@ -484,6 +490,8 @@ gdk_init (int *argc,
gdk_progname = "<unknown>";
}
GDK_NOTE (MISC, g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
gdk_display = XOpenDisplay (gdk_display_name);
if (!gdk_display)
{
......@@ -579,7 +587,7 @@ gdk_init (int *argc,
gdk_im_open (NULL, NULL, NULL);
#endif
initialized = 1;
gdk_initialized = 1;
}
/*
......@@ -3159,10 +3167,11 @@ gdk_exit_func (void)
/* This is to avoid an infinite loop if a program segfaults in
an atexit() handler (and yes, it does happen, especially if a program
has trounced over memory too badly for even g_print to work) */
if(in_gdk_exit_func == TRUE) return;
if (in_gdk_exit_func == TRUE)
return;
in_gdk_exit_func = TRUE;
if (initialized)
if (gdk_initialized)
{
#ifdef USE_XIM
/* cleanup IC */
......@@ -3175,7 +3184,7 @@ gdk_exit_func (void)
gdk_key_repeat_restore ();
XCloseDisplay (gdk_display);
initialized = 0;
gdk_initialized = 0;
}
}
......
......@@ -140,7 +140,7 @@ const guint gtk_micro_version = GTK_MICRO_VERSION;
static gboolean iteration_done = FALSE;
static guint main_level = 0;
static gint initialized = FALSE;
static gint gtk_initialized = FALSE;
static GdkEvent *next_event = NULL;
static GList *current_events = NULL;
......@@ -231,12 +231,10 @@ void
gtk_init (int *argc,
char ***argv)
{
static gboolean gtk_initialized = FALSE;
gchar *current_locale;
if (gtk_initialized)
return;
gtk_initialized = TRUE;
if (0)
{
......@@ -331,7 +329,7 @@ gtk_init (int *argc,
/* Check if there is a good chance the mb functions will handle things
* correctly - set if either mblen("\xc0", MB_CUR_MAX) == 1 in the
* C locale, or were using X's mb functions. (-DX_LOCALE && locale != C)
* C locale, or we're using X's mb functions. (-DX_LOCALE && locale != C)
*/
current_locale = g_strdup (setlocale (LC_CTYPE, NULL));
......@@ -371,7 +369,7 @@ gtk_init (int *argc,
/* Set the 'initialized' flag.
*/
initialized = TRUE;
gtk_initialized = TRUE;
}
void
......@@ -1354,9 +1352,9 @@ gtk_get_event_widget (GdkEvent *event)
static void
gtk_exit_func (void)
{
if (initialized)
if (gtk_initialized)
{
initialized = FALSE;
gtk_initialized = FALSE;
gtk_preview_uninit ();
}
}
......
......@@ -368,11 +368,23 @@ gtk_type_free (GtkType type,
g_free (mem);
}
GList*
gtk_type_children_types (GtkType type)
{
GtkTypeNode *node;
LOOKUP_TYPE_NODE (node, type);
if (node)
return node->children_types;
return NULL;
}
void
gtk_type_describe_heritage (GtkType type)
{
GtkTypeNode *node;
gint first;
gboolean first;
LOOKUP_TYPE_NODE (node, type);
first = TRUE;
......@@ -395,8 +407,8 @@ gtk_type_describe_heritage (GtkType type)
}
void
gtk_type_describe_tree (GtkType type,
gint show_size)
gtk_type_describe_tree (GtkType type,
gboolean show_size)
{
GtkTypeNode *node;
......
......@@ -197,6 +197,7 @@ GtkType gtk_type_from_name (const gchar *name);
GtkType gtk_type_parent (GtkType type);
gpointer gtk_type_class (GtkType type);
gpointer gtk_type_parent_class (GtkType type);
GList* gtk_type_children_types (GtkType type);
gpointer gtk_type_new (GtkType type);
void gtk_type_free (GtkType type,
gpointer mem);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment