Function from Python not being loaded for Driver when project opened #61063

Closed
opened 2019-01-31 15:36:25 +01:00 by stephen thomas · 6 comments

System Information
Operating system: Pop!_OS (Debian) 18.10
Graphics card: GTX Titan X

Blender Version
Broken:
2.80 77eaa4790d
Worked: (optional)

A driver calls on a python function. The python function is internal and registered.

When the project is opened, the driver can't find the function, throwing up "ERROR: Invalid Python expression".

Pressing "Update Dependencies" fixes the problem

Exact steps for others to reproduce the error
With 'driver-bug-test.blend':

  • Open the project.
  • Enter pose mode for the armature
  • Try moving it along the X axis (Moving the armature along the x axis should make the cube move along the Y-axis, but it doesn't)
  • Exit pose mode
  • Select the cube
  • In the Drivers panel, you'll see in the Driver Property panel an error "ERROR: Invalid Python expression"
  • Clicking 'Update Dependencies' allows the driver to start working correctly.

This happens each time the project is opened.

I'd be happy to just click this button each time I load, but if you have a project with many items being driven by functions, it's not practical at all.

driver-bug-test.blend

**System Information** Operating system: Pop!_OS (Debian) 18.10 Graphics card: GTX Titan X **Blender Version** Broken: 2.80 77eaa4790d37 Worked: (optional) A driver calls on a python function. The python function is internal and registered. When the project is opened, the driver can't find the function, throwing up "ERROR: Invalid Python expression". Pressing "Update Dependencies" fixes the problem **Exact steps for others to reproduce the error** With 'driver-bug-test.blend': - Open the project. - Enter pose mode for the armature - Try moving it along the X axis (Moving the armature along the x axis should make the cube move along the Y-axis, but it doesn't) - Exit pose mode - Select the cube - In the Drivers panel, you'll see in the Driver Property panel an error "ERROR: Invalid Python expression" - Clicking 'Update Dependencies' allows the driver to start working correctly. This happens each time the project is opened. I'd be happy to just click this button each time I load, but if you have a project with many items being driven by functions, it's not practical at all. [driver-bug-test.blend](https://archive.blender.org/developer/F6465381/driver-bug-test.blend)
Author

Added subscriber: @stephenthomas

Added subscriber: @stephenthomas

Added subscribers: @Sergey, @brecht

Added subscribers: @Sergey, @brecht

@Sergey, this traces back to d192d723.

Python module registration should be done before the depsgraph like in 2.7 I think, for cases like this. Wouldn't mind an extra pair of eyes to check if it's safe though.

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 120bf65..5295064 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -491,12 +491,6 @@ static void wm_file_read_post(
 
        CTX_wm_window_set(C, wm->windows.first);
 
-       Main *bmain = CTX_data_main(C);
-       DEG_on_visible_update(bmain, true);
-       wm_event_do_depsgraph(C);
-
-       ED_editors_init(C);
-
 #ifdef WITH_PYTHON
        if (is_startup_file) {
                /* possible python hasn't been initialized */
@@ -526,6 +520,12 @@ static void wm_file_read_post(
        UNUSED_VARS(is_startup_file, reset_app_template);
 #endif  /* WITH_PYTHON */
 
+       Main *bmain = CTX_data_main(C);
+       DEG_on_visible_update(bmain, true);
+       wm_event_do_depsgraph(C);
+
+       ED_editors_init(C);
+
        WM_operatortype_last_properties_clear_all();
 
        /* important to do before NULL'ing the context */
@Sergey, this traces back to d192d723. Python module registration should be done before the depsgraph like in 2.7 I think, for cases like this. Wouldn't mind an extra pair of eyes to check if it's safe though. ``` diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 120bf65..5295064 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -491,12 +491,6 @@ static void wm_file_read_post( CTX_wm_window_set(C, wm->windows.first); - Main *bmain = CTX_data_main(C); - DEG_on_visible_update(bmain, true); - wm_event_do_depsgraph(C); - - ED_editors_init(C); - #ifdef WITH_PYTHON if (is_startup_file) { /* possible python hasn't been initialized */ @@ -526,6 +520,12 @@ static void wm_file_read_post( UNUSED_VARS(is_startup_file, reset_app_template); #endif /* WITH_PYTHON */ + Main *bmain = CTX_data_main(C); + DEG_on_visible_update(bmain, true); + wm_event_do_depsgraph(C); + + ED_editors_init(C); + WM_operatortype_last_properties_clear_all(); /* important to do before NULL'ing the context */ ```

Added subscriber: @ConradDueck

Added subscriber: @ConradDueck

This issue was referenced by d31b2f8549

This issue was referenced by d31b2f854954838fb849b5b0be0011d792eecb43

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