forked from bartvdbraak/blender
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.
This commit is contained in:
parent
1f56eee953
commit
9cf0bbb95c
@ -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
|
||||
|
@ -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__'):
|
||||
|
@ -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()
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user