Commit Graph

466 Commits

Author SHA1 Message Date
90d42e114c py/rna: BPy_reports_to_error() now takes the exception type as an argument and returns -1 as an error value 2011-03-12 15:18:08 +00:00
c678bd2d7d py/rna, ability to have python static methods in collections. 2011-03-12 14:32:30 +00:00
d7257a983f bugfix [#26454] WITH_PYTHON_SAFETY crash. 2011-03-11 02:43:30 +00:00
Nathan Letwory
5b6223fdeb Py_hash_t is new typedef in Python 3.2, typedeffing Py_ssize_t. Changing to that to keep "slow adaptors" happy ;) 2011-03-04 11:08:22 +00:00
Nathan Letwory
292f633698 long hash caused stack corruption in _PySet_NextEntry. This wanted a Py_hash_t, so made hash into such. 2011-03-04 10:37:49 +00:00
e197cc95e6 fix crash from own recent changes [#26271] Crash when accessing bpy.data.node_groups 2011-03-03 13:55:15 +00:00
b6b77b8426 Py/RNA api:
fix for crash when iterating over a collection which allocates the collection and frees on when finished.

The ability for BPy_StructRNA to hold a reference to other PyObject's was added to support this.
2011-03-03 09:16:06 +00:00
3a2ce2be83 Py/RNA api - real collection iterator
Previously the api just converted the collection to a list and got the iterator from the list to return.

This has the advantage that it uses minimal memory on large collections where before it would make an array.

Though the main reason for this change is to support a bugfix for collections which free memory when they are done, this currently crashes the python api since once the list is built, the data is freed which is used by the list items in some cases (dynamic enums for eg).
2011-03-03 07:41:09 +00:00
5f5fb5061b formatting edits. (no functional changes) 2011-03-03 05:42:16 +00:00
9c45fed287 Change RNA weakref code to use a ghash rather then a PyList, removing items from the list was far too slow. 2011-03-02 18:59:43 +00:00
415e8df10e simplify rna internal weakref use. 2011-03-02 16:56:13 +00:00
7159bc0b1c minor fixes to weakref validation before making bigger changes 2011-03-02 06:56:21 +00:00
e2304a4dbb move anim functions out of bpy_rna.c, its getting too big. 2011-03-02 04:51:43 +00:00
623822626a Py/RNA Stability: don't allow python to reference freed ID's and crash.
Second method for not having python crash blender on invalid access (ifdef'd out ATM, so no functional change).

This uses a weakref list per ID, and invalidates all members of that list when the ID is freed.
the list is not stores in the ID pointer but using a hash table since storing python in DNA data is not acceptable.

This is more correct then the previous method but shows down execution of scripts significantly since its always adding and removing from lists when data is created and freed.
2011-03-01 14:53:26 +00:00
c9ee017fb5 Py/RNA API test code to prevent crashing blender when python references freed ID's.
This uses pythons GC so its no overhead during runtime but makes removing ID's slower.

Commented definition 'USE_PYRNA_INVALIDATE_GC' for now, so no functional change.
2011-03-01 09:02:54 +00:00
7b636c717d bpy/rna support for invalidating objects.
access will raise an error.
2011-02-28 22:56:29 +00:00
55268331f6 missed these last commit. 2011-02-28 21:06:09 +00:00
7348a50d79 change return values from mathutils callbacks to match pythons (-1 is error), so error macro's can be used in both. 2011-02-28 18:42:41 +00:00
Nathan Letwory
5a760e22fc doxygen: blender/python tagged. 2011-02-27 20:10:08 +00:00
cd615f6fcc found moving verts in pythons 2.5 api is approx 10x slower because the multi-dimensional array assignment reads the array 3 times (typecheck, length-check & for-real).
the length check was running sequence checks on every number which would fail, small speedup by avoiding this.

should eventually get this working faster by reading once into an allocated array.
2011-02-24 08:47:58 +00:00
31c7d694e0 remove 2 unnecessary checks for array type before assignment. 2011-02-24 07:25:47 +00:00
65bb4ff8d1 py/rna api:
ifdef'd out weakref for blender/py api, worth testing to see if it adds much overhead.
2011-02-23 13:43:45 +00:00
Nathan Letwory
5b607701a7 doxygen: prevent GPL license block from being parsed as doxygen comment. 2011-02-23 10:52:22 +00:00
1e120098fc pyapi, use direct access to the frame rather then python attributes. 2011-02-22 07:57:18 +00:00
dd8383e469 make doc generation close files (py3.2 complains about this),
minor formatting changes for C docstrings.
2011-02-22 05:23:20 +00:00
6524d27462 py api was raising SystemError exception incorrectly, this is intended for internal interpreter problems.
Replace most with RuntimeError.
2011-02-18 06:04:05 +00:00
2ae5c3932d Change to how python classes are initialized when blender calls them.
Annoyance was that operators that defined and __init__ function would need to do...
    def __init__(self, another_self):
        ....

py/rna was calling the class directly with PyObject_Call() but needed to pass the pre-allocated object only so __init__() would run .
This works OK internally but becomes messy since __new__ and __init__ always get the same args there was no way to avoid a superfluous self argument to __init__.
2011-02-17 07:21:44 +00:00
73df566b4a error case not being handled when calling python classes from RNA 2011-02-17 06:56:24 +00:00
f5217afd18 Ugly hack to get PoseLib UI working ok (problem mentioned in log for
r34883).

Full description:
When defining an operator button in the UI layout code, trying to set
the value for such an operator's enum properties, where said enum uses
a dynamically generated list of items (which depends on using context
info), will "fail". No context info will be passed to the callbacks
used to generate this list of items, as PROP_ENUM_NO_CONTEXT is still
set on the operator properties (it seems these will only get cleared
when the operator actually runs, which is far too late already for
this usage) so RNA_property_enum_items() will pass NULL instead of a
context pointer *even* when one exists!

I'm not sure of why we even need this flag. It seems to have caused a
few other rounds of problems already, from quick searches I did on
this matter...
2011-02-16 01:46:32 +00:00
8b7482892b made most variables which are only used in a single file and not defined in header static for blenlib, blenkernel and editors. 2011-02-14 17:55:27 +00:00
d845d6308a comments for how py-rna calls api new classes. small speedup for StructRNA.__new__(...) used for creating new classes and corrected exception type. 2011-02-14 11:30:35 +00:00
a3c2ad34b1 improve py/rna exception messages. 2011-02-14 08:14:52 +00:00
a6765280f9 py rna api: turn class.is_register into a class property rather then a class method.
eg:

if MySybclass.is_registered:
    ...
2011-02-14 07:26:07 +00:00
72bc3f22b7 python api renaming and added headers for some files which didnt have one, no functionality change. 2011-02-14 04:15:25 +00:00
8ea0b4685c misc small changes:
- rename rna collection structs Main prefix to BlendData: eg, MainObjects --> BlendDataObjects
- printing python collection now prints its type (when available)
- renamed shadowed vars in bpy_rna.c.
- when making functions static I also made debugging/test functions static, reverse and add definitions to headers instead.
2011-02-14 03:15:55 +00:00
0955c664aa fix for warnings from Sparse static source code checker, mostly BKE/BLI and python functions.
- use NULL rather then 0 where possible (makes code & function calls more readable IMHO).
- set static variables and functions (exposed some unused vars/funcs).
- use func(void) rather then func() for definitions.
2011-02-13 10:52:18 +00:00
65b922ad88 cls.is_registered() class method for python subclasses of internal types.
Synonymous with ('bl_rna' in cls.__dict__)
2011-02-11 02:40:14 +00:00
fb8c135584 minor python register changes.
- KeyingSetInfo classes are now collected like Panels, Operators etc so bpy.utils.register_module() can be used.
- move bpy.types.register() to bpy.utils.register_class
2011-02-11 00:11:17 +00:00
19efa4301a fix crash from report [#25746] Adding keyframes to nested custom properties (IDProperties) of a bone causes segfault
though keyframing still doesn't work, it gives an error instead.
also use const char * in more parts of the py/rna api.
2011-02-01 23:53:54 +00:00
1c2bb084ac partial revert for r34590, exclude render() from enabling the read-only state.
will re-open [#25845] and assign to Brecht.
2011-02-01 20:38:24 +00:00
b17bbf9d95 fix for 2 segfaults running in background mode.
- operators which reload G.main would crash blender if called from python and then accessed bpy.data.*
- WM_read_homefile_exec was setting the contexts Scene to NULL as a signal for the event system, this didnt work in background mode, crashing when property update functions expected scene to be set.
2011-02-01 02:54:29 +00:00
11d61383fa workaround [#25845] Empty UI panels
- now writing to RNA is disabled when inside render() call.
- disallow calling operators when writes are disabled.

Rendering runs in a thread so running operators from the thread is not safe unless rendering becomes a blocking operator again.
2011-02-01 00:32:50 +00:00
45fc590835 internal changes, script writers won't notice.
disable getattr metaclass forwarding attributes from the python class, eg:
  bpy.types.Scene.foo != bpy.types.Scene.bl_rna.properties['foo']

... This was convenient but too tricky to properly maintain with attribute assignment and attributes defined within the class.
avoid doubles in dir() by converting to a set and then back to a list.
2011-01-27 06:48:14 +00:00
57289044ca improve unregister error check not to loop over parent classes properties (would check the same property multiple times) 2011-01-25 07:31:11 +00:00
c0e74f9dce fix [#25748] Addons register parameters/functions more than once
- values were added to both the classes __dict__ as well as the internal StructRNA.
- made properties available from the type since this is where the python api assigns them:
>>> bpy.types.Scene.frame_start
<bpy_struct, IntProperty("frame_start")>
- rename RNA_struct_type_properties() -> RNA_struct_type_properties(), added RNA_struct_type_find_property()
2011-01-25 06:54:57 +00:00
27cb6218a3 fix [#25778] Memoryblock Data from SCR: end corrupt
+ other minor changes.
2011-01-25 01:51:28 +00:00
c0f161f811 fix [#25776] Crash when operator's bl_idname has more than one dot 2011-01-24 05:15:14 +00:00
daa09a4a60 Raise an exception when registering classes with ID names which are too long. (related to bug ), found while looking into bug [#25776]. 2011-01-24 03:38:34 +00:00
3b0c2accc6 support building with python3.2 2011-01-18 21:39:50 +00:00
08dc18fda0 rename fcurve.keyframe_points.add() --> insert()
add new add function which allocates a number of points instead.
2011-01-18 11:27:52 +00:00