made the object/class cast checks much more descriptive, based on

Sat Mar  7 20:20:53 1998  Tim Janik  <timj@gimp.org>

        * gtk/gtkobject.c:
        (gtk_object_check_cast):
        (gtk_object_check_class_cast):
        made the object/class cast checks much more descriptive, based on
        gtk-draco-980305-2.patch.gz and gtk-draco-980306-1.patch.gz but
        optimized for common code path.

        * gtk/gtkpreview.c: added a few extra checks for the visual
        (gtk-draco-980305-0.patch.gz).

        * gdk/gdk.c (gdk_signal): abort() on a signal if G_ENABLE_DEBUG
          is defined, so we dump core (gtk-draco-980305-0.patch.gz).
This commit is contained in:
Tim Janik 1998-03-07 20:32:59 +00:00 committed by Tim Janik
parent 640c75216d
commit 124d1e5caa
13 changed files with 180 additions and 21 deletions

View File

@ -1,3 +1,18 @@
Sat Mar 7 20:20:53 1998 Tim Janik <timj@gimp.org>
* gtk/gtkobject.c:
(gtk_object_check_cast):
(gtk_object_check_class_cast):
made the object/class cast checks much more descriptive, based on
gtk-draco-980305-2.patch.gz and gtk-draco-980306-1.patch.gz but
optimized for common code path.
* gtk/gtkpreview.c: added a few extra checks for the visual
(gtk-draco-980305-0.patch.gz).
* gdk/gdk.c (gdk_signal): abort() on a signal if G_ENABLE_DEBUG
is defined, so we dump core (gtk-draco-980305-0.patch.gz).
Sat Mar 7 01:07:24 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkrange.c (gtk_range_expose): Fixed the vscrollbar

View File

@ -1,3 +1,18 @@
Sat Mar 7 20:20:53 1998 Tim Janik <timj@gimp.org>
* gtk/gtkobject.c:
(gtk_object_check_cast):
(gtk_object_check_class_cast):
made the object/class cast checks much more descriptive, based on
gtk-draco-980305-2.patch.gz and gtk-draco-980306-1.patch.gz but
optimized for common code path.
* gtk/gtkpreview.c: added a few extra checks for the visual
(gtk-draco-980305-0.patch.gz).
* gdk/gdk.c (gdk_signal): abort() on a signal if G_ENABLE_DEBUG
is defined, so we dump core (gtk-draco-980305-0.patch.gz).
Sat Mar 7 01:07:24 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkrange.c (gtk_range_expose): Fixed the vscrollbar

View File

@ -1,3 +1,18 @@
Sat Mar 7 20:20:53 1998 Tim Janik <timj@gimp.org>
* gtk/gtkobject.c:
(gtk_object_check_cast):
(gtk_object_check_class_cast):
made the object/class cast checks much more descriptive, based on
gtk-draco-980305-2.patch.gz and gtk-draco-980306-1.patch.gz but
optimized for common code path.
* gtk/gtkpreview.c: added a few extra checks for the visual
(gtk-draco-980305-0.patch.gz).
* gdk/gdk.c (gdk_signal): abort() on a signal if G_ENABLE_DEBUG
is defined, so we dump core (gtk-draco-980305-0.patch.gz).
Sat Mar 7 01:07:24 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkrange.c (gtk_range_expose): Fixed the vscrollbar

View File

@ -1,3 +1,18 @@
Sat Mar 7 20:20:53 1998 Tim Janik <timj@gimp.org>
* gtk/gtkobject.c:
(gtk_object_check_cast):
(gtk_object_check_class_cast):
made the object/class cast checks much more descriptive, based on
gtk-draco-980305-2.patch.gz and gtk-draco-980306-1.patch.gz but
optimized for common code path.
* gtk/gtkpreview.c: added a few extra checks for the visual
(gtk-draco-980305-0.patch.gz).
* gdk/gdk.c (gdk_signal): abort() on a signal if G_ENABLE_DEBUG
is defined, so we dump core (gtk-draco-980305-0.patch.gz).
Sat Mar 7 01:07:24 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkrange.c (gtk_range_expose): Fixed the vscrollbar

View File

@ -1,3 +1,18 @@
Sat Mar 7 20:20:53 1998 Tim Janik <timj@gimp.org>
* gtk/gtkobject.c:
(gtk_object_check_cast):
(gtk_object_check_class_cast):
made the object/class cast checks much more descriptive, based on
gtk-draco-980305-2.patch.gz and gtk-draco-980306-1.patch.gz but
optimized for common code path.
* gtk/gtkpreview.c: added a few extra checks for the visual
(gtk-draco-980305-0.patch.gz).
* gdk/gdk.c (gdk_signal): abort() on a signal if G_ENABLE_DEBUG
is defined, so we dump core (gtk-draco-980305-0.patch.gz).
Sat Mar 7 01:07:24 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkrange.c (gtk_range_expose): Fixed the vscrollbar

View File

@ -1,3 +1,18 @@
Sat Mar 7 20:20:53 1998 Tim Janik <timj@gimp.org>
* gtk/gtkobject.c:
(gtk_object_check_cast):
(gtk_object_check_class_cast):
made the object/class cast checks much more descriptive, based on
gtk-draco-980305-2.patch.gz and gtk-draco-980306-1.patch.gz but
optimized for common code path.
* gtk/gtkpreview.c: added a few extra checks for the visual
(gtk-draco-980305-0.patch.gz).
* gdk/gdk.c (gdk_signal): abort() on a signal if G_ENABLE_DEBUG
is defined, so we dump core (gtk-draco-980305-0.patch.gz).
Sat Mar 7 01:07:24 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkrange.c (gtk_range_expose): Fixed the vscrollbar

View File

@ -1,3 +1,18 @@
Sat Mar 7 20:20:53 1998 Tim Janik <timj@gimp.org>
* gtk/gtkobject.c:
(gtk_object_check_cast):
(gtk_object_check_class_cast):
made the object/class cast checks much more descriptive, based on
gtk-draco-980305-2.patch.gz and gtk-draco-980306-1.patch.gz but
optimized for common code path.
* gtk/gtkpreview.c: added a few extra checks for the visual
(gtk-draco-980305-0.patch.gz).
* gdk/gdk.c (gdk_signal): abort() on a signal if G_ENABLE_DEBUG
is defined, so we dump core (gtk-draco-980305-0.patch.gz).
Sat Mar 7 01:07:24 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkrange.c (gtk_range_expose): Fixed the vscrollbar

View File

@ -3116,7 +3116,11 @@ gdk_signal (int sig_num)
}
g_print ("\n** ERROR **: %s caught\n", sig);
#ifdef G_ENABLE_DEBUG
abort ();
#else /* !G_ENABLE_DEBUG */
gdk_exit (1);
#endif /* !G_ENABLE_DEBUG */
}
static void

View File

@ -3116,7 +3116,11 @@ gdk_signal (int sig_num)
}
g_print ("\n** ERROR **: %s caught\n", sig);
#ifdef G_ENABLE_DEBUG
abort ();
#else /* !G_ENABLE_DEBUG */
gdk_exit (1);
#endif /* !G_ENABLE_DEBUG */
}
static void

View File

@ -29,9 +29,9 @@ extern "C" {
#endif /* __cplusplus */
#define GTK_CONTAINER(obj) GTK_CHECK_CAST (obj, gtk_container_get_type (), GtkContainer)
#define GTK_CONTAINER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_container_get_type, GtkContainerClass)
#define GTK_IS_CONTAINER(obj) GTK_CHECK_TYPE (obj, gtk_container_get_type ())
#define GTK_CONTAINER(obj) (GTK_CHECK_CAST ((obj), gtk_container_get_type (), GtkContainer))
#define GTK_CONTAINER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), gtk_container_get_type, GtkContainerClass))
#define GTK_IS_CONTAINER(obj) (GTK_CHECK_TYPE ((obj), gtk_container_get_type ()))
#define GTK_TYPE_CONTAINER (gtk_container_get_type ())

View File

@ -1174,20 +1174,49 @@ gtk_object_get_user_data (GtkObject *object)
* results:
*****************************************/
static gchar*
gtk_object_descriptive_type_name (GtkType type)
{
gchar *name;
name = gtk_type_name (type);
if (!name)
name = "(unknown)";
return name;
}
GtkObject*
gtk_object_check_cast (GtkObject *obj,
GtkType cast_type)
{
if (obj && obj->klass && !gtk_type_is_a (obj->klass->type, cast_type))
if (!obj)
{
gchar *from_name = gtk_type_name (obj->klass->type);
gchar *to_name = gtk_type_name (cast_type);
g_warning ("invalid cast from \"%s\" to \"%s\"",
from_name ? from_name : "(unknown)",
to_name ? to_name : "(unknown)");
g_warning ("invalid cast from (NULL) pointer to `%s'",
gtk_object_descriptive_type_name (cast_type));
return obj;
}
if (!obj->klass)
{
g_warning ("invalid unclassed pointer in cast to `%s'",
gtk_object_descriptive_type_name (cast_type));
return obj;
}
if (obj->klass->type < GTK_TYPE_OBJECT)
{
g_warning ("invalid class type `%s' in cast to `%s'",
gtk_object_descriptive_type_name (obj->klass->type),
gtk_object_descriptive_type_name (cast_type));
return obj;
}
if (!gtk_type_is_a (obj->klass->type, cast_type))
{
g_warning ("invalid cast from `%s' to `%s'",
gtk_object_descriptive_type_name (obj->klass->type),
gtk_object_descriptive_type_name (cast_type));
return obj;
}
return obj;
}
@ -1203,10 +1232,26 @@ GtkObjectClass*
gtk_object_check_class_cast (GtkObjectClass *klass,
GtkType cast_type)
{
if (klass && !gtk_type_is_a (klass->type, cast_type))
g_warning ("invalid cast from \"%sClass\" to \"%sClass\"",
gtk_type_name (klass->type),
gtk_type_name (cast_type));
if (!klass)
{
g_warning ("invalid class cast from (NULL) pointer to `%s'",
gtk_object_descriptive_type_name (cast_type));
return klass;
}
if (klass->type < GTK_TYPE_OBJECT)
{
g_warning ("invalid class type `%s' in class cast to `%s'",
gtk_object_descriptive_type_name (klass->type),
gtk_object_descriptive_type_name (cast_type));
return klass;
}
if (!gtk_type_is_a (klass->type, cast_type))
{
g_warning ("invalid class cast from `%s' to `%s'",
gtk_object_descriptive_type_name (klass->type),
gtk_object_descriptive_type_name (cast_type));
return klass;
}
return klass;
}

View File

@ -42,17 +42,17 @@ extern "C" {
#else /* !GTK_NO_CHECK_CASTS */
#define GTK_CHECK_CAST(obj,cast_type,cast) \
((cast*) gtk_object_check_cast ((GtkObject*) (obj), cast_type))
((cast*) gtk_object_check_cast ((GtkObject*) (obj), (cast_type)))
#define GTK_CHECK_CLASS_CAST(klass,cast_type,cast) \
((cast*) gtk_object_check_class_cast ((GtkObjectClass*) (klass), cast_type))
((cast*) gtk_object_check_class_cast ((GtkObjectClass*) (klass), (cast_type)))
#endif /* GTK_NO_CHECK_CASTS */
/* Determines whether 'obj' is a type of 'otype'.
*/
#define GTK_CHECK_TYPE(obj,otype) (gtk_type_is_a (((GtkObject*) (obj))->klass->type, otype))
#define GTK_CHECK_TYPE(obj,otype) (gtk_type_is_a (((GtkObject*) (obj))->klass->type, (otype)))
/* Macro for casting a pointer to a GtkObject pointer.

View File

@ -222,7 +222,7 @@ gtk_preview_uninit ()
GtkPreviewProp *prop;
GdkAtom property;
if (preview_class && !install_cmap &&
if (preview_class && !install_cmap && preview_class->info.visual &&
(preview_class->info.visual->type != GDK_VISUAL_TRUE_COLOR) &&
(preview_class->info.visual->type != GDK_VISUAL_DIRECT_COLOR))
{
@ -489,7 +489,8 @@ gtk_preview_draw_row (GtkPreview *preview,
g_return_if_fail (preview != NULL);
g_return_if_fail (GTK_IS_PREVIEW (preview));
g_return_if_fail (data != NULL);
g_return_if_fail (preview_class->info.visual != NULL);
if ((w <= 0) || (y < 0))
return;
@ -934,7 +935,7 @@ gtk_preview_dither_init (GtkPreviewClass *klass)
{ 63, 31, 55, 23, 61, 29, 53, 21 }
};
if (klass->info.visual->type != GDK_VISUAL_PSEUDO_COLOR)
if (!klass->info.visual || klass->info.visual->type != GDK_VISUAL_PSEUDO_COLOR)
return;
shades_r = klass->info.nred_shades;