Fix for bug #8746: the fake user button for datablocks was not a toggle

button, while it should be.
This commit is contained in:
2008-03-26 20:17:50 +00:00
parent 0599a56468
commit 5183788fd6
5 changed files with 21 additions and 23 deletions

View File

@@ -48,7 +48,7 @@ void free_brush(struct Brush *brush);
int brush_set_nr(struct Brush **current_brush, int nr);
int brush_delete(struct Brush **current_brush);
void brush_check_exists(struct Brush **brush);
void brush_toggle_fake_user(struct Brush *brush);
void brush_toggled_fake_user(struct Brush *brush);
int brush_texture_set_nr(struct Brush *brush, int nr);
int brush_texture_delete(struct Brush *brush);
int brush_clone_image_set_nr(struct Brush *brush, int nr);

View File

@@ -73,7 +73,8 @@ Brush *add_brush(char *name)
brush->clone.alpha= 0.5;
/* enable fake user by default */
brush_toggle_fake_user(brush);
brush->id.flag |= LIB_FAKEUSER;
brush_toggled_fake_user(brush);
return brush;
}
@@ -95,8 +96,10 @@ Brush *copy_brush(Brush *brush)
}
/* enable fake user by default */
if (!(brushn->id.flag & LIB_FAKEUSER))
brush_toggle_fake_user(brushn);
if (!(brushn->id.flag & LIB_FAKEUSER)) {
brushn->id.flag |= LIB_FAKEUSER;
brush_toggled_fake_user(brushn);
}
return brushn;
}
@@ -148,8 +151,10 @@ void make_local_brush(Brush *brush)
new_id(0, (ID *)brush, 0);
/* enable fake user by default */
if (!(brush->id.flag & LIB_FAKEUSER))
brush_toggle_fake_user(brush);
if (!(brush->id.flag & LIB_FAKEUSER)) {
brush->id.flag |= LIB_FAKEUSER;
brush_toggled_fake_user(brush);
}
}
else if(local && lib) {
brushn= copy_brush(brush);
@@ -203,16 +208,14 @@ int brush_delete(Brush **current_brush)
return 0;
}
void brush_toggle_fake_user(Brush *brush)
void brush_toggled_fake_user(Brush *brush)
{
ID *id= (ID*)brush;
if(id) {
if(id->flag & LIB_FAKEUSER) {
id->flag -= LIB_FAKEUSER;
id->us--;
} else {
id->flag |= LIB_FAKEUSER;
id_us_plus(id);
} else {
id->us--;
}
}
}

View File

@@ -5915,7 +5915,7 @@ void do_fpaintbuts(unsigned short event)
}
break;
case B_BRUSHKEEPDATA:
brush_toggle_fake_user(settings->imapaint.brush);
brush_toggled_fake_user(settings->imapaint.brush);
allqueue(REDRAWBUTSEDIT, 0);
allqueue(REDRAWIMAGE, 0);
break;

View File

@@ -296,7 +296,7 @@ void do_image_buttons(unsigned short event)
}
break;
case B_KEEPDATA:
brush_toggle_fake_user(settings->imapaint.brush);
brush_toggled_fake_user(settings->imapaint.brush);
allqueue(REDRAWIMAGE, 0);
allqueue(REDRAWBUTSEDIT, 0);
break;

View File

@@ -384,10 +384,7 @@ int std_libbuttons(uiBlock *block, short xco, short yco,
}
if(keepbut) {
if(id->flag & LIB_FAKEUSER)
uiDefBut(block, BUT, keepbut, "F", xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Don't save this datablock even if it has no users");
else
uiDefBut(block, BUT, keepbut, "F", xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Saves this datablock even if it has no users");
uiDefButBitS(block, TOG, LIB_FAKEUSER, keepbut, "F", xco,yco,XIC,YIC, &id->flag, 0, 0, 0, 0, "Saves this datablock even if it has no users");
xco+= XIC;
}
}
@@ -1649,13 +1646,11 @@ void do_global_buttons(unsigned short event)
id= (ID *)G.saction->action;
}/* similar for other spacetypes ? */
if (id) {
if( id->flag & LIB_FAKEUSER) {
id->flag -= LIB_FAKEUSER;
id->us--;
} else {
id->flag |= LIB_FAKEUSER;
/* flag was already toggled, just need to update user count */
if(id->flag & LIB_FAKEUSER)
id->us++;
}
else
id->us--;
}
allqueue(REDRAWHEADERS, 0);