bpy.app.handlers.load_post not run on startup file loading after splashscreen #34636

Closed
opened 2013-03-14 10:40:57 +01:00 by Emanuele Gissi · 9 comments

%%%--- Steps for others to reproduce the error ---

  1. Register a load_post handler in a script init.py:

def register():

  bpy.utils.register_module(__name__)
  bpy.app.handlers.load_post.append(load_handler)

@persistent
def load_handler(self):

  print("Run load handler")
  1. Open Blender 2.66 (Linux Xubuntu amd64)

  2. At the splashscreen do not choose any alternative and click elsewhere

  3. The default startup file is loaded, load_post handler is not run.

Note that if I reload the default startup file by the File > New menu, then the load_post handler is correctly run. %%%

%%%--- Steps for others to reproduce the error --- 1) Register a load_post handler in a script __init__.py: def register(): ``` bpy.utils.register_module(__name__) bpy.app.handlers.load_post.append(load_handler) ``` @persistent def load_handler(self): ``` print("Run load handler") ``` 2) Open Blender 2.66 (Linux Xubuntu amd64) 3) At the splashscreen do not choose any alternative and click elsewhere 4) The default startup file is loaded, load_post handler is *not run*. Note that if I reload the default startup file by the File > New menu, then the load_post handler is correctly run. %%%
Author

Changed status to: 'Open'

Changed status to: 'Open'

%%%When the splash screen shows, the startup.blend has already been loaded, clicking next to it does not cause it any file load, it just hides the splash screen.

Where are you putting this init.py script, is it a text datablock in the startup.blend, part of an addon, ..? Regardless, I guess the problem is that any script will run after the startup.blend has already been loaded. This isn't really something we can change I think, as running a script without Blender data would be problematic, the code relies too much on there being a valid database, window manager, scene, etc.%%%

%%%When the splash screen shows, the startup.blend has already been loaded, clicking next to it does not cause it any file load, it just hides the splash screen. Where are you putting this __init__.py script, is it a text datablock in the startup.blend, part of an addon, ..? Regardless, I guess the problem is that any script will run after the startup.blend has already been loaded. This isn't really something we can change I think, as running a script without Blender data would be problematic, the code relies too much on there being a valid database, window manager, scene, etc.%%%
Author

%%%This init.py script is part of an addon.
This is a load_post handler, then it should be run after the startup.blend has already been loaded.

If I reload the default startup file by the File > New menu, then the load_post handler is correctly run.

I think that the problem is specific to Blender first load of the default startup file, that forgets to run the load_post handler after the loading operation.
Emanuele%%%

%%%This __init__.py script is part of an addon. This is a load_post handler, then it should be run *after* the startup.blend has already been loaded. If I reload the default startup file by the File > New menu, then the load_post handler is correctly run. I think that the problem is specific to Blender first load of the default startup file, that forgets to run the load_post handler after the loading operation. Emanuele%%%
Member

%%%see attached image to understand the timing!

(load_post_handler_timing.png)%%%

%%%see attached image to understand the timing! (load_post_handler_timing.png)%%%
Author

%%%Ok, now I understand the timing...

I should say that it would be more coherent and less confusing for addons users to run the load_post script at a later time for default startup file.
Is it feasible?
Emanuele%%%

%%%Ok, now I understand the timing... I should say that it would be more coherent and less confusing for addons users to run the load_post script at a later time for default startup file. Is it feasible? Emanuele%%%
Member

%%%there's a possible work-around, but i'd call it hacky:
http://blenderartists.org/forum/showthread.php?233979-how-to-run-bpy-app-handlers-load_post-every-time-after-file-loaded&p=2332342#post2332342%%%

%%%there's a possible work-around, but i'd call it hacky: http://blenderartists.org/forum/showthread.php?233979-how-to-run-bpy-app-handlers-load_post-every-time-after-file-loaded&p=2332342#post2332342%%%
Author

%%%Thank you Neil, I am going to include your wonderful suggestion in my code.
Though I think that a proper solution should be found.
Emanuele%%%

%%%Thank you Neil, I am going to include your wonderful suggestion in my code. Though I think that a proper solution should be found. Emanuele%%%

%%%fixed r55643.%%%

%%%fixed r55643.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
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-addons#34636
No description provided.