[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57554] trunk/blender: add option to enable auto-execute scripts, but exclude certain directories .
Campbell Barton
ideasman42 at gmail.com
Tue Jun 18 20:11:52 CEST 2013
Revision: 57554
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57554
Author: campbellbarton
Date: 2013-06-18 18:11:52 +0000 (Tue, 18 Jun 2013)
Log Message:
-----------
add option to enable auto-execute scripts, but exclude certain directories.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
trunk/blender/source/blender/blenkernel/CMakeLists.txt
trunk/blender/source/blender/blenkernel/intern/blender.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/blenloader/intern/writefile.c
trunk/blender/source/blender/editors/space_file/filesel.c
trunk/blender/source/blender/makesdna/DNA_userdef_types.h
trunk/blender/source/blender/makesrna/intern/rna_userdef.c
trunk/blender/source/blender/windowmanager/WM_api.h
trunk/blender/source/blender/windowmanager/intern/wm_files.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
trunk/blender/source/creator/creator.c
Added Paths:
-----------
trunk/blender/source/blender/blenkernel/BKE_autoexec.h
trunk/blender/source/blender/blenkernel/intern/autoexec.c
Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py 2013-06-18 16:52:02 UTC (rev 57553)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py 2013-06-18 18:11:52 UTC (rev 57554)
@@ -867,9 +867,22 @@
colsplit = col.split(percentage=0.95)
sub = colsplit.column()
- sub.label(text="Author:")
- sub.prop(system, "author", text="")
+ row = sub.split(percentage=0.3)
+ row.label(text="Auto Execution:")
+ row.prop(system, "use_scripts_auto_execute")
+
+ if system.use_scripts_auto_execute:
+ box = sub.box()
+ row = box.row()
+ row.label(text="Excluded Paths:")
+ row.operator("wm.userpref_autoexec_path_add", text="", icon='ZOOMIN', emboss=False)
+ for i, path_cmp in enumerate(userpref.autoexec_paths):
+ row = box.row()
+ row.prop(path_cmp, "path", text="")
+ row.prop(path_cmp, "use_glob", text="", icon='FILTER')
+ row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i
+
col = split.column()
col.label(text="Save & Load:")
col.prop(paths, "use_relative_paths")
@@ -896,11 +909,13 @@
col.separator()
- col.label(text="Scripts:")
- col.prop(system, "use_scripts_auto_execute")
+ col.label(text="Text Editor:")
col.prop(system, "use_tabs_as_spaces")
+ col.label(text="Author:")
+ col.prop(system, "author", text="")
+
from bl_ui.space_userpref_keymap import InputKeyMapPanel
Added: trunk/blender/source/blender/blenkernel/BKE_autoexec.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_autoexec.h (rev 0)
+++ trunk/blender/source/blender/blenkernel/BKE_autoexec.h 2013-06-18 18:11:52 UTC (rev 57554)
@@ -0,0 +1,31 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Foundation 2013
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef __BKE_AUTOEXEC_H__
+#define __BKE_AUTOEXEC_H__
+
+/** \file BKE_autoexec.h
+ * \ingroup bke
+ */
+
+bool BKE_autoexec_match(const char *path);
+
+#endif /* __BKE_AUTOEXEC_H__ */
Property changes on: trunk/blender/source/blender/blenkernel/BKE_autoexec.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/blender/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/blenkernel/CMakeLists.txt 2013-06-18 16:52:02 UTC (rev 57553)
+++ trunk/blender/source/blender/blenkernel/CMakeLists.txt 2013-06-18 18:11:52 UTC (rev 57554)
@@ -63,6 +63,7 @@
intern/anim.c
intern/anim_sys.c
intern/armature.c
+ intern/autoexec.c
intern/blender.c
intern/bmfont.c
intern/boids.c
@@ -163,6 +164,7 @@
BKE_anim.h
BKE_animsys.h
BKE_armature.h
+ BKE_autoexec.h
BKE_blender.h
BKE_bmesh.h
BKE_bmfont.h
Added: trunk/blender/source/blender/blenkernel/intern/autoexec.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/autoexec.c (rev 0)
+++ trunk/blender/source/blender/blenkernel/intern/autoexec.c 2013-06-18 18:11:52 UTC (rev 57554)
@@ -0,0 +1,69 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Foundation 2013
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/armature.c
+ * \ingroup bke
+ *
+ * Currently just checks if a blend file can be trusted to autoexec,
+ * may add signing here later.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "DNA_userdef_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_fnmatch.h"
+#include "BLI_path_util.h"
+
+#include "BKE_autoexec.h" /* own include */
+
+/**
+ * \param path The path to check against.
+ * \return Success
+ */
+bool BKE_autoexec_match(const char *path)
+{
+ bPathCompare *path_cmp;
+
+#ifdef WIN32
+ const int fnmatch_flags = FNM_CASEFOLD;
+#else
+ const int fnmatch_flags = 0;
+#endif
+
+ BLI_assert((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0);
+
+ for (path_cmp = U.autoexec_paths.first; path_cmp; path_cmp = path_cmp->next) {
+ if ((path_cmp->flag & USER_PATHCMP_GLOB)) {
+ if (fnmatch(path_cmp->path, path, fnmatch_flags) == 0) {
+ return true;
+ }
+ }
+ else if (BLI_path_ncmp(path_cmp->path, path, strlen(path_cmp->path)) == 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
Property changes on: trunk/blender/source/blender/blenkernel/intern/autoexec.c
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c 2013-06-18 16:52:02 UTC (rev 57553)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c 2013-06-18 18:11:52 UTC (rev 57554)
@@ -416,6 +416,8 @@
MEM_freeN(addon);
}
+ BLI_freelistN(&U.autoexec_paths);
+
BLI_freelistN(&U.uistyles);
BLI_freelistN(&U.uifonts);
BLI_freelistN(&U.themes);
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2013-06-18 16:52:02 UTC (rev 57553)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2013-06-18 18:11:52 UTC (rev 57554)
@@ -9605,6 +9605,7 @@
link_list(fd, &user->themes);
link_list(fd, &user->user_keymaps);
link_list(fd, &user->addons);
+ link_list(fd, &user->autoexec_paths);
for (keymap=user->user_keymaps.first; keymap; keymap=keymap->next) {
keymap->modal_items= NULL;
Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c 2013-06-18 16:52:02 UTC (rev 57553)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c 2013-06-18 18:11:52 UTC (rev 57554)
@@ -860,6 +860,7 @@
wmKeyMapItem *kmi;
wmKeyMapDiffItem *kmdi;
bAddon *bext;
+ bPathCompare *path_cmp;
uiStyle *style;
writestruct(wd, USER, "UserDef", 1, &U);
@@ -888,6 +889,10 @@
IDP_WriteProperty(bext->prop, wd);
}
}
+
+ for (path_cmp = U.autoexec_paths.first; path_cmp; path_cmp = path_cmp->next) {
+ writestruct(wd, DATA, "bPathCompare", 1, path_cmp);
+ }
for (style= U.uistyles.first; style; style= style->next) {
writestruct(wd, DATA, "uiStyle", 1, style);
Modified: trunk/blender/source/blender/editors/space_file/filesel.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/filesel.c 2013-06-18 16:52:02 UTC (rev 57553)
+++ trunk/blender/source/blender/editors/space_file/filesel.c 2013-06-18 18:11:52 UTC (rev 57554)
@@ -609,6 +609,7 @@
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
+ file_draw_check_cb(C, NULL, NULL);
}
}
Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h 2013-06-18 16:52:02 UTC (rev 57553)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h 2013-06-18 18:11:52 UTC (rev 57554)
@@ -360,6 +360,12 @@
IDProperty *prop; /* User-Defined Properties on this Addon (for storing preferences) */
} bAddon;
+typedef struct bPathCompare {
+ struct bPathCompare *next, *prev;
+ char path[768]; /* FILE_MAXDIR */
+ char flag, pad[7];
+} bPathCompare;
+
typedef struct SolidLight {
int flag, pad;
float col[4], spec[4], vec[4];
@@ -412,6 +418,7 @@
struct ListBase keymaps DNA_DEPRECATED; /* deprecated in favor of user_keymaps */
struct ListBase user_keymaps;
struct ListBase addons;
+ struct ListBase autoexec_paths;
char keyconfigstr[64];
short undosteps;
@@ -522,7 +529,12 @@
USER_TXT_TABSTOSPACES_DISABLE = (1 << 25),
USER_TOOLTIPS_PYTHON = (1 << 26),
} eUserPref_Flag;
-
+
+/* flag */
+typedef enum ePathCompare_Flag {
+ USER_PATHCMP_GLOB = (1 << 0),
+} ePathCompare_Flag;
+
/* helper macro for checking frame clamping */
#define FRAMENUMBER_MIN_CLAMP(cfra) { \
if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \
Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c 2013-06-18 16:52:02 UTC (rev 57553)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c 2013-06-18 18:11:52 UTC (rev 57554)
@@ -339,9 +339,9 @@
return bext;
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list