diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-06-10 13:44:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-06-10 13:44:27 +0400 |
commit | 9cf0bbb95c00129501d14f97be3f33cc208771fb (patch) | |
tree | 0ea82db58f4dfb3a999bb499149e9c4a69835e22 | |
parent | 1f56eee95304e38b91e05cbb2e595948585b2f31 (diff) |
added a check to console auto-compleation for pythons struct_seq type, so bpy.app and sys.float_info autocompleate their attributes rather then bring treated as a typle.
4 files changed, 18 insertions, 5 deletions
diff --git a/build_files/cmake/example_scripts/cmake_linux_install.sh b/build_files/cmake/example_scripts/cmake_linux_install.sh index 7770efcf392..504218f91a6 100755 --- a/build_files/cmake/example_scripts/cmake_linux_install.sh +++ b/build_files/cmake/example_scripts/cmake_linux_install.sh @@ -17,7 +17,7 @@ cd ~/blender-svn/build-cmake # cmake without copying files for fast rebuilds # the files from svn will be used in place -cmake ../blender -DWITH_INSTALL:BOOL=FALSE +cmake ../blender # make blender, will take some time make diff --git a/release/scripts/modules/console/complete_namespace.py b/release/scripts/modules/console/complete_namespace.py index a31280ebff0..d787fed0967 100644 --- a/release/scripts/modules/console/complete_namespace.py +++ b/release/scripts/modules/console/complete_namespace.py @@ -37,6 +37,11 @@ def is_dict(obj): return hasattr(obj, 'keys') and hasattr(getattr(obj, 'keys'), '__call__') +def is_struct_seq(obj): + """Returns whether obj is a structured sequence subclass: sys.float_info""" + return isinstance(obj, tuple) and hasattr(obj, 'n_fields') + + def complete_names(word, namespace): """Complete variable names or attributes @@ -174,7 +179,7 @@ def complete(word, namespace, private=True): if type(obj) in (bool, float, int, str): return [] # an extra char '[', '(' or '.' will be added - if hasattr(obj, '__getitem__'): + if hasattr(obj, '__getitem__') and not is_struct_seq(obj): # list or dictionary matches = complete_indices(word, namespace, obj) elif hasattr(obj, '__call__'): diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py index 3048fa1d597..455eabe377b 100644 --- a/release/scripts/modules/console_python.py +++ b/release/scripts/modules/console_python.py @@ -80,7 +80,7 @@ def get_console(console_id): if console_data: console, stdout, stderr = console_data - # XXX, bug in python 3.1.2 ? (worked in 3.1.1) + # XXX, bug in python 3.1.2, 3.2 ? (worked in 3.1.1) # seems there is no way to clear StringIO objects for writing, have to make new ones each time. import io stdout = io.StringIO() diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8f15a21c624..06d049d2cb5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1485,6 +1485,14 @@ static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( { const char *openname= G.main->name; + if(CTX_wm_window(C) == NULL) { + /* in rare cases this could happen, when trying to invoke in background + * mode on load for example. Don't use poll for this because exec() + * can still run without a window */ + BKE_report(op->reports, RPT_ERROR, "Context window not set"); + return OPERATOR_CANCELLED; + } + /* if possible, get the name of the most recently used .blend file */ if (G.recent_files.first) { struct RecentFile *recent = G.recent_files.first; @@ -1535,7 +1543,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) ot->invoke= wm_open_mainfile_invoke; ot->exec= wm_open_mainfile_exec; - ot->poll= WM_operator_winactive; + /* ommit window poll so this can work in background mode */ WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH); @@ -1954,7 +1962,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) ot->invoke= wm_save_mainfile_invoke; ot->exec= wm_save_as_mainfile_exec; ot->check= blend_save_check; - ot->poll= NULL; + /* ommit window poll so this can work in background mode */ WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); |