Pose UI hack needed to be undone, alternate fix is needed. #30937

Closed
opened 2012-04-13 11:29:30 +02:00 by Campbell Barton · 7 comments

%%%------------------------------------------------------------------------
r34885 | aligorith | 2011-02-16 12:46:32 +1100 (Wed, 16 Feb 2011) | 18 lines

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...

Index: source/blender/python/intern/bpy_rna.c


- source/blender/python/intern/bpy_rna.c	(revision 34884)

+++ source/blender/python/intern/bpy_rna.c (revision 34885)
@@ -699,6 +699,10 @@
MEM_freeN((void *)enum_str);
return 0;
} else {

  •   /* hack so that dynamic enums used for operator properties will be able to be built (i.e. context will be supplied to itemf)
    
  •    * and thus running defining operator buttons for such operators in UI will work */
    
  •   RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); 
    
  •   if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, val)) {
      	const char *enum_str= pyrna_enum_as_string(ptr, prop);
      	PyErr_Format(PyExc_TypeError, "%.200s enum \"%.200s\" not found in (%.200s)", error_prefix, param, enum_str);
    

%%%

%%%------------------------------------------------------------------------ r34885 | aligorith | 2011-02-16 12:46:32 +1100 (Wed, 16 Feb 2011) | 18 lines 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... Index: source/blender/python/intern/bpy_rna.c **** - source/blender/python/intern/bpy_rna.c (revision 34884) +++ source/blender/python/intern/bpy_rna.c (revision 34885) @@ -699,6 +699,10 @@ MEM_freeN((void *)enum_str); return 0; } else { + /* hack so that dynamic enums used for operator properties will be able to be built (i.e. context will be supplied to itemf) + * and thus running defining operator buttons for such operators in UI will work */ + RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); + if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, val)) { const char *enum_str= pyrna_enum_as_string(ptr, prop); PyErr_Format(PyExc_TypeError, "%.200s enum \"%.200s\" not found in (%.200s)", error_prefix, param, enum_str); ------------------------------------------------------------------------ %%%
Author
Owner

Changed status to: 'Open'

Changed status to: 'Open'
Author
Owner

%%%Aligorith: tested poselib UI and couldn't get it to fail. What case was this needed for exactly?%%%

%%%Aligorith: tested poselib UI and couldn't get it to fail. What case was this needed for exactly?%%%
Member

%%%Check the attached file. Immediately after loading the file, if trying to remove the selected pose, "Pose" (unselected) gets removed instead of "Pose.002" (selected). This does not happen when this fix was applied.

I'm currently going through and checking for other cases where this sort of problem may also be occurring...%%%

%%%Check the attached file. Immediately after loading the file, if trying to remove the selected pose, "Pose" (unselected) gets removed instead of "Pose.002" (selected). This does not happen when this fix was applied. I'm currently going through and checking for other cases where this sort of problem may also be occurring...%%%
Author
Owner

%%%@Joshua, still cant redo this, I'm going into the pose panels "Pose Library" and pressing "-" button. this is working as expected.%%%

%%%@Joshua, still cant redo this, I'm going into the pose panels "Pose Library" and pressing "-" button. this is working as expected.%%%
Member

%%%Strange.

I'd previously found that just reloading the file within the same Blender session and the trying again will end up masking these problems. That is, it only shows when starting Blender from scratch.%%%

%%%Strange. I'd previously found that just reloading the file within the same Blender session and the trying again will end up masking these problems. That is, it only shows when starting Blender from scratch.%%%
Author
Owner

%%%applied alternative fix r45876. closing.%%%

%%%applied alternative fix r45876. closing.%%%
Author
Owner

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#30937
No description provided.