Fix (IRC reported) bad handling of Text data-block user count.

Reported on IRC by dfelinto, thanks.

Root of the issue was that opening a new text file would create
datablock with one user, when Text editor is actually a 'user one' user.

This was leaving Text datablocks in inconsitent user count, and
generating asserts in BKE_library area.

Also changed a weird piece of code related to that extra user thing in
main remapping func.
This commit is contained in:
Bastien Montagne 2017-01-04 14:07:38 +01:00
parent 351a9d084f
commit a9163f7d22
3 changed files with 3 additions and 2 deletions

View File

@ -522,8 +522,7 @@ void BKE_libblock_remap_locked(
* been incremented for that, we have to decrease once more its user count... unless we had to skip
* some 'user_one' cases. */
if ((old_id->tag & LIB_TAG_EXTRAUSER_SET) && !(id_remap_data.status & ID_REMAP_IS_USER_ONE_SKIPPED)) {
id_us_min(old_id);
old_id->tag &= ~LIB_TAG_EXTRAUSER_SET;
id_us_clear_real(old_id);
}
BLI_assert(old_id->us - skipped_refcounted >= 0);

View File

@ -410,6 +410,7 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const
}
ta = BKE_libblock_alloc(bmain, ID_TXT, BLI_path_basename(filepath_abs));
ta->id.us = 0;
BLI_listbase_clear(&ta->lines);
ta->curl = ta->sell = NULL;

View File

@ -254,6 +254,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
}
else if (st) {
st->text = text;
id_us_ensure_real(&text->id);
st->left = 0;
st->top = 0;
st->scroll_accum[0] = 0.0f;