Hi,

2008/8/10 Frank Niessink <[EMAIL PROTECTED]>:

> Yeah, I noticed it too. It's probably the EffortViewerColumnPopupMenu
> that's reconstructed on every wx.EVT_UI_UPDATE (basically every time
> you open a menu, hover over a button, etc.). From this comment (which
> is yours I think?):
>
>    # Since the aggregation can change in the viewer's lifetime and
>    # the UICommands depend on it, this is getColumnUICommands instead
>    # of createColumnUICommands.
>
> I conclude we do need to cache the ColumnUICommands. I'm working on it.

I was warm, but not exactly right. It was this code in menu.py that
was executing too often:

class DynamicMenuThatGetsUICommandsFromViewer(DynamicMenu):
    ...
    def updateMenuItems(self):
        newCommands = self.getUICommands()
        if newCommands != self._uiCommands:
            self.clearMenu()
            self.fillMenu(newCommands)
            self._uiCommands = newCommands

It turned out the newCommands was never equal to self._uiCommands,
since EffortViewer.getUICommands would create a new list every time it
was called. I added a __eq__ method to the UICommand class so that two
UICommands compare equal if they have the same menuText attribute.

Cheers, Frank

Reply via email to