Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2008-04-08 00:56:45 +0400
committerMartin Poirier <theeth@yahoo.com>2008-04-08 00:56:45 +0400
commit79ed118fd492d13e261fcef7c68bf875761f4a6d (patch)
tree0bbaf4b6134e33494fc64cc643752a6e6d918fc9 /release/scripts/bpymodules
parent6dec5db1e6e050067ee58d6db7a476b8153a5d0d (diff)
Potential fix for [#8113] Blender.Registry segfault when no permission to write
This converts exceptions in Warning in selected points of the registry module. While I couldn't reproduce the segfault ( I received the Py error as expected), this isn't a bad idea anyway, since the BPy C counterpart was discarding the error anyway, making it a warning is a bit more inline with its meaning. The exception is not preventable nor fixable from a script's point of view, so better to silence it and print a warning to the console instead.
Diffstat (limited to 'release/scripts/bpymodules')
-rw-r--r--release/scripts/bpymodules/BPyRegistry.py41
1 files changed, 25 insertions, 16 deletions
diff --git a/release/scripts/bpymodules/BPyRegistry.py b/release/scripts/bpymodules/BPyRegistry.py
index f0d6da82d52..4d681e15937 100644
--- a/release/scripts/bpymodules/BPyRegistry.py
+++ b/release/scripts/bpymodules/BPyRegistry.py
@@ -193,14 +193,17 @@ def LoadConfigData (key = None):
if bsys.exists(fname): files.append(fname)
for p in files:
- f = file(p, 'r')
- lines = f.readlines()
- f.close()
- if lines: # Lines may be blank
- mainkey = lines[0].split('=')[0].strip()
- pysrc = "\n".join(lines)
- exec(pysrc)
- exec("Registry.SetKey('%s', %s)" % (str(mainkey), mainkey))
+ try:
+ f = file(p, 'r')
+ lines = f.readlines()
+ f.close()
+ if lines: # Lines may be blank
+ mainkey = lines[0].split('=')[0].strip()
+ pysrc = "\n".join(lines)
+ exec(pysrc)
+ exec("Registry.SetKey('%s', %s)" % (str(mainkey), mainkey))
+ except Exception, e:
+ raise Warning(e) # Resend exception as warning
def RemoveConfigData (key = None):
@@ -223,8 +226,11 @@ def RemoveConfigData (key = None):
import os
- for p in files:
- os.remove(p) # remove the file(s)
+ try:
+ for p in files:
+ os.remove(p) # remove the file(s)
+ except Exception, e:
+ raise Warning(e) # Resend exception as warning
def SaveConfigData (key = None):
@@ -250,9 +256,12 @@ def SaveConfigData (key = None):
if not cfgdict: continue
- filename = bsys.join(_CFG_DIR, "%s%s" % (mainkey, _EXT))
- f = file(filename, 'w')
- output = _dict_to_str(mainkey, _sanitize(cfgdict))
- if output!='None':
- f.write(output)
- f.close()
+ try:
+ filename = bsys.join(_CFG_DIR, "%s%s" % (mainkey, _EXT))
+ f = file(filename, 'w')
+ output = _dict_to_str(mainkey, _sanitize(cfgdict))
+ if output!='None':
+ f.write(output)
+ f.close()
+ except Exception, e:
+ raise Warning(e) # Resend exception as warning