Commit 731f5219 authored by scott's avatar scott

More refcounting. --sg

More refcounting.
--sg
parent 0a325309
Wed Feb 4 19:04:35 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* channel.c
* channel.h
* disp_callbacks.c
* gimage.c
* layer.c
* layer.h
* layers_dialog.c
* undo.c: More GTK refcount-related changes. (We're not there
yet, but we're getting closer.)
Tue Feb 3 17:52:34 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* app/interface.[ch] app/app_procs.[ch]: Changes to deal with new
......
......@@ -32,16 +32,19 @@
#include "channel_pvt.h"
/*
enum {
LAST_SIGNAL
};
*/
static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_destroy (GtkObject *object);
/*
static gint channel_signals[LAST_SIGNAL] = { 0 };
*/
static GimpDrawableClass *parent_class = NULL;
......@@ -77,7 +80,9 @@ gimp_channel_class_init (GimpChannelClass *class)
object_class = (GtkObjectClass*) class;
parent_class = gtk_type_class (gimp_drawable_get_type ());
/*
gtk_object_class_add_signals (object_class, channel_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_channel_destroy;
}
......@@ -143,6 +148,21 @@ channel_new (int gimage_ID, int width, int height, char *name, int opacity,
return channel;
}
Channel *
channel_ref (Channel *channel)
{
gtk_object_ref (GTK_OBJECT (channel));
gtk_object_sink (GTK_OBJECT (channel));
return channel;
}
void
channel_unref (Channel *channel)
{
gtk_object_unref (GTK_OBJECT (channel));
}
Channel *
channel_copy (Channel *channel)
......
......@@ -73,6 +73,9 @@ struct _mask_undo
Channel * channel_new (int, int, int, char *, int, unsigned char *);
Channel * channel_copy (Channel *);
Channel * channel_ref (Channel *);
void channel_unref (Channel *);
Channel * channel_get_ID (int);
void channel_delete (Channel *);
void channel_scale (Channel *, int, int);
......
......@@ -32,16 +32,19 @@
#include "channel_pvt.h"
/*
enum {
LAST_SIGNAL
};
*/
static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_destroy (GtkObject *object);
/*
static gint channel_signals[LAST_SIGNAL] = { 0 };
*/
static GimpDrawableClass *parent_class = NULL;
......@@ -77,7 +80,9 @@ gimp_channel_class_init (GimpChannelClass *class)
object_class = (GtkObjectClass*) class;
parent_class = gtk_type_class (gimp_drawable_get_type ());
/*
gtk_object_class_add_signals (object_class, channel_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_channel_destroy;
}
......@@ -143,6 +148,21 @@ channel_new (int gimage_ID, int width, int height, char *name, int opacity,
return channel;
}
Channel *
channel_ref (Channel *channel)
{
gtk_object_ref (GTK_OBJECT (channel));
gtk_object_sink (GTK_OBJECT (channel));
return channel;
}
void
channel_unref (Channel *channel)
{
gtk_object_unref (GTK_OBJECT (channel));
}
Channel *
channel_copy (Channel *channel)
......
......@@ -73,6 +73,9 @@ struct _mask_undo
Channel * channel_new (int, int, int, char *, int, unsigned char *);
Channel * channel_copy (Channel *);
Channel * channel_ref (Channel *);
void channel_unref (Channel *);
Channel * channel_get_ID (int);
void channel_delete (Channel *);
void channel_scale (Channel *, int, int);
......
......@@ -32,16 +32,19 @@
#include "channel_pvt.h"
/*
enum {
LAST_SIGNAL
};
*/
static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_destroy (GtkObject *object);
/*
static gint channel_signals[LAST_SIGNAL] = { 0 };
*/
static GimpDrawableClass *parent_class = NULL;
......@@ -77,7 +80,9 @@ gimp_channel_class_init (GimpChannelClass *class)
object_class = (GtkObjectClass*) class;
parent_class = gtk_type_class (gimp_drawable_get_type ());
/*
gtk_object_class_add_signals (object_class, channel_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_channel_destroy;
}
......@@ -143,6 +148,21 @@ channel_new (int gimage_ID, int width, int height, char *name, int opacity,
return channel;
}
Channel *
channel_ref (Channel *channel)
{
gtk_object_ref (GTK_OBJECT (channel));
gtk_object_sink (GTK_OBJECT (channel));
return channel;
}
void
channel_unref (Channel *channel)
{
gtk_object_unref (GTK_OBJECT (channel));
}
Channel *
channel_copy (Channel *channel)
......
......@@ -73,6 +73,9 @@ struct _mask_undo
Channel * channel_new (int, int, int, char *, int, unsigned char *);
Channel * channel_copy (Channel *);
Channel * channel_ref (Channel *);
void channel_unref (Channel *);
Channel * channel_get_ID (int);
void channel_delete (Channel *);
void channel_scale (Channel *, int, int);
......
......@@ -1033,7 +1033,7 @@ undo_push_layer (GImage *gimage,
{
/* if this is a remove layer, delete the layer */
if (lu->undo_type == 1)
layer_delete (lu->layer);
layer_unref (lu->layer);
g_free (lu);
return FALSE;
}
......@@ -1124,7 +1124,7 @@ undo_free_layer (int state,
*/
if ((state == REDO && lu->undo_type == 0) ||
(state == UNDO && lu->undo_type == 1))
layer_delete (lu->layer);
layer_unref (lu->layer);
g_free (lu);
}
......
......@@ -52,8 +52,10 @@ static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layermask);
static void gimp_layer_mask_destroy (GtkObject *object);
/*
static gint layer_signals[LAST_SIGNAL] = { 0 };
static gint layer_mask_signals[LAST_SIGNAL] = { 0 };
*/
static GimpDrawableClass *layer_parent_class = NULL;
static GimpChannelClass *layer_mask_parent_class = NULL;
......@@ -93,7 +95,9 @@ gimp_layer_class_init (GimpLayerClass *class)
layer_parent_class = gtk_type_class (gimp_drawable_get_type ());
/*
gtk_object_class_add_signals (object_class, layer_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_layer_destroy;
drawable_class->invalidate_preview = layer_invalidate_preview;
......@@ -136,7 +140,9 @@ gimp_layer_mask_class_init (GimpLayerMaskClass *class)
object_class = (GtkObjectClass*) class;
layer_mask_parent_class = gtk_type_class (gimp_channel_get_type ());
/*
gtk_object_class_add_signals (object_class, layer_mask_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_layer_mask_destroy;
}
......@@ -264,6 +270,22 @@ layer_new (gimage_ID, width, height, type, name, opacity, mode)
}
Layer *
layer_ref (Layer *layer)
{
gtk_object_ref (GTK_OBJECT (layer));
gtk_object_sink (GTK_OBJECT (layer));
return layer;
}
void
layer_unref (Layer *layer)
{
gtk_object_unref (GTK_OBJECT (layer));
}
Layer *
layer_copy (layer, add_alpha)
Layer * layer;
......
......@@ -96,6 +96,9 @@ struct _fs_to_layer_undo
Layer * layer_new (int, int, int, int, char *, int, int);
Layer * layer_copy (Layer *, int);
Layer * layer_ref (Layer *);
void layer_unref (Layer *);
Layer * layer_from_tiles (void *, GimpDrawable *, TileManager *, char *, int, int);
LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType);
......
......@@ -86,6 +86,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
gdisp = (GDisplay *) gtk_object_get_user_data (GTK_OBJECT (canvas));
if (!canvas->window)
return FALSE;
/* If this is the first event... */
if (!gdisp->select)
{
......
......@@ -86,6 +86,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
gdisp = (GDisplay *) gtk_object_get_user_data (GTK_OBJECT (canvas));
if (!canvas->window)
return FALSE;
/* If this is the first event... */
if (!gdisp->select)
{
......
......@@ -86,6 +86,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
gdisp = (GDisplay *) gtk_object_get_user_data (GTK_OBJECT (canvas));
if (!canvas->window)
return FALSE;
/* If this is the first event... */
if (!gdisp->select)
{
......
......@@ -2147,10 +2147,10 @@ gimage_add_layer (GImage *gimage, Layer *float_layer, int position)
*/
if (gimage_floating_sel (gimage) && (gimage->floating_sel != float_layer) && position == 0)
position = 1;
gimage->layers = g_slist_insert (gimage->layers, float_layer, position);
gimage->layers = g_slist_insert (gimage->layers, layer_ref (float_layer), position);
}
else
gimage->layers = g_slist_prepend (gimage->layers, float_layer);
gimage->layers = g_slist_prepend (gimage->layers, layer_ref (float_layer));
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, float_layer);
/* notify the layers dialog of the currently active layer */
......@@ -2431,7 +2431,7 @@ gimage_add_channel (GImage *gimage, Channel *channel, int position)
undo_push_channel (gimage, cu);
/* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel);
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
/* notify this gimage of the currently active channel */
gimage_set_active_channel (gimage, channel);
......
......@@ -32,16 +32,19 @@
#include "channel_pvt.h"
/*
enum {
LAST_SIGNAL
};
*/
static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_destroy (GtkObject *object);
/*
static gint channel_signals[LAST_SIGNAL] = { 0 };
*/
static GimpDrawableClass *parent_class = NULL;
......@@ -77,7 +80,9 @@ gimp_channel_class_init (GimpChannelClass *class)
object_class = (GtkObjectClass*) class;
parent_class = gtk_type_class (gimp_drawable_get_type ());
/*
gtk_object_class_add_signals (object_class, channel_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_channel_destroy;
}
......@@ -143,6 +148,21 @@ channel_new (int gimage_ID, int width, int height, char *name, int opacity,
return channel;
}
Channel *
channel_ref (Channel *channel)
{
gtk_object_ref (GTK_OBJECT (channel));
gtk_object_sink (GTK_OBJECT (channel));
return channel;
}
void
channel_unref (Channel *channel)
{
gtk_object_unref (GTK_OBJECT (channel));
}
Channel *
channel_copy (Channel *channel)
......
......@@ -73,6 +73,9 @@ struct _mask_undo
Channel * channel_new (int, int, int, char *, int, unsigned char *);
Channel * channel_copy (Channel *);
Channel * channel_ref (Channel *);
void channel_unref (Channel *);
Channel * channel_get_ID (int);
void channel_delete (Channel *);
void channel_scale (Channel *, int, int);
......
......@@ -52,8 +52,10 @@ static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layermask);
static void gimp_layer_mask_destroy (GtkObject *object);
/*
static gint layer_signals[LAST_SIGNAL] = { 0 };
static gint layer_mask_signals[LAST_SIGNAL] = { 0 };
*/
static GimpDrawableClass *layer_parent_class = NULL;
static GimpChannelClass *layer_mask_parent_class = NULL;
......@@ -93,7 +95,9 @@ gimp_layer_class_init (GimpLayerClass *class)
layer_parent_class = gtk_type_class (gimp_drawable_get_type ());
/*
gtk_object_class_add_signals (object_class, layer_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_layer_destroy;
drawable_class->invalidate_preview = layer_invalidate_preview;
......@@ -136,7 +140,9 @@ gimp_layer_mask_class_init (GimpLayerMaskClass *class)
object_class = (GtkObjectClass*) class;
layer_mask_parent_class = gtk_type_class (gimp_channel_get_type ());
/*
gtk_object_class_add_signals (object_class, layer_mask_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_layer_mask_destroy;
}
......@@ -264,6 +270,22 @@ layer_new (gimage_ID, width, height, type, name, opacity, mode)
}
Layer *
layer_ref (Layer *layer)
{
gtk_object_ref (GTK_OBJECT (layer));
gtk_object_sink (GTK_OBJECT (layer));
return layer;
}
void
layer_unref (Layer *layer)
{
gtk_object_unref (GTK_OBJECT (layer));
}
Layer *
layer_copy (layer, add_alpha)
Layer * layer;
......
......@@ -96,6 +96,9 @@ struct _fs_to_layer_undo
Layer * layer_new (int, int, int, int, char *, int, int);
Layer * layer_copy (Layer *, int);
Layer * layer_ref (Layer *);
void layer_unref (Layer *);
Layer * layer_from_tiles (void *, GimpDrawable *, TileManager *, char *, int, int);
LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType);
......
......@@ -272,6 +272,7 @@ lc_dialog_create (int gimage_id)
if (lc_shell == NULL)
{
lc_shell = gtk_dialog_new ();
gtk_widget_ref (lc_shell);
gtk_window_set_title (GTK_WINDOW (lc_shell), "Layers & Channels");
gtk_window_set_wmclass (GTK_WINDOW (lc_shell), "layers_and_channels", "Gimp");
......@@ -371,7 +372,7 @@ lc_dialog_update_image_list ()
return;
gtk_option_menu_remove_menu (GTK_OPTION_MENU (image_option_menu));
gtk_widget_destroy (image_menu);
/* gtk_widget_destroy (image_menu); */
default_id = layersD->gimage_id;
layersD->gimage_id = -1; /* ??? */
......@@ -412,6 +413,8 @@ lc_dialog_free ()
channels_dialog_free ();
gtk_widget_destroy (lc_shell);
gtk_widget_unref (lc_shell);
lc_shell = NULL;
}
......
......@@ -52,8 +52,10 @@ static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layermask);
static void gimp_layer_mask_destroy (GtkObject *object);
/*
static gint layer_signals[LAST_SIGNAL] = { 0 };
static gint layer_mask_signals[LAST_SIGNAL] = { 0 };
*/
static GimpDrawableClass *layer_parent_class = NULL;
static GimpChannelClass *layer_mask_parent_class = NULL;
......@@ -93,7 +95,9 @@ gimp_layer_class_init (GimpLayerClass *class)
layer_parent_class = gtk_type_class (gimp_drawable_get_type ());
/*
gtk_object_class_add_signals (object_class, layer_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_layer_destroy;
drawable_class->invalidate_preview = layer_invalidate_preview;
......@@ -136,7 +140,9 @@ gimp_layer_mask_class_init (GimpLayerMaskClass *class)
object_class = (GtkObjectClass*) class;
layer_mask_parent_class = gtk_type_class (gimp_channel_get_type ());
/*
gtk_object_class_add_signals (object_class, layer_mask_signals, LAST_SIGNAL);
*/
object_class->destroy = gimp_layer_mask_destroy;
}
......@@ -264,6 +270,22 @@ layer_new (gimage_ID, width, height, type, name, opacity, mode)
}
Layer *
layer_ref (Layer *layer)
{
gtk_object_ref (GTK_OBJECT (layer));
gtk_object_sink (GTK_OBJECT (layer));
return layer;
}
void
layer_unref (Layer *layer)
{
gtk_object_unref (GTK_OBJECT (layer));
}
Layer *
layer_copy (layer, add_alpha)
Layer * layer;
......
......@@ -96,6 +96,9 @@ struct _fs_to_layer_undo
Layer * layer_new (int, int, int, int, char *, int, int);
Layer * layer_copy (Layer *, int);
Layer * layer_ref (Layer *);
void layer_unref (Layer *);
Layer * layer_from_tiles (void *, GimpDrawable *, TileManager *, char *, int, int);
LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType);
......
......@@ -272,6 +272,7 @@ lc_dialog_create (int gimage_id)
if (lc_shell == NULL)
{
lc_shell = gtk_dialog_new ();
gtk_widget_ref (lc_shell);
gtk_window_set_title (GTK_WINDOW (lc_shell), "Layers & Channels");
gtk_window_set_wmclass (GTK_WINDOW (lc_shell), "layers_and_channels", "Gimp");
......@@ -371,7 +372,7 @@ lc_dialog_update_image_list ()
return;
gtk_option_menu_remove_menu (GTK_OPTION_MENU (image_option_menu));
gtk_widget_destroy (image_menu);
/* gtk_widget_destroy (image_menu); */
default_id = layersD->gimage_id;
layersD->gimage_id = -1; /* ??? */
......@@ -412,6 +413,8 @@ lc_dialog_free ()
channels_dialog_free ();
gtk_widget_destroy (lc_shell);
gtk_widget_unref (lc_shell);
lc_shell = NULL;
}
......
......@@ -1033,7 +1033,7 @@ undo_push_layer (GImage *gimage,
{
/* if this is a remove layer, delete the layer */
if (lu->undo_type == 1)
layer_delete (lu->layer);
layer_unref (lu->layer);
g_free (lu);
return FALSE;
}
......@@ -1124,7 +1124,7 @@ undo_free_layer (int state,
*/
if ((state == REDO && lu->undo_type == 0) ||
(state == UNDO && lu->undo_type == 1))
layer_delete (lu->layer);
layer_unref (lu->layer);
g_free (lu);
}
......
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