something is funny with read_homefile operator
and possibly open mainfile in this use case
when the operator is executed from UI Panel in 3D Viewport, and a popup is not invoked, e.g when file is not dirty, or when calling inside another operator with “EXEC_DEFAULT”
the window only catches the mouse press event, and not release, so it invokes for example the box select operator in the newly opened file, or what ever is assigned to left click
here’s code for you to try, execute the button twice in a row, under view3d Misc category
import bpy
class Foo(bpy.types.Panel):
bl_label = "General"
bl_region_type = "UI"
bl_space_type = "VIEW_3D"
def draw(self, context):
op = self.layout.operator("wm.read_homefile")
op.load_ui=False
op.use_empty=True
bpy.utils.register_class(Foo)
the only way I found to fix this is to simulate mouse-left-release right before calling
....
# simulate mouse left release here
bpy.ops.wm.read_homefile(load_ui=False, use_empty=True)
....
but I cannot use event_simulate without enabling it in command line args Command Line Arguments — Blender Manual
which is not very convenient as it would be used in a user addon
I used a 3rd party module to simulate mouse events, it worked, but that solution is not perfect too, considering support for multiple platforms
can someone help with this?, I suppose this is something that should be edited in Blender source, but still I want to understand the issue more
thanks in advance