Page MenuHome

Automatic scripts reload after path editing
AbandonedPublic

Authored by Alexander Romanov (a.romanov) on Jan 19 2017, 9:36 AM.

Details

Reviewers
Julian Eisel (Severin)
Group Reviewers
User Interface
Summary

Not all users know about F8-binded "script.reload" operator. In User Preferences panel you can edit the path to the scripts, and this is convenient to reload them automatically.


Alexander (Blend4Web Team)

Diff Detail

Event Timeline

Alexander Romanov (a.romanov) retitled this revision from to Add "script.reload" button to User Preference Panel.
Alexander Romanov (a.romanov) updated this object.

looks ok, I would take step further & also add to preferences addons header as the refresh & reload F8 appear to do different things.

looks ok, I would take step further & also add to preferences addons header as the refresh & reload F8 appear to do different things.

I think that any button should have some relations with options listed on the same Tab. In this case relation between "Scripts" field and "Reload Scripts" button is clear. And if we put it in "Addons", two buttons with similar names "refresh"~ "reload" can confuse.

Not currently convinced this is a good change.

Why would a normal artists want to use this button?

Not currently convinced this is a good change.

Why would a normal artists want to use this button?

It is useful for example for installation of some plugins which are placed in 'Scripts' folder. For example Blend4Web SDK use this installation method. And many artists use SDK instead of plugin due to it's advantages.

It is useful for example for installation of some plugins which are placed in 'Scripts' folder. For example Blend4Web SDK use this installation method. And many artists use SDK instead of plugin due to it's advantages.

This seems like a really specific corner-case, though. In this case you'd still have to communicate this to the user somehow why they need to reload the scripts, in which case it's just as easy to tell them to use F8.

My first reaction is the same as @Sergey Sharybin (sergey)'s. A normal user should never have to reload scripts, much less need to know why. Exposing the functionality is nice for power users, but that's already handled via F8 and so for most users adding the button is merely going to further complicate the user preferences.

Could we auto reload when changing the scripts path?

I think this indicates some weakness in the installation procedure, we shouldn't add buttons for manual steps but rather try to automate it better.

Could we auto reload when changing the scripts path?

I think this indicates some weakness in the installation procedure, we shouldn't add buttons for manual steps but rather try to automate it better.

I'll try.

Could we auto reload when changing the scripts path?

I think this indicates some weakness in the installation procedure, we shouldn't add buttons for manual steps but rather try to automate it better.

I'll try.

The property is defined in C-code, but such kind of callbacks has no simple way to pass a Context, which is needed for calling 'SCRIPT_OT_reload'. So I think there is no simple way to do this update automatically.

The property is defined in C-code, but such kind of callbacks has no simple way to pass a Context, which is needed for calling 'SCRIPT_OT_reload'. So I think there is no simple way to do this update automatically.

You can use RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); to get bContext passed to the property _update function. I think that would be okay as a solution for this corner case. Alternatively, we could place a button (icon only?) next to the Scripts text field to reload scripts manually. But indeed, an automatic approach would be preferable.

Julian Eisel (Severin) requested changes to this revision.Feb 10 2017, 4:07 PM

Also requesting changes since consensus is that current patch isn't really the way to go.

This revision now requires changes to proceed.Feb 10 2017, 4:07 PM
Alexander Romanov (a.romanov) updated this object.
Alexander Romanov (a.romanov) edited edge metadata.

Implemented as automatic SCRIPT_OT_reload call in update callback.

There is a comment

/* TODO, editing should reset sys.path! */

What the correct behavior should be? Is resetting necessary?

Alexander Romanov (a.romanov) retitled this revision from Add "script.reload" button to User Preference Panel to Automatic scripts reload after path editing.Apr 18 2017, 10:41 AM

Unless this can work perfectly, I don't think its worth attempting.

The tricky part is that the scripts path controls what blender does at startup (it may run scripts in the startup path, new add-ons are available) and since it's added to sys.path - the imports of all existing scripts could have a different outcome.

In practice I'm sure it's possibly to mostly get this working, but suggest to reject this since:

  • It introduces a new state for the Python interpreter where users may run into unexpected problems that won't occur on restart.
  • Debugging these problems is time consuming for minimal gains.
This revision now requires changes to proceed.Aug 25 2017, 9:22 AM