Page MenuHome

Refactor our ID copying and freeing code
AbandonedPublic

Authored by Bastien Montagne (mont29) on Jun 16 2017, 12:04 PM.

Details

Summary

This is initial (and partial/incomplete) implementation of T51804.

Some notes about current patch:

I) Compared to T51804, also added new handling of freeing (since things like 'not in Main', 'not user-refcounting' etc. also are crucial to be correctly handled by freeing code.

II) It is not finished! This is first step, laying out new API and general behavior. Lots of work remains to get master-ready patch, mostly monkey-coding in copy area.

III) It aims at not breaking anything (obviously), also for current branches. To do so, it mostly defines *new* functions, and avoids changing signature/behavior of existing ones in most cases. That's why we have some duplicated code/functionnality, goal is to get rid of deprecated functions later, as smoothly as possible for everybody.

IV) Biggest changes (and most noisy ones) will be in copy code, since right now most of it always assumes to always increment usercount of used IDs. Not sure if we want to double all those functions with _ex versions taking flag optionsparameter, or to directly modify existing ones? The former would ensure we do not break any existing branch, the later would avoid adding too much new functions...

Diff Detail

Repository
rB Blender
Branch
id_copy_refactor
Build Status
Buildable 696
Build 696: arc lint + arc unit

Event Timeline

Bastien Montagne (mont29) updated this revision to Diff 9003.EditedJul 11 2017, 8:08 PM

So, biggest initial work is done, new copy system shall be usable now.

Some notes:

  • Sound and VFont are now also copyable - code is a bit theoric here though...
  • Scene copying was quite heavily refactored to behave same as other datablocks in default copying.
  • Nuked some ID's custom copying code (like ugly creation of empty datablock + manual copying of data from source, yuck!), now all use same standard operations.
  • Datablock copy callbacks are now named '..._copy_data()', because they only copy internal data, not ID itself at all.
  • Those changes also implied some update of some neighbor code (like some sub-data copying functions).
  • Am not happy with dirty hack in VFont copying, thing is, BLI' freefont uses BKE's Nurbs... design sounds nasty to me here :/
  • I refrained from trying to move everyting to new code for now - better first get it tested a bit seriously and put into master, before trying to handle things like 'localize' functions used by rendering process...
  • Code is designed to allow evolution in copy behaviors (the flag system), we probably will need to refine a bit options there as we use it more and more.

  • Make object copying fully compatible/aware of new copy flag system.
  • Add Mesh and Key support to new copying code.
  • Fix wrong assert, and issue with Key ID freeing tag after copying from mesh...
  • Add new Curve copying code.
  • Add mball and lattice new copying, tweak a bit more skey handling.
  • Add remaining 'new copying' for obdata ID types.
  • Initial work on new copying for nodetrees.
  • Change a bit ideas behind new copying code, now ID-specific copying never handles usercount.
  • Move Material, Texture and Image datablocks to new copying code.
  • Rename new BKE_<foo>_copy_ex to BKE_<foo>_copy_data.
  • Move World and MovieClip to new copying system.
  • Move Group and ParticleSettings to new copying system.
  • Merge branch 'master' into id_copy_refactor
  • Move Action to new copying code.
  • Move Text, Brush and GPencil datablocks to new copying code.
  • Move Mask and FreestyleLineStyle to new ID copying code.
  • Move Palette, PaintCurve and CacheFIle to new ID copying system.
  • Add Sound copying callback.
  • Add VFont copying.
  • Huuuuge refactor of Scene copying, added to generic library ID copying.
  • Fix several crashes and other issues in new ID copying code.
  • Fix stupid mistake in new LineStyle copying code.

@ potential reviewers: This is a huge patch, but main entry point to review are changes in library.c (and BKE_library.h), those define and control the new behavior.

All changes done in other BKE files for every datatypes are more like boring reorganization, except for the Scene one (and maybe a few others), nice to check, but can be also mostly ignored.