Fix #31702: Drag and Drop parenting crashes Blender

Crash was caused by recent changes in parent drop operator which were
aimed to prevent parenting objects between different scenes (which probably
makes sense).

The problem was how it was checked if objects belongs to the same scene --
outliner tree with type ID_SCE was used for this which works pretty nice
for All Scenes outliner view. But in other view modes there is no scene
element in outliner tree which lead to some NULL pointer dereferences.

Currently resolved this by assuming that if there's no Scene parent element
in outliner tree parent and child belongs to the same scene which is active
scene. This is truth for current view modes of outliner but if it'll be
changed in the future this assumption shall be updated and re-implemented
with some smarter checks of which scene object from outliner belongs to.
This commit is contained in:
Sergey Sharybin
2012-06-05 09:57:19 +00:00
parent ae8103240d
commit f885306bb8
2 changed files with 16 additions and 2 deletions

View File

@@ -1503,7 +1503,12 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
scene = (Scene *)outliner_search_back(soops, te_found, ID_SCE);
if (scene == NULL) {
return OPERATOR_CANCELLED;
/* currently outlier organized in a way, that if there's no parent scene
* element for object it means that all displayed objects belong to
* active scene and parenting them is allowed (sergey)
*/
scene = CTX_data_scene(C);
}
if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) {

View File

@@ -98,7 +98,16 @@ static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
if (te_valid) {
/* check that parent/child are both in the same scene */
Scene *scene = (Scene *)outliner_search_back(soops, te_valid, ID_SCE);
if (BKE_scene_base_find(scene, (Object *)id)) {
if (!scene) {
/* currently outlier organized in a way, that if there's no parent scene
* element for object it means that all displayed objects belong to
* active scene and parenting them is allowed (sergey)
*/
return 1;
}
if (scene && BKE_scene_base_find(scene, (Object *)id)) {
return 1;
}
}