From 911f9e00d13c57fb093b7ba7b930a340aa0a79a9 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Wed, 28 Oct 2020 14:06:26 -0400 Subject: [PATCH 1/2] Animation: Improve labels on Snap menu in NLA & Dopesheet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add "Selection to" as prefix for those menu items that move the selected keyframes to something, for both the Key → Snap menu and the Shift+S pie menu. No functional changes. This was missed in rB477d983c2e8ab298cbf638d5aadd77fad9c2f677 Differential Revision: https://developer.blender.org/D9304 --- release/scripts/startup/bl_ui/space_dopesheet.py | 8 ++++---- release/scripts/startup/bl_ui/space_nla.py | 8 ++++---- source/blender/editors/space_action/action_edit.c | 8 ++++---- source/blender/editors/space_graph/graph_edit.c | 10 +++++----- source/blender/editors/space_nla/nla_edit.c | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index a866921f326..aa88fceaef7 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -668,10 +668,10 @@ class DOPESHEET_MT_snap_pie(Menu): layout = self.layout pie = layout.menu_pie() - pie.operator("action.snap", text="Current Frame").type = 'CFRA' - pie.operator("action.snap", text="Nearest Frame").type = 'NEAREST_FRAME' - pie.operator("action.snap", text="Nearest Second").type = 'NEAREST_SECOND' - pie.operator("action.snap", text="Nearest Marker").type = 'NEAREST_MARKER' + pie.operator("action.snap", text="Selection to Current Frame").type = 'CFRA' + pie.operator("action.snap", text="Selection to Nearest Frame").type = 'NEAREST_FRAME' + pie.operator("action.snap", text="Selection to Nearest Second").type = 'NEAREST_SECOND' + pie.operator("action.snap", text="Selection to Nearest Marker").type = 'NEAREST_MARKER' class LayersDopeSheetPanel: diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 4ecc4e7fdd9..d472352084c 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -241,10 +241,10 @@ class NLA_MT_snap_pie(Menu): layout = self.layout pie = layout.menu_pie() - pie.operator("nla.snap", text="Current Frame").type = 'CFRA' - pie.operator("nla.snap", text="Nearest Frame").type = 'NEAREST_FRAME' - pie.operator("nla.snap", text="Nearest Second").type = 'NEAREST_SECOND' - pie.operator("nla.snap", text="Nearest Marker").type = 'NEAREST_MARKER' + pie.operator("nla.snap", text="Selection to Current Frame").type = 'CFRA' + pie.operator("nla.snap", text="Selection to Nearest Frame").type = 'NEAREST_FRAME' + pie.operator("nla.snap", text="Selection to Nearest Second").type = 'NEAREST_SECOND' + pie.operator("nla.snap", text="Selection to Nearest Marker").type = 'NEAREST_MARKER' class NLA_MT_context_menu(Menu): diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index e14e78912d7..f058ec5546a 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1696,23 +1696,23 @@ static const EnumPropertyItem prop_actkeys_snap_types[] = { {ACTKEYS_SNAP_CFRA, "CFRA", 0, - "Current Frame", + "Selection to Current Frame", "Snap selected keyframes to the current frame"}, {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, - "Nearest Frame", + "Selection to Nearest Frame", "Snap selected keyframes to the nearest (whole) frame (use to fix accidental sub-frame " "offsets)"}, {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, - "Nearest Second", + "Selection to Nearest Second", "Snap selected keyframes to the nearest second"}, {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, - "Nearest Marker", + "Selection to Nearest Marker", "Snap selected keyframes to the nearest marker"}, {0, NULL, 0, NULL, NULL}, }; diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index b25a275a0ab..7fc1329df64 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -2887,28 +2887,28 @@ static const EnumPropertyItem prop_graphkeys_snap_types[] = { {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, - "Current Frame", + "Selection to Current Frame", "Snap selected keyframes to the current frame"}, {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, - "Cursor Value", + "Selection to Cursor Value", "Set values of selected keyframes to the cursor value (Y/Horizontal component)"}, {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, - "Nearest Frame", + "Selection to Nearest Frame", "Snap selected keyframes to the nearest (whole) frame (use to fix accidental sub-frame " "offsets)"}, {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, - "Nearest Second", + "Selection to Nearest Second", "Snap selected keyframes to the nearest second"}, {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, - "Nearest Marker", + "Selection to Nearest Marker", "Snap selected keyframes to the nearest marker"}, {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index fa27a6941ec..ed8e5ad76e9 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -2158,12 +2158,12 @@ void NLA_OT_clear_scale(wmOperatorType *ot) /* defines for snap keyframes tool */ static const EnumPropertyItem prop_nlaedit_snap_types[] = { - {NLAEDIT_SNAP_CFRA, "CFRA", 0, "Current Frame", ""}, + {NLAEDIT_SNAP_CFRA, "CFRA", 0, "Selection to Current Frame", ""}, /* XXX as single entry? */ - {NLAEDIT_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, + {NLAEDIT_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Selection to Nearest Frame", ""}, /* XXX as single entry? */ - {NLAEDIT_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, - {NLAEDIT_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""}, + {NLAEDIT_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Selection to Nearest Second", ""}, + {NLAEDIT_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Selection to Nearest Marker", ""}, {0, NULL, 0, NULL, NULL}, }; From 52b38d9c3d84485385d5bc2e58f16c5acfaca9b7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Oct 2020 09:33:15 +1100 Subject: [PATCH 2/2] PyAPI: point sys.executable to the Python binary `sys.executable` is documented to be a Python interpreter or None. This was set to Blender's executable which caused the multiprocessing module to spawn new instances of Blender instead of Python on WIN32. See issue described in D7815. Deprecate 'bpy.app.binary_path_python' & warn when using. Blender's executable remains accessible via `bpy.app.binary_path`. Modified 04c5471ceefb4, setting `sys.executable` instead of using Py_SetProgramName, which is needed for a bundled Python installation. --- release/scripts/modules/sys_info.py | 4 +-- source/blender/python/intern/bpy_app.c | 33 +++----------------- source/blender/python/intern/bpy_interface.c | 23 +++++++++++++- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index fc3ffe4dd88..cb80529f0f3 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -82,10 +82,10 @@ def write_sysinfo(filepath): output.write("\t%r\n" % p) output.write(title("Python (External Binary)")) - output.write("binary path: %s\n" % prepr(bpy.app.binary_path_python)) + output.write("binary path: %s\n" % prepr(sys.executable)) try: py_ver = prepr(subprocess.check_output([ - bpy.app.binary_path_python, + sys.executable, "--version", ]).strip()) except Exception as e: diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 554ab2645a7..8354e220b09 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -292,36 +292,13 @@ static int bpy_app_global_flag_set__only_disable(PyObject *UNUSED(self), return bpy_app_global_flag_set(NULL, value, closure); } -#define BROKEN_BINARY_PATH_PYTHON_HACK - PyDoc_STRVAR(bpy_app_binary_path_python_doc, - "String, the path to the python executable (read-only)"); -static PyObject *bpy_app_binary_path_python_get(PyObject *self, void *UNUSED(closure)) + "String, the path to the python executable (read-only). " + "Deprecated! Use ``sys.executable`` instead."); +static PyObject *bpy_app_binary_path_python_get(PyObject *UNUSED(self), void *UNUSED(closure)) { - /* refcount is held in BlenderAppType.tp_dict */ - static PyObject *ret = NULL; - - if (ret == NULL) { - /* only run once */ - char fullpath[1024]; - BKE_appdir_program_python_search( - fullpath, sizeof(fullpath), PY_MAJOR_VERSION, PY_MINOR_VERSION); - ret = PyC_UnicodeFromByte(fullpath); -#ifdef BROKEN_BINARY_PATH_PYTHON_HACK - Py_INCREF(ret); - UNUSED_VARS(self); -#else - PyDict_SetItem( - BlenderAppType.tp_dict, - /* XXX BAAAADDDDDD! self is not a PyDescr at all! it's bpy.app!!! */ PyDescr_NAME(self), - ret); -#endif - } - else { - Py_INCREF(ret); - } - - return ret; + PyErr_Warn(PyExc_RuntimeWarning, "Use 'sys.executable' instead of 'binary_path_python'!"); + return Py_INCREF_RET(PySys_GetObject("executable")); } PyDoc_STRVAR(bpy_app_debug_value_doc, diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index c4523363a91..a4417f38756 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -306,7 +306,11 @@ void BPY_python_start(bContext *C, int argc, const char **argv) PyThreadState *py_tstate = NULL; const char *py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL); - /* Not essential but nice to set our name. */ + /* Needed for Python's initialization for portable Python installations. + * We could use #Py_SetPath, but this overrides Python's internal logic + * for calculating it's own module search paths. + * + * `sys.executable` is overwritten after initialization to the Python binary. */ { const char *program_path = BKE_appdir_program_path(); wchar_t program_path_wchar[FILE_MAX]; @@ -354,6 +358,23 @@ void BPY_python_start(bContext *C, int argc, const char **argv) Py_DECREF(py_argv); } + /* Setting the program name is important so the 'multiprocessing' module + * can launch new Python instances. */ + { + char program_path[FILE_MAX]; + if (BKE_appdir_program_python_search( + program_path, sizeof(program_path), PY_MAJOR_VERSION, PY_MINOR_VERSION)) { + PyObject *py_program_path = PyC_UnicodeFromByte(program_path); + PySys_SetObject("executable", py_program_path); + Py_DECREF(py_program_path); + } + else { + fprintf(stderr, + "Unable to find the python binary, " + "the multiprocessing module may not be functional!\n"); + } + } + # ifdef WITH_FLUID /* Required to prevent assertion error, see: * https://stackoverflow.com/questions/27844676 */