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:
authorCampbell Barton <ideasman42@gmail.com>2010-09-25 10:36:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-09-25 10:36:01 +0400
commit92954672dc9d3fae95fcf07c39b5787253787469 (patch)
tree3f9cc2328698954668896b21ab626eb14bbeb9a0 /release
parentb57e09544a430a585e8665c7064252be1b59ec57 (diff)
bugfix [#23978] Error installing addon
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy/utils.py21
-rw-r--r--release/scripts/ui/space_userpref.py30
2 files changed, 37 insertions, 14 deletions
diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py
index 5d5f736a33b..1792425268b 100644
--- a/release/scripts/modules/bpy/utils.py
+++ b/release/scripts/modules/bpy/utils.py
@@ -441,17 +441,18 @@ def addon_disable(module_name, default_set=True):
mod = _sys.modules.get(module_name)
- if mod is None:
- print("addon_disable", module_name, "not loaded, nothing to do")
- return
-
- mod.__addon_enabled__ = False
+ # possible this addon is from a previous session and didnt load a module this time.
+ # so even if the module is not found, still disable the addon in the user prefs.
+ if mod:
+ mod.__addon_enabled__ = False
- try:
- _bpy_types._unregister_module(module_name, free=False) # dont free because we may want to enable again.
- mod.unregister()
- except:
- traceback.print_exc()
+ try:
+ _bpy_types._unregister_module(module_name, free=False) # dont free because we may want to enable again.
+ mod.unregister()
+ except:
+ traceback.print_exc()
+ else:
+ print("addon_disable", module_name, "not loaded")
# could be in more then once, unlikely but better do this just incase.
addons = _bpy.context.user_preferences.addons
diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py
index a2be1b8a3b3..d15dc8934ca 100644
--- a/release/scripts/ui/space_userpref.py
+++ b/release/scripts/ui/space_userpref.py
@@ -920,8 +920,8 @@ class USERPREF_PT_addons(bpy.types.Panel):
split = layout.split(percentage=0.2)
col = split.column()
- col.prop(context.window_manager, "addon_filter", text="Filter", expand=True)
col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
+ col.prop(context.window_manager, "addon_filter", text="Filter", expand=True)
col = split.column()
@@ -1010,14 +1010,18 @@ class USERPREF_PT_addons(bpy.types.Panel):
col.column().label(text="Missing script files")
module_names = {mod.__name__ for mod, info in addons}
- for ext in sorted(missing_modules):
+ for module_name in sorted(missing_modules):
+ is_enabled = module_name in used_ext
# Addon UI Code
box = col.column().box()
colsub = box.column()
row = colsub.row()
- row.label(text=ext, icon='ERROR')
- row.operator("wm.addon_disable").module = ext
+ row.label(text=module_name, icon='ERROR')
+
+ if is_enabled:
+ row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name
+
from bpy.props import *
@@ -1093,6 +1097,7 @@ class WM_OT_addon_install(bpy.types.Operator):
pyfile = self.filepath
path_addons = bpy.utils.script_paths("addons")[-1]
+ contents = set(os.listdir(path_addons))
#check to see if the file is in compressed format (.zip)
if zipfile.is_zipfile(pyfile):
@@ -1121,6 +1126,23 @@ class WM_OT_addon_install(bpy.types.Operator):
traceback.print_exc()
return {'CANCELLED'}
+ # disable any addons we may have enabled previously and removed.
+ # this is unlikely but do just incase. bug [#23978]
+ addons_new = set(os.listdir(path_addons)) - contents
+ for new_addon in addons_new:
+ bpy.utils.addon_disable(os.path.splitext(new_addon)[0])
+
+ # possible the zip contains multiple addons, we could disallow this
+ # but for now just use the first
+ for mod in USERPREF_PT_addons._addon_list():
+ if mod.__name__ in addons_new:
+ info = addon_info_get(mod)
+
+ # show the newly installed addon.
+ context.window_manager.addon_filter = 'All'
+ context.window_manager.addon_search = info["name"]
+ break
+
# TODO, should not be a warning.
# self.report({'WARNING'}, "File installed to '%s'\n" % path_dest)
return {'FINISHED'}