Page MenuHome

Crash updating string custom property with frame_change handler
Closed, ResolvedPublic

Description

--- Blender version with error, and version that worked ---
SVN r60747

--- Short description of error ---
If you set up a frame_change_pre handler that updates a custom string property based on the current frame value, Blender will crash if you move the mouse cursor over the custom property's panel in the Properties editor. Example .blend and gdb backtrace attached.

--- Steps for others to reproduce the error (preferably based on attached .blend file) ---

1. Open the attached .blend file and run the script in the Text Editor.
2. Go to the 3D View and play back the animation (Alt+A).
3. Move the mouse cursor to the bottom of the Properties Editor, specifically "MyString" custom property
4. Witness crashage.

Event Timeline

Just small addition: you need to run the script before playback :)

General issue here is that the button stores the IDProperty string pointer, which turns invalid when setting the string (and is not immediately redrawn).

Correction: The problem is not simply the string value (this is not actually stored in string buttons), but the uiBut->rnaprop pointer. For regular RNA props it can be relied upon insofar as these PropertyRNA pointers stay valid. But in the case of plain IDProperties the "rnaprop" pointer is actually an IDProperty*, with the MAGIC flag set to tell them apart (common RNA hack). However, IDProperties do get freed when replacing their values, which invalidates but->rnaprop.

@Campbell Barton (campbellbarton), can you please check this report? You're the most familiar with custom props and so..

Discussed this with Campbell on IRC a while back. IIRC our conclusion was that forcing a redraw when changing ID properties is the easiest solution for now, although not really nice.

Alternatively we'd need a safe way of referencing IDProperty from buttons instead of just storing a pointer and hoping for the best. This would probably be a lot of work, considering how many functions access these pointers.

Campbell Barton (campbellbarton) changed the task status from Unknown Status to Resolved.Nov 10 2014, 5:12 PM