Commit Graph

78 Commits

Author SHA1 Message Date
Bastien Montagne 9f090bac5c IDProperties: add a foreach looper and use it in libquery code.
Note: part of fix for T75279.

Differential Revision: https://developer.blender.org/D7550
2020-04-28 15:25:19 +02:00
Bastien Montagne af00fab312 IDProps: add utility to set an ID pointer IDProp value. 2020-01-24 11:39:21 +01:00
Lukas Stockner ece4515fc8 Fix T71250: ID user decrement error with ID properties in ViewLayer
Credit for the original patch goes to @scorpion81.
2019-11-04 15:02:03 +01:00
Jacques Lucke e60890075b Cleanup: rename IDP_FreeProperty_ex to IDP_FreePropertyContent_ex
This was missing from rBdb5120603f.
2019-05-16 14:17:50 +02:00
Jacques Lucke db5120603f Refactor: Simplify ID Property freeing
This also makes `IDP_CopyProperty` the "opposite"
of `IDP_FreeProperty`, which is what I'd expect.

Two refactoring steps:
* rename IDP_FreeProperty to IDP_FreePropertyContent
* new IDP_FreeProperty function that actually frees the property

Reviewers: brecht

Differential Revision: https://developer.blender.org/D4872
2019-05-16 14:11:11 +02:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton c0f88ed8a8 Cleanup: sort forward declarations of enum & struct
Done using:
  source/tools/utils_maintenance/c_sort_blocks.py
2019-01-28 21:17:58 +11:00
Campbell Barton 06a1a66a9b Merge branch 'master' into blender2.8 2018-06-17 17:10:19 +02:00
Campbell Barton 6fc8a74886 Cleanup: trailing space for blenkernel 2018-06-17 17:05:51 +02:00
Campbell Barton 29aa531e51 Merge branch 'master' into blender2.8 2018-05-05 14:42:15 +02:00
Campbell Barton d3b3df0371 IDProp API: add native C repr function
Was using Python which wasn't very efficient (even for logging).
2018-05-05 14:41:25 +02:00
Campbell Barton b3545ae373 Merge branch 'master' into blender2.8 2018-05-04 07:30:14 +02:00
Campbell Barton f3c5b0394f IDProp API: expose repr utility function
Useful for logging properties passed to operators.
2018-05-04 07:29:05 +02:00
Sergey Sharybin 56a336196d Add utility function to reset ID property value to a given one
This is similar to idproperty_reset() defined in layer.c, but it does not
re-alloc property itself.

We should replace idproperty_reset() with IDP_Reset() now.
2018-01-24 15:04:46 +01:00
Bastien Montagne c8b3f13c9e Bring new IDP_MergeGroup() on par with other copying logic.
We now have to support more complex copying types, which are controlled
by flags, so all copying logic will need to take those at some point (at
least, all potentially dealing with IDs).
2017-08-15 16:42:20 +02:00
Bastien Montagne 41830cc432 Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).

This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.

It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).

Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!

As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.

Design task : T51804
Phab Diff: D2714
2017-08-07 20:34:36 +02:00
Bastien Montagne 9da7dfa158 Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).

This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.

It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).

Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!

As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.

Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
Dalai Felinto 66c74242bb Make IDP_MergeGroup recursive
With this we also do not need IDP_MergeGroupValues anymore.
If this causes problems in the future we can always make recursion an
option (like overwrite is).
2017-05-03 11:51:49 +02:00
Dalai Felinto 3cb0e8e1af IDProperty: New util function to merge groups recursively 2017-04-20 11:00:32 +02:00
Alexander Romanov a7b3047cef Datablock ID Properties
The absence of datablock properties "will certainly be resolved soon as the need for them is becoming obvious" said the [[http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.67/Python_Nodes|Python Nodes release notes]]. So this patch allows Python scripts to create ID Properties which reference datablocks.
This functionality is implemented for `PointerProperty` and now such properties can be created with Python.

In addition to the standard update callback, `PointerProperty` can have a `poll` callback (standard RNA) which is useful for search menus. For details see the test included in this patch.

Original author: @artfunkel

Alexander (Blend4Web Team)

Reviewers: brecht, artfunkel, mont29, campbellbarton

Reviewed By: mont29, campbellbarton

Subscribers: jta, sergey, campbellbarton, wisaac, poseidon4o, mont29, homyachetser, Evgeny_Rodygin, AlexKowel, yurikovelenov, fjuhec, sharlybg, cardboard, duarteframos, blueprintrandom, a.romanov, BYOB, disnel, aditiapratama, bliblubli, dfelinto, lukastoenne

Maniphest Tasks: T37754

Differential Revision: https://developer.blender.org/D113
2017-04-13 12:33:05 +03:00
Campbell Barton aab4f2b762 cleanup: redundant casts & const cast correctness 2015-01-01 23:42:28 +11:00
Campbell Barton 28a0e1dae5 Fix T42883: ID-Prop arrays longer than 'shot' fail 2014-12-12 16:25:32 +01:00
Campbell Barton 3346ab0348 Fix/workaround T37073: Crash updating custom props visible in the UI 2014-11-10 17:10:58 +01:00
Campbell Barton 4b3f1b7540 Cleanup: remove rarely used IDProp iterator 2014-11-03 17:06:14 +01:00
Sergey Sharybin 3e41c8ad6f Fix compilation error with debug scons
The issue is that we've got hell with DEBUG and _DEBUG,
theu're defined really inconsistent acros CMake and SCons.

Used more reliable NDEBUG definition for IDP_spit.
2014-08-11 20:58:42 +06:00
Campbell Barton a90e49e40a Tweaks to macros 2014-08-04 11:43:10 +10:00
Campbell Barton 7f32cf4605 Prevent macros hiding casts from `const` pointers 2014-08-01 22:03:03 +10:00
Campbell Barton 2195dd32cc Fix T37595: Switching modal transform broke with trackball rotation.
Id properties may have different sized "values" array depending on the
transform operator
2013-12-13 00:35:12 +11:00
Campbell Barton 8a7f2b24c1 Code Cleanup: use const's and bools for idprops 2013-12-13 00:35:11 +11:00
Campbell Barton 089d0ad8f9 add IDP_FreeFromGroup(), replaces IDP_RemFromGroup(), IDP_FreeProperty(), MEM_freeN(). 2013-10-16 05:29:28 +00:00
Sergey Sharybin 35b61a7512 Move GCC attributes into a centraized defines
Instead of having ifdef __GNUC__ all over the headers
to use special compiler's hints use a special file where
all things like this are concentrated.

Makes code easier to follow and allows to manage special
attributes in more efficient way.

Thanks Campbell for review!
2013-09-01 15:01:15 +00:00
Campbell Barton 418011907c remove nan copyrights from code added since blender become opensource (copy paste errors), also remove BKE_script.h 2013-07-02 10:14:59 +00:00
Campbell Barton 08aef8a7c8 code cleanup: move doxy docs from headers into source. also replace strncpy();str[len]=0 with BLI_strncpy() in BLI_stringdec(). 2013-03-24 01:51:54 +00:00
Campbell Barton 1a7638fa94 add id property clear function (matching the same python function for dicts/lists) 2013-01-02 23:10:14 +00:00
Campbell Barton 9b948717b0 code cleanup: float <> double conversion. 2012-11-03 18:23:30 +00:00
Campbell Barton 1bcadda46b fix [#30910] Problems: Add Shortcut(s) for "Ctrl Tab" menu
comparing keymaps was too sloppy or too strict, now sloppy keymap comparison works by setting all the operator
properties to their default values if they are not already set, then compare this with the keymap item (ignoring values missing from either one).

... this way any non default keymap setting wont match with an operator menu item which doesnt set this operator at all (a problem sighted in this bug report).


developer notes:
- IDP_EqualsProperties_ex() function adds an argument to treat missing members of either group to act as if there is a match.
- WM_operator_properties_default() function to reset RNA values to their defaults.
- add IDP_spit(), debug only function to print out ID properties.
2012-10-31 20:29:32 +00:00
Campbell Barton c7fbeded4c add IDP_MergeGroup(dst, src, overwrite) function,
like PyDict_Merge()
2012-10-31 19:07:25 +00:00
Campbell Barton 2580575658 correct another case of nonnull (all should be correct now), and comment about color conversion. 2012-07-08 17:51:28 +00:00
Campbell Barton 0c7b56cf39 correct use of nonull attribute 2012-07-08 17:08:27 +00:00
Campbell Barton b91bc4f037 use gcc attrubutes to warn on unused return values and arguments which shouldnt be NULL.
also remove IDP_AppendArray's return value which wasnt the new item in the array (which is odd/misleading), but wasnt used anywhere either.
2012-07-08 06:00:27 +00:00
Campbell Barton 9892736206 code cleanup: header cleanup and remove some duplicate defines. 2012-05-12 20:39:39 +00:00
Campbell Barton 4f7bdc59d3 style cleanup: spelling.
also remove large, duplicate comments from sunsky.h
2012-03-09 00:41:09 +00:00
Campbell Barton 95670e03a0 style cleanup / comment formatting for bli/bke/bmesh 2012-03-03 20:19:11 +00:00
Campbell Barton 7cc206ddca Code Cleanup: remove non existing function declarations.
added some missing functions too - which are not used yep but should be there for api completeness.
* CDDM_set_mloop
* CDDM_set_mpoly
* BLI_mempool_count
2012-02-29 15:00:37 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Campbell Barton 8623935aa8 pass a pointer to IDP_New's IDPropertyTemplate rather then a copy. 2011-11-15 09:22:52 +00:00