# HG changeset patch # User Goffi # Date 1584559581 -3600 # Node ID 9b73a18799892c42131b94c075890dc6c41f290f # Parent e578df3304d8fc993411613c55171b93ec53c4fb core: fixed doAction when new widget is already existing and visible: when the doAction new widget was existing and visible, the factory was creating a new one, which could result in a consusing situation for the user (share widget's attachment added to an non visible widget for instance). diff -r e578df3304d8 -r 9b73a1879989 cagou/core/cagou_main.py --- a/cagou/core/cagou_main.py Sat Mar 07 00:05:50 2020 +0100 +++ b/cagou/core/cagou_main.py Wed Mar 18 20:26:21 2020 +0100 @@ -813,6 +813,9 @@ # selected_widget can be modified in changeWidget, so we need to set it before self.selected_widget = new + if to_change == new: + log.debug("switchWidget called with old==new, nothing to do") + return new to_change.whwrapper.changeWidget(new) return new @@ -945,10 +948,18 @@ except IndexError: log.warning("No plugin widget found to do {action}".format(action=action)) else: - factory = plg_infos['factory'] - return self.switchWidget( - None, - factory(plg_infos, target=target, profiles=profiles)) + try: + # does the widget already exist? + wid = next(self.widgets.getWidgets( + plg_infos['main'], + target=target, + profiles=profiles)) + except StopIteration: + # no, let's create a new one + factory = plg_infos['factory'] + wid = factory(plg_infos, target=target, profiles=profiles) + + return self.switchWidget(None, wid) ## bridge handlers ##