Page MenuHome

Fix T37599: Crash making linked objects local and undo
ClosedPublic

Authored by Sergey Sharybin (sergey) on Feb 28 2014, 12:09 PM.

Details

Summary

Root of the issues comes to the fact that it's possible to produce
a situation when library object data uses local object. This is
actually forbidden and not supported by .blend IO.

Made it so Make Local wouldn't produce such an unsupported states.

Diff Detail

Repository
rB Blender
Branch
fix_T37599

Event Timeline

The solution doesn't really seem generic enough with only curve bevel/taper and modifiers taken into account. This skips for example Mesh.texcomesh and probably other pointers too? Should there be some kind of generic datablock function to loop over these pointers?

Sergey Sharybin (sergey) updated this revision to Unknown Object (????).Mar 6 2014, 2:46 PM

Mae it a generic looper function

Node tree looping is not supported yet, we don't have
any utility function to do this unfortunately.

We could optimize things a bit bu adding flags like SKIP_MATERIALS to this looper. Pretty much straightforward to add if we agree on general layout.

Talked to Lukas in IRC, we don't allow having IDs in nodes other than in node->id. Simple to implement. Will do it.

Brecht Van Lommel (brecht) requested changes to this revision.Mar 7 2014, 3:34 PM

@Brecht Van Lommel (brecht), what are exact changes you expect to be done? (apart from what i've mentioned above) ?

Oops, forgot the inline comments in another tab.

source/blender/blenkernel/intern/library.c
1634 ↗(On Diff #1190)

Particle systems have parent, target_ob, and the group for field weights.

1776 ↗(On Diff #1190)

Lamps have nodetrees too.

1805 ↗(On Diff #1190)

Worlds have node trees too.

Sergey Sharybin (sergey) updated this revision to Unknown Object (????).Mar 10 2014, 12:36 PM

Some fixes

General comments on having an ID looper.

Even at thie basic level I think the patch could be extended a bit.

  • have LibraryIDLinkCallback accept a single flag argument, so data about the ID can be passed (LibraryForeachIDEnum or so...)
    • NEVER_NULL
    • NEVER_SELF
    • ID_USER

realize this duplicates some info from RNA, but think this can't be helped.
to begin with just adding NEVER_NULL would be handy, then at least other flags can be added later.

Some way to avoid null check on every member before use could be nice too (can be done with macro but Im sure you wont like this :) )

Note: to avoid doubling up when checking for NULL and calling, it could do this...

if (mesh->texcomesh) {
    callback(user_data, &mesh->texcomesh->id);
}

with this...

id = &mesh->texcomesh->id;
if (id) {
    callback(user_data, id);
}

Link to edit to this diff which uses a NULL check macro to make BKE_library_foreach_ID_link more compact.

http://pastebin.com/cA7PdPee

Additional types to support...

  • Scene? - objects, camera, world, set, marker-camera links, toolsettings (brush), sequencer data + all its strip id links (mask, movieclip, sound, camera override)
  • Screen? scene
  • Object Pose (display object, pose constraints)

... i could go on and keep checking more.

... is it worth making this more comprehensive?

Sergey Sharybin (sergey) updated this revision to Unknown Object (????).Mar 26 2014, 10:56 AM

Made it more genericfunction

Sergey Sharybin (sergey) updated this revision to Unknown Object (????).Mar 26 2014, 10:58 AM

Forgot this in previous patch

Sergey Sharybin (sergey) updated this revision to Unknown Object (????).Mar 26 2014, 11:59 AM

Update with the changes from Campbell

Sergey Sharybin (sergey) updated this revision to Unknown Object (????).Mar 26 2014, 12:59 PM

Get rid of unneeded headers in library_query

Also make it possible to abort iteration by returning
'false' from the callback.

Generally LGTM, some comments,.

source/blender/blenkernel/BKE_library_query.h
38

Not totally happy with this prefix, ID_ is used for lots of general stuff.

Maybe
-IDFOREACH_*** ?, not much nicer.

  • IDITER_***
  • IDWALK_***
source/blender/blenkernel/intern/library_query.c
68

Suggest comment,,,

/* ID invoke wrapper, _PP (pointer-to-pointer = (ID **)) */
137

Simple doxy comment would be nice.

/**
 * Loop over all of the ID's this datablock links to.
 *
 * \note: May be extended to be recursive in the future.
 */