File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -295,19 +295,25 @@ def from_mainwindow(
295295 if not isinstance (config , config_class ) and config is not None :
296296 raise QgistTypeError (translate ('global' , '"config" must be a "config_class" object or None. (dtype_workbench from_mainwindow)' ))
297297
298- toolbars_list = [
299- dtype_uielement_class .from_uiobject (uiobject ).as_dict ()
298+ def uiobject_to_dict (_uiobject ):
299+ try :
300+ return dtype_uielement_class .from_uiobject (_uiobject ).as_dict ()
301+ except QgistUnnamedElementError :
302+ return None
303+
304+ toolbars_list = [ui_dict for ui_dict in (
305+ uiobject_to_dict (uiobject )
300306 for _ , uiobject in dtype_workbench_class ._get_uielements_from_mainwindow (
301307 mainwindow , QToolBar
302308 ).items ()
303- ]
309+ ) if ui_dict is not None ]
304310
305- dockwidgets_list = [
306- dtype_uielement_class . from_uiobject (uiobject ). as_dict ( )
311+ dockwidgets_list = [ui_dict for ui_dict in (
312+ uiobject_to_dict (uiobject )
307313 for _ , uiobject in dtype_workbench_class ._get_uielements_from_mainwindow (
308314 mainwindow , QDockWidget
309315 ).items ()
310- ]
316+ ) if ui_dict is not None ]
311317
312318 mainwindow_state = base64 .encodebytes (bytes (mainwindow .saveState ())).decode ('ASCII' )
313319
You can’t perform that action at this time.
0 commit comments