mirror of https://github.com/GNOME/gimp.git
app/undo.c app/gimage.h added a simple ref count to the guides so that
1998-03-11 Larry Ewing <lewing@discord.isc.tamu.edu> * app/undo.c * app/gimage.h * app/gimage.c: added a simple ref count to the guides so that undo does not free the too early...
This commit is contained in:
parent
16aacc47a8
commit
bd8f7a1a9a
|
@ -1974,6 +1974,7 @@ undo_push_guide (GImage *gimage,
|
|||
|
||||
if ((new = undo_push (gimage, size, GIMAGE_MOD)))
|
||||
{
|
||||
((Guide *)(guide))->ref_count++;
|
||||
data = g_new (GuideUndo, 1);
|
||||
new->data = data;
|
||||
new->pop_func = undo_pop_guide;
|
||||
|
@ -1998,14 +1999,17 @@ undo_pop_guide (GImage *gimage,
|
|||
{
|
||||
GuideUndo *data;
|
||||
Guide tmp;
|
||||
int tmp_ref;
|
||||
|
||||
data = data_ptr;
|
||||
|
||||
gdisplays_expose_guide (gimage->ID, data->guide);
|
||||
gdisplays_expose_guide (gimage->ID, &data->orig);
|
||||
|
||||
tmp_ref = data->guide->ref_count;
|
||||
tmp = *(data->guide);
|
||||
*(data->guide) = data->orig;
|
||||
data->guide->ref_count = tmp_ref;
|
||||
data->orig = tmp;
|
||||
|
||||
switch (state)
|
||||
|
@ -2030,8 +2034,9 @@ undo_free_guide (int state,
|
|||
|
||||
data = data_ptr;
|
||||
|
||||
if (data->guide->position < 0)
|
||||
gimage_delete_guide (data->gimage, data->guide);
|
||||
data->guide->ref_count--;
|
||||
if (data->guide->position < 0 && data->guide->ref_count <= 0)
|
||||
gimage_delete_guide (data->gimage, data->guide);
|
||||
|
||||
g_free (data_ptr);
|
||||
}
|
||||
|
|
|
@ -825,6 +825,7 @@ gimage_add_hguide (GImage *gimage)
|
|||
Guide *guide;
|
||||
|
||||
guide = g_new (Guide, 1);
|
||||
guide->ref_count = 0;
|
||||
guide->position = -1;
|
||||
guide->orientation = HORIZONTAL_GUIDE;
|
||||
|
||||
|
@ -839,6 +840,7 @@ gimage_add_vguide (GImage *gimage)
|
|||
Guide *guide;
|
||||
|
||||
guide = g_new (Guide, 1);
|
||||
guide->ref_count = 0;
|
||||
guide->position = -1;
|
||||
guide->orientation = VERTICAL_GUIDE;
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ typedef struct _GImage GImage;
|
|||
|
||||
struct _Guide
|
||||
{
|
||||
int ref_count;
|
||||
int position;
|
||||
int orientation;
|
||||
};
|
||||
|
|
|
@ -1974,6 +1974,7 @@ undo_push_guide (GImage *gimage,
|
|||
|
||||
if ((new = undo_push (gimage, size, GIMAGE_MOD)))
|
||||
{
|
||||
((Guide *)(guide))->ref_count++;
|
||||
data = g_new (GuideUndo, 1);
|
||||
new->data = data;
|
||||
new->pop_func = undo_pop_guide;
|
||||
|
@ -1998,14 +1999,17 @@ undo_pop_guide (GImage *gimage,
|
|||
{
|
||||
GuideUndo *data;
|
||||
Guide tmp;
|
||||
int tmp_ref;
|
||||
|
||||
data = data_ptr;
|
||||
|
||||
gdisplays_expose_guide (gimage->ID, data->guide);
|
||||
gdisplays_expose_guide (gimage->ID, &data->orig);
|
||||
|
||||
tmp_ref = data->guide->ref_count;
|
||||
tmp = *(data->guide);
|
||||
*(data->guide) = data->orig;
|
||||
data->guide->ref_count = tmp_ref;
|
||||
data->orig = tmp;
|
||||
|
||||
switch (state)
|
||||
|
@ -2030,8 +2034,9 @@ undo_free_guide (int state,
|
|||
|
||||
data = data_ptr;
|
||||
|
||||
if (data->guide->position < 0)
|
||||
gimage_delete_guide (data->gimage, data->guide);
|
||||
data->guide->ref_count--;
|
||||
if (data->guide->position < 0 && data->guide->ref_count <= 0)
|
||||
gimage_delete_guide (data->gimage, data->guide);
|
||||
|
||||
g_free (data_ptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue