Fix [#31714] Pinning object context causes texture list to disappear

Problem was py code of main texture panel was not doing any check on the pinned id, assuming it managed the textures itself - but this is not the case of the Object datablock...

All work actually done by Sergey, was just missing the Lamp specific case. Checked both in code and with tests, quite sure all cases are now correctly handled!
This commit is contained in:
Bastien Montagne 2012-06-21 07:32:06 +00:00
parent 27aa2174b7
commit 19e81b12e7

@ -23,6 +23,7 @@ from bpy.types import Menu, Panel
from bpy.types import (Brush, from bpy.types import (Brush,
Lamp, Lamp,
Material, Material,
Object,
ParticleSettings, ParticleSettings,
Texture, Texture,
World) World)
@ -80,6 +81,15 @@ def context_tex_datablock(context):
return idblock return idblock
def id_tex_datablock(bid):
if isinstance(bid, Object):
if bid.type == 'LAMP':
return bid.data
return bid.active_material
return bid
class TextureButtonsPanel(): class TextureButtonsPanel():
bl_space_type = 'PROPERTIES' bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
@ -114,7 +124,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
pin_id = space.pin_id pin_id = space.pin_id
if space.use_pin_id and not isinstance(pin_id, Texture): if space.use_pin_id and not isinstance(pin_id, Texture):
idblock = pin_id idblock = id_tex_datablock(pin_id)
pin_id = None pin_id = None
if not space.use_pin_id: if not space.use_pin_id: