Page MenuHome

Refactor writefile handling of data-blocks.
ClosedPublic

Authored by Bastien Montagne (mont29) on Feb 13 2017, 2:57 PM.

Details

Summary

Instead of calling a function looping over whole list of a given ID
type, make whole loop over Main in parent function, and call functions
writing a single datablock at a time.

This design is more in line with all other places in Blender where we
handle whole content of Main (including readfile.c), and much more easy
to extend and add e.g. some generic processing of IDs before/after
writing, etc.

From user point, there should be no change at all, only difference is
that data-block types won't be saved in same order as before (.blend
file specs enforces no order here, so this is not an issue, but it could
bug some third party users using other, simplified .blend file reader
maybe).

Diff Detail

Repository
rB Blender

Event Timeline

Bastien Montagne (mont29) retitled this revision from to Refactor writefile handling of data-blocks..
Bastien Montagne (mont29) updated this object.

Seems OK, although before and after - you have to manually add an entry for each ID type, so doesn't seem like that big of an advantage.


Edit, should the if (lt->id.us > 0 || wd->current) { checks on ID types be moved outside the functions, into the ID loop?

source/blender/blenloader/intern/writefile.c
3944

should add assert for default case, nice to error incase people forget adding new datablocks.

This revision is now accepted and ready to land.Mar 17 2017, 9:14 AM

Edit, should the if (lt->id.us > 0 || wd->current) { checks on ID types be moved outside the functions, into the ID loop?

Don’t think so, because some datablocks (Scene, WindowManager, Screen) do not check for actual user…

This revision was automatically updated to reflect the committed changes.