|
50 | 50 | from ..error import (
|
51 | 51 | QgistTypeError,
|
52 | 52 | QgistValueError,
|
| 53 | + Qgist_ALL_Errors, |
53 | 54 | )
|
| 55 | +from ..msg import msg_warning |
54 | 56 | from ..util import translate
|
55 | 57 |
|
56 | 58 |
|
@@ -181,21 +183,33 @@ def toolbars(self):
|
181 | 183 | def _activate_uielements(uiobjects_dict, uielements_dict):
|
182 | 184 |
|
183 | 185 | for name_internal, uiobject in uiobjects_dict.items():
|
184 |
| - try: |
| 186 | + if name_internal in uielements_dict.keys(): |
185 | 187 | uielements_dict[name_internal].push_state_to_uiobject()
|
186 |
| - except KeyError: |
187 |
| - uielement = dtype_uielement_class.from_uiobject(uiobject) |
188 |
| - uielements_dict[uielement.name_internal] = uielement |
| 188 | + else: |
| 189 | + """try/except-block fixes #7, Certain other plugins inhibit |
| 190 | + the start of Workbench because of unnamed UI elements""" |
| 191 | + try: |
| 192 | + uielement = dtype_uielement_class.from_uiobject(uiobject) |
| 193 | + uielements_dict[uielement.name_internal] = uielement |
| 194 | + except Qgist_ALL_Errors as e: |
| 195 | + msg_warning(e) |
189 | 196 | for name_internal in (uielements_dict.keys() - uiobjects_dict.keys()):
|
190 | 197 | uielements_dict[name_internal].existence = False
|
191 | 198 |
|
192 | 199 | @staticmethod
|
193 | 200 | def _get_uielements_from_mainwindow(mainwindow, uielement_type):
|
194 | 201 |
|
| 202 | + def get_parent(el): |
| 203 | + """Fixes #6, Certain other plugins crash Workbench: |
| 204 | + Their UI's parent is exposed as a property instead of a method""" |
| 205 | + if hasattr(el.parent, '__call__'): |
| 206 | + return el.parent() |
| 207 | + return el.parent |
| 208 | + |
195 | 209 | return {
|
196 | 210 | uielement.objectName(): uielement
|
197 | 211 | for uielement in mainwindow.findChildren(uielement_type)
|
198 |
| - if uielement.parent().objectName() == 'QgisApp' |
| 212 | + if get_parent(uielement).objectName() == 'QgisApp' |
199 | 213 | }
|
200 | 214 |
|
201 | 215 | @staticmethod
|
|
0 commit comments