Editing driver's expression eliminates "Zero" number #50063

Closed
opened 2016-11-17 18:33:36 +01:00 by Serge Lyatin · 8 comments

System Information
Win7 32bit

Blender Version
Broken: 2.78a

Exact steps for others to reproduce the error
Driver expression has got "zero" number at the end of line. Now click left mouse button into the violet "X Location" menu and zero somehow gone away.

Driver_zero.jpg

Driver_zero.blend

**System Information** Win7 32bit **Blender Version** Broken: 2.78a **Exact steps for others to reproduce the error** Driver expression has got "zero" number at the end of line. Now click left mouse button into the violet "X Location" menu and zero somehow gone away. ![Driver_zero.jpg](https://archive.blender.org/developer/F402634/Driver_zero.jpg) [Driver_zero.blend](https://archive.blender.org/developer/F402636/Driver_zero.blend)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @SergeL

Added subscriber: @SergeL
Member

Added subscribers: @JulianEisel, @mont29, @JoshuaLeung

Added subscribers: @JulianEisel, @mont29, @JoshuaLeung
Member

Confirmed.

Hmm... this looks suspiciously like a bug in the UI code related to the way that it trims off excess zeros off the end of numbers. Some observations:

  • Once it has removed the zero, it doesn't remove any more digits/characters in subsequent editing cycles
  • If we replace the 0 with a 1 (or add a 1 after it), no truncation occurs.

@mont29 / @JulianEisel - Sounds like something for you guys to look into?

Confirmed. Hmm... this looks suspiciously like a bug in the UI code related to the way that it trims off excess zeros off the end of numbers. Some observations: * Once it has removed the zero, it doesn't remove any more digits/characters in subsequent editing cycles * If we replace the 0 with a 1 (or add a 1 after it), no truncation occurs. @mont29 / @JulianEisel - Sounds like something for you guys to look into?
Julian Eisel self-assigned this 2016-11-18 02:14:36 +01:00
Member

Would propose this as fix: P425: Possible fix for #50063

diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 991cd54..5b2da6c 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -99,6 +99,10 @@ void ui_but_anim_flag(uiBut *but, float cfra)
        }
 }
 
+/**
+ * \a str can be NULL to only perform check if \a but has expression at all.
+ * \return if button has an expression.
+ */
 bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
 {
        FCurve *fcu;
@@ -111,7 +115,9 @@ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
                driver = fcu->driver;
 
                if (driver && driver->type == DRIVER_TYPE_PYTHON) {
-                       BLI_strncpy(str, driver->expression, maxlen);
+                       if (str) {
+                               BLI_strncpy(str, driver->expression, maxlen);
+                       }
                        return true;
                }
        }
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index f3eeadb..fc511d6 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3067,7 +3067,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
                data->str = ui_but_string_get_dynamic(but, &data->maxlen);
        }
 
-       if (ui_but_is_float(but) && !ui_but_is_unit(but)) {
+       if (ui_but_is_float(but) && !ui_but_is_unit(but) && !ui_but_anim_expression_get(but, NULL, 0)) {
                BLI_str_rstrip_float_zero(data->str, '\0');
        }
 

It disables trimming of trailing zeros in case the button contains an expression.

Would propose this as fix: [P425: Possible fix for #50063](https://archive.blender.org/developer/P425.txt) ``` diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 991cd54..5b2da6c 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -99,6 +99,10 @@ void ui_but_anim_flag(uiBut *but, float cfra) } } +/** + * \a str can be NULL to only perform check if \a but has expression at all. + * \return if button has an expression. + */ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen) { FCurve *fcu; @@ -111,7 +115,9 @@ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen) driver = fcu->driver; if (driver && driver->type == DRIVER_TYPE_PYTHON) { - BLI_strncpy(str, driver->expression, maxlen); + if (str) { + BLI_strncpy(str, driver->expression, maxlen); + } return true; } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f3eeadb..fc511d6 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3067,7 +3067,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) data->str = ui_but_string_get_dynamic(but, &data->maxlen); } - if (ui_but_is_float(but) && !ui_but_is_unit(but)) { + if (ui_but_is_float(but) && !ui_but_is_unit(but) && !ui_but_anim_expression_get(but, NULL, 0)) { BLI_str_rstrip_float_zero(data->str, '\0'); } ``` It disables trimming of trailing zeros in case the button contains an expression.

@JulianEisel fix LGTM.

@JulianEisel fix LGTM.

This issue was referenced by 3fb11061ba

This issue was referenced by 3fb11061bad7c76ea53925ed599ee155b0d4222f
Member

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
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#50063
No description provided.