Outliner/Collections: Fix objects disappearing when moving to collections

Bug introduced on fb4cd136a7 (multi-object drag-and-drop).

How to reproduce the bug:
* Create a new collection
* Move the Cube to the new collection
* Move the Camera to the new collection (Cube disappears)
* Move the Lamp to the new collection (Camera disappears)

Explanation of the bug:
The moved object was still selected, so we were trying to add the object to the
collection were the object was already inserted (which would fail silently) and
then remove it.
This commit is contained in:
Dalai Felinto 2018-01-15 18:27:50 -02:00
parent b810e9ffc4
commit ae12424298
1 changed files with 3 additions and 2 deletions

View File

@ -412,8 +412,9 @@ bool BKE_collection_object_remove(Main *bmain, ID *owner_id, SceneCollection *sc
*/
void BKE_collection_object_move(ID *owner_id, SceneCollection *sc_dst, SceneCollection *sc_src, Object *ob)
{
BKE_collection_object_add(owner_id, sc_dst, ob);
BKE_collection_object_remove(NULL, owner_id, sc_src, ob, false);
if (BKE_collection_object_add(owner_id, sc_dst, ob)) {
BKE_collection_object_remove(NULL, owner_id, sc_src, ob, false);
}
}
/**