Selection menu for properties does not preselect current item. #60817

Closed
opened 2019-01-24 14:11:11 +01:00 by matc · 12 comments

System Information
Operating system:
Graphics card:

Blender Version
Broken:
2.80, a3261aad13, 2019-01-04
2.79, f4dc9f9d68, 2018-03-22 (is slightly less broken than 2.80)
Worked:

Short description of error
No item or the wrong item is selected when the selection menu of a property is opened.

Exact steps for others to reproduce the error
Open default startup .blend.
Add "Copy Location" constraint to "Cube". (Bug is not limited to constraints.)
Set Target to "Light"
Open selection menu again for Target. "Camera" will be highlighted instead of "Light".

Possible fix
The attached diff passes the data behind PointerRNA *ptr as active item. This ends up in overwriting the current value of but->func_arg2. I can't tell whether this will cause problems somewhere else.
preselect.diff

**System Information** Operating system: Graphics card: **Blender Version** Broken: 2.80, a3261aad130e, 2019-01-04 2.79, f4dc9f9d68b, 2018-03-22 (is slightly less broken than 2.80) Worked: **Short description of error** No item or the wrong item is selected when the selection menu of a property is opened. **Exact steps for others to reproduce the error** Open default startup .blend. Add "Copy Location" constraint to "Cube". (Bug is not limited to constraints.) Set Target to "Light" Open selection menu again for Target. "Camera" will be highlighted instead of "Light". **Possible fix** The attached diff passes the data behind `PointerRNA *ptr` as active item. This ends up in overwriting the current value of `but->func_arg2`. I can't tell whether this will cause problems somewhere else. [preselect.diff](https://archive.blender.org/developer/F6389414/preselect.diff)
Author

Added subscriber: @matc

Added subscriber: @matc
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Can confirm.

Best would be if you submit you proposed fix as patch so that devs that know more about the side effects can do a code review.

Can confirm. Best would be if you submit you proposed fix as patch so that devs that know more about the side effects can do a code review.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Setting low priority since this isn't new in 2.8x.

Setting low priority since this isn't new in 2.8x.
Author

I think the easiest way to fix this, is to use the property value as active item in ui_searchbox_update.

I previously thought that but->func_arg2 was NULL whenever the active item was not displayed correctly. But apparently it is set to block->func_arg2. And the same happens with but->func. This means there is not really a way to update func_arg2 without messing up the expected arguments for func.

This works fine with PROP_POINTER, and as before for everything else:

diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index 251bc86a3f5..a647693b75f 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -325,9 +325,20 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
     data->items.offset_i = data->items.offset = 0;
     data->active = -1;

-    /* handle active */
-    if (but->search_func && but->func_arg2) {
+    if (but->rnapoin.data && but->rnaprop && RNA_property_type(but->rnaprop) == PROP_POINTER) {
+      /* Buttons that prepare the search box through ui_but_add_search get in ui_def_but their
+       * func_arg2 set to the same value as its block. Therefore if we have a property, using the
+       * property value as the active item makes more sense here.
+       */
+      PointerRNA ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
+      data->items.active = ptr.data;
+    }
+    else {
       data->items.active = but->func_arg2;
+    }
+
+    /* handle active */
+    if (but->search_func && data->items.active) {
       but->search_func(C, but->search_arg, but->editstr, &data->items);
       data->items.active = NULL;



I think the easiest way to fix this, is to use the property value as active item in ui_searchbox_update. I previously thought that but->func_arg2 was NULL whenever the active item was not displayed correctly. But apparently it is set to block->func_arg2. And the same happens with but->func. This means there is not really a way to update func_arg2 without messing up the expected arguments for func. This works fine with PROP_POINTER, and as before for everything else: ``` diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c index 251bc86a3f5..a647693b75f 100644 --- a/source/blender/editors/interface/interface_region_search.c +++ b/source/blender/editors/interface/interface_region_search.c @@ -325,9 +325,20 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset) data->items.offset_i = data->items.offset = 0; data->active = -1; - /* handle active */ - if (but->search_func && but->func_arg2) { + if (but->rnapoin.data && but->rnaprop && RNA_property_type(but->rnaprop) == PROP_POINTER) { + /* Buttons that prepare the search box through ui_but_add_search get in ui_def_but their + * func_arg2 set to the same value as its block. Therefore if we have a property, using the + * property value as the active item makes more sense here. + */ + PointerRNA ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop); + data->items.active = ptr.data; + } + else { data->items.active = but->func_arg2; + } + + /* handle active */ + if (but->search_func && data->items.active) { but->search_func(C, but->search_arg, but->editstr, &data->items); data->items.active = NULL; ```

Added subscriber: @jenkm

Added subscriber: @jenkm

Can't reproduce, has it been fixed? I tried it in 3.1.0 and 2.93.5.

Can't reproduce, has it been fixed? I tried it in 3.1.0 and 2.93.5.

Changed status from 'Confirmed' to: 'Needs Triage'

Changed status from 'Confirmed' to: 'Needs Triage'

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Germano Cavalcante self-assigned this 2022-02-16 15:06:15 +01:00

I reproduced this bug in the 2.80, but not the latest daily build, so it appears the bug has been fixed already.

If the problem persists, please let us know so we can re-open the report.

I reproduced this bug in the 2.80, but not the latest daily build, so it appears the bug has been fixed already. If the problem persists, please let us know so we can re-open the report.
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
5 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#60817
No description provided.