Menu

#307 FilterPanel: Listener is triggered multiple times

any future version
needs-merge
None
FR 10
FR 10
5
2018-06-20
2018-05-29
No

The actionPerformed()-method of PropertyDefinitionChanged is called multiple times. The hash codes of the source and the listener indicates that multiple different ComboBoxes are active, triggering their own listeners.
Each time showFilter() is called, all components are removed from the panel, recreated and readded. showFilter() is also called from the listener's actionPerformed()-methods. This may cause the bug.

Discussion

  • Philipp Mewes

    Philipp Mewes - 2018-05-29
    • summary: FilterPanel: Listeners are added multiple times --> FilterPanel: Listener is triggered multiple times
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,3 +1,2 @@
    -When udo.edu.scaffoldhunter.gui.filtering.FilterPanel.showFilter() is called, listeners are added to the comboboxes by calling showPropertyDefinition(), showStringFilter() and showNumFilter(). The actionPerformed()-methods of  this lsteners call showFilter() too, so everytime an action event occurs another filter is added for each listener registered, which leads to an exponential growth of the number of listeners. Sometimes this slows down the GUI since the work in the listener is repeated many times.
    -
    -The best way to fix this would be to ensure that each listener is only added once.
    +The actionPerformed()-method of PropertyDefinitionChanged is called multiple times. The hash codes of the source and the listener indicates that multiple different ComboBoxes are active, triggering their own listeners. 
    +Each time showFilter() is called, all components are removed from the panel, recreated and readded. showFilter() is also called from the listener's actionPerformed()-methods. This may cause the bug.
    
     
  • Philipp Mewes

    Philipp Mewes - 2018-06-01

    Seems to be an easy fix. I wondered why the property definition comboxbox was recreated each time showFilter() was called, which was especially everytime, the value of this combobox changes. Moved the creation and configuration of the combobox to the constructor. This does not ony saves some resources, it also fixes the bug, since only a single instance of the combobox with a single listener-instance is presented. See here: [4ee2b0].

    The procedure is similar to the recreaton of the other GUI elements at the panel. Even though this seems not to cause any bugs, it could be implemented more efficiently by creating each element only once. Since the code in this class is already touched by this bug, should this be changed too?

     

    Related

    Commit: [4ee2b0]

  • Philipp Mewes

    Philipp Mewes - 2018-06-01

    Fixed two small bugs: [a030b5] and [82bc27].

     

    Related

    Commit: [82bc27]
    Commit: [a030b5]

  • Philipp Mewes

    Philipp Mewes - 2018-06-04

    Another fix: [d507ae].

     

    Related

    Commit: [d507ae]

  • Philipp Mewes

    Philipp Mewes - 2018-06-04
    • status: in-progress --> needs-review
     
  • Till Schäfer

    Till Schäfer - 2018-06-08
    • status: needs-review --> re-opened
     
  • Till Schäfer

    Till Schäfer - 2018-06-08

    As far as i understood from a first glance, showFilter is called on initialization and later whenever PropertyDefinitionChanged, NumComparisonChanged or StringComparisonChanged is called, to update the content of the drop down. The problem here is, that showFilter just re-adds the components and does not clean up the listeners on the old components, which causes the GC to not clean them up und causes all the hidden elements to be updated as well. Am I right?
    If thats the case, the folowing things should be considered as well:
    (1) The problem does not only apply to showPropertyDefinition, but also to showNumFilter, showStringFilter, and showDeleteButton, showNumValue, and showStringValue. I think a good solution here would be to split the functionality in "create" and "update" that is now bundled in #showFilter. Thus, just create the static content in the constructor (as you have done for showPropertyDefiniton/propDefCombo. And just update the content of the panel and the content of the boxes by showFilter which should be renamed to updateFilterPanel then.

    (2) An organisational thing: is this easy to seperate this changes from FR 10? In this case, please rebase on master, and merge the changes back into FR 10 as soon this bug is fixed. This allows to merge this bug prior to FR 10.

     
  • Philipp Mewes

    Philipp Mewes - 2018-06-08
    • status: re-opened --> in-progress
     
  • Philipp Mewes

    Philipp Mewes - 2018-06-08

    Yes. I think the reason for this is the propertyDefinitionsModel that holds the last reference to the ComboBox. If propertyDefinitionsModel.setSelectedItem() is called, the listeners of all associated ComboBoxes are triggered. In showNumFilter() and showStringFilter() the problem does not occur because a new model is used there. However this methods still cause overhead, since the combo boxes are recreated.

     

    Last edit: Philipp Mewes 2018-06-08
  • Philipp Mewes

    Philipp Mewes - 2018-06-12

    (1) Moved the other comboboxes to the constructor ([19c7e9]), which caused a bug which is fixed here: [a19b49]. Also moved stringValue and numValue ([5321a9]).

     

    Related

    Commit: [19c7e9]
    Commit: [5321a9]
    Commit: [a19b49]

  • Philipp Mewes

    Philipp Mewes - 2018-06-12

    (2) I think rebasing is not possible here. [5321a9] on bug-307 changes the update of the SpinnerNumberModel of the numValue-spinner (see ll 350 - 358). This update is necessary since eature-10 introduces limits for this spinner. If bug-307 is rebased, this change will disappear and must be re-applied on feature-10 after the changes from bug-307 are merged.

     

    Related

    Commit: [5321a9]

  • Philipp Mewes

    Philipp Mewes - 2018-06-14

    The latest fix ([370201]) removed this modification. Maybe a rebase is still possible. I will check this.

     

    Related

    Commit: [370201]

  • Philipp Mewes

    Philipp Mewes - 2018-06-15

    [a030b5] still refers to changes from feature-10. Rebasing bug-307 onto master therefore would lead to an inconsistent history.

     

    Related

    Commit: [a030b5]

  • Philipp Mewes

    Philipp Mewes - 2018-06-15
    • status: in-progress --> needs-review
     
  • Till Schäfer

    Till Schäfer - 2018-06-19
    • status: needs-review --> needs-merge
    • Blocks: feature #10 --> FR 10
    • Depends On: --> FR 10
     
  • Till Schäfer

    Till Schäfer - 2018-06-19

    looks good. please merge this back to FR 10 on your own. As soon FR 10 is finished I will close this bug.

     
  • Philipp Mewes

    Philipp Mewes - 2018-06-20

    Merged into feature-10 in [844e93]

     

    Related

    Commit: [844e93]


Log in to post a comment.

MongoDB Logo MongoDB