- rna attribute setting problem, class instances could not set their own attributes because they are blocked by our own internal setattr.

this could be supported again easily however it leads typo's & api changes not showing any errors.

  This broke povray export.
  Solution for now is to allow setting private properties starting with '_'

  eg, 
    ob = bpy.context.object
    
    ob._foo = [1,2,3] # this is a python list, it will stay only as long as this PyObject is active
    ob.foo = 1 # raises an error!, only for rna properties
    ob["foo"] = 1 # converts to an ID property and is saved

    using the underscore like this should really be used for classes internally.

- povray failed on armatures

- menu key wasn't using WM_keymap_add_menu
This commit is contained in:
Campbell Barton 2009-11-18 08:40:18 +00:00
parent 1e1a0078da
commit 318e9aa5d1
4 changed files with 27 additions and 28 deletions

@ -285,7 +285,7 @@ def write_pov(filename, scene=None, info_callback = None):
for ob in sel:
ob_num+= 1
if ob.type in ('LAMP', 'CAMERA', 'EMPTY', 'META'):
if ob.type in ('LAMP', 'CAMERA', 'EMPTY', 'META', 'ARMATURE'):
continue
me = ob.data
@ -722,26 +722,26 @@ class PovrayRender(bpy.types.RenderEngine):
def _export(self, scene):
import tempfile
self.temp_file_in = tempfile.mktemp(suffix='.pov')
self.temp_file_out = tempfile.mktemp(suffix='.tga')
self.temp_file_ini = tempfile.mktemp(suffix='.ini')
self._temp_file_in = tempfile.mktemp(suffix='.pov')
self._temp_file_out = tempfile.mktemp(suffix='.tga')
self._temp_file_ini = tempfile.mktemp(suffix='.ini')
'''
self.temp_file_in = '/test.pov'
self.temp_file_out = '/test.tga'
self.temp_file_ini = '/test.ini'
self._temp_file_in = '/test.pov'
self._temp_file_out = '/test.tga'
self._temp_file_ini = '/test.ini'
'''
def info_callback(txt):
self.update_stats("", "POVRAY: " + txt)
write_pov(self.temp_file_in, scene, info_callback)
write_pov(self._temp_file_in, scene, info_callback)
def _render(self):
try: os.remove(self.temp_file_out) # so as not to load the old file
try: os.remove(self._temp_file_out) # so as not to load the old file
except: pass
write_pov_ini(self.temp_file_ini, self.temp_file_in, self.temp_file_out)
write_pov_ini(self._temp_file_ini, self._temp_file_in, self._temp_file_out)
print ("***-STARTING-***")
@ -757,15 +757,15 @@ class PovrayRender(bpy.types.RenderEngine):
pov_binary = winreg.QueryValueEx(regKey, 'Home')[0] + '\\bin\\pvengine'
if 1:
self.process = subprocess.Popen([pov_binary, self.temp_file_ini]) # stdout=subprocess.PIPE, stderr=subprocess.PIPE
self._process = subprocess.Popen([pov_binary, self._temp_file_ini]) # stdout=subprocess.PIPE, stderr=subprocess.PIPE
else:
# This works too but means we have to wait until its done
os.system('%s %s' % (pov_binary, self.temp_file_ini))
os.system('%s %s' % (pov_binary, self._temp_file_ini))
print ("***-DONE-***")
def _cleanup(self):
for f in (self.temp_file_in, self.temp_file_ini, self.temp_file_out):
for f in (self._temp_file_in, self._temp_file_ini, self._temp_file_out):
try: os.remove(f)
except: pass
@ -785,19 +785,19 @@ class PovrayRender(bpy.types.RenderEngine):
y= int(r.resolution_y*r.resolution_percentage*0.01)
# Wait for the file to be created
while not os.path.exists(self.temp_file_out):
while not os.path.exists(self._temp_file_out):
if self.test_break():
try: self.process.terminate()
try: self._process.terminate()
except: pass
break
if self.process.poll() != None:
if self._process.poll() != None:
self.update_stats("", "POVRAY: Failed")
break
time.sleep(self.DELAY)
if os.path.exists(self.temp_file_out):
if os.path.exists(self._temp_file_out):
self.update_stats("", "POVRAY: Rendering")
@ -807,7 +807,7 @@ class PovrayRender(bpy.types.RenderEngine):
result = self.begin_result(0, 0, x, y)
lay = result.layers[0]
# possible the image wont load early on.
try: lay.load_from_file(self.temp_file_out)
try: lay.load_from_file(self._temp_file_out)
except: pass
self.end_result(result)
@ -815,23 +815,23 @@ class PovrayRender(bpy.types.RenderEngine):
while True:
# test if povray exists
if self.process.poll() != None:
if self._process.poll() != None:
update_image();
break
# user exit
if self.test_break():
try: self.process.terminate()
try: self._process.terminate()
except: pass
break
# Would be nice to redirect the output
# stdout_value, stderr_value = self.process.communicate() # locks
# stdout_value, stderr_value = self._process.communicate() # locks
# check if the file updated
new_size = os.path.getsize(self.temp_file_out)
new_size = os.path.getsize(self._temp_file_out)
if new_size != prev_size:
update_image()

@ -100,7 +100,7 @@ def draw(layout, context, context_member):
if convert_to_pyobject and not hasattr(val_orig, "len"):
row.itemL(text=val_draw)
else:
row.itemR(rna_item, '["' + key + '"]', text="")
row.itemR(rna_item, '["%s"]' % key, text="")
row = split.row(align=True)

@ -164,7 +164,7 @@ void ED_operatortypes_curve(void)
void ED_keymap_curve(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
// wmKeyMapItem *kmi;
keymap= WM_keymap_find(keyconf, "Font", 0, 0);
keymap->poll= ED_operator_editfont;
@ -251,7 +251,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CURVE_OT_specials_menu", WKEY, KM_PRESS, 0, 0);
/* menus */
WM_keymap_add_item(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
ED_object_generic_keymap(keyconf, keymap, TRUE);
}

@ -1625,11 +1625,10 @@ static int pyrna_struct_setattro( BPy_StructRNA *self, PyObject *pyname, PyObjec
if (prop==NULL) {
// XXX - This currently allows anything to be assigned to an rna prop, need to see how this should be used
// but for now it makes porting scripts confusing since it fails silently.
#if 0
if (!BPy_StructRNA_CheckExact(self) && PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) {
// edit: allowing this for setting classes internal attributes.
if (name[0]=='_' && !BPy_StructRNA_CheckExact(self) && PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) {
return 0;
} else
#endif
{
PyErr_Format( PyExc_AttributeError, "StructRNA - Attribute \"%.200s\" not found", name);
return -1;