Bug with CheckBoxTreeSelectionModel

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Bug with CheckBoxTreeSelectionModel

Postby p1999 » Tue Apr 16, 2013 6:55 am

Hi all,

(Just to document a bug that I have found before forgetting about it.)

If you use checkBoxTree.getModel().removeNodeFromParent(node), and the node is the last unchecked node of its siblings, and there are unchecked siblings of one of its parent nodes, then the selection model will become inconsistent and will cause a stack overflow error when the tree is refreshed, e.g. when a treeModel.nodeChanged is fired. I have taken a look at the source code, and that is why I can confirm that it is indeed a bug with CheckBoxTreeSelectionModel.

To workaround this bug, if the node has siblings, make sure the node's selection state is equal to one of its siblings before removing it.

Regards,
p1999
p1999
 
Posts: 4
Joined: Tue Apr 16, 2013 6:30 am

Re: Bug with CheckBoxTreeSelectionModel

Postby JIDE Support » Tue Apr 16, 2013 8:19 am

Thanks for the detailed bug report. Will try to fix it in next regular release.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Bug with CheckBoxTreeSelectionModel

Postby JIDE Support » Wed May 15, 2013 12:05 am

It's weird that I can't reproduce the issue. Could you please give the attached test case a try to make sure we are on the same page? If possible, could you please use this test case as a start point to create a stand-alone test case for us to investigate further?

Thanks,
Attachments
TestFilterMoveNodes.java
(4.22 KiB) Downloaded 1783 times
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Bug with CheckBoxTreeSelectionModel

Postby p1999 » Sat May 18, 2013 8:24 am

I just saw your post, and am trying out right now, but I think you might have misunderstood the situation.
1. It is a CheckBoxTree. Do you mean CheckBoxTreeSelectionModel is used in any other place?
2. The node must satisfy the following criteria:
a. It is unchecked.
b. All its siblings are checked.
c. One of its parent nodes must have a sibling which is unchecked.

Let me give an example below:

Code: Select all
Root
- A
- - B
- - C*
- D

We at first have only C's checkbox checked. A will be partially checked. We then remove B. Then we call a nodeChanged on one of the nodes (I am not sure at the moment exactly which node will cause the issue, but I believe that any node will do).

Let me know when you have reproduced the issue so that you can save me some effort.
Last edited by p1999 on Sat May 18, 2013 8:58 am, edited 1 time in total.
p1999
 
Posts: 4
Joined: Tue Apr 16, 2013 6:30 am

Re: Bug with CheckBoxTreeSelectionModel

Postby p1999 » Sat May 18, 2013 8:57 am

I'm sorry, the example above was slightly too simple to cause the problem. This is the revised criteria for the node:
a. It is unchecked.
b. All its siblings are checked.
c. One of the parents of its parent node must have a sibling which is unchecked.

Here is a corresponding example:
Code: Select all
Root
- A
- - B
- - - C
- - - D*
- E
p1999
 
Posts: 4
Joined: Tue Apr 16, 2013 6:30 am

Re: Bug with CheckBoxTreeSelectionModel

Postby p1999 » Sat May 18, 2013 9:04 am

There! It's reproducible:
Code: Select all
            LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
            final DefaultMutableTreeNode root=new DefaultMutableTreeNode("root");
            final DefaultMutableTreeNode A=new DefaultMutableTreeNode("A");
            final DefaultMutableTreeNode B=new DefaultMutableTreeNode("B");
            final DefaultMutableTreeNode C=new DefaultMutableTreeNode("C");
            final DefaultMutableTreeNode D=new DefaultMutableTreeNode("D");
            final DefaultMutableTreeNode E=new DefaultMutableTreeNode("E");
            root.add(A);
            A.add(B);
            B.add(C);
            B.add(D);
            root.add(E);
            final DefaultTreeModel model=new DefaultTreeModel(root);
            final CheckBoxTree tree=new CheckBoxTree(model);
            final CheckBoxTreeSelectionModel selModel=tree.getCheckBoxTreeSelectionModel();
            selModel.clearSelection();
            selModel.addSelectionPath(new TreePath(D.getPath()));
            JFrame frame=new JFrame("Jide 3.4.9 Java "+System.getProperty("java.runtime.version"));
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));
            frame.getContentPane().add(new JScrollPane(tree));
            frame.getContentPane().add(new JButton(new AbstractAction("Remove B")
            {
               public void actionPerformed(ActionEvent e)
               {
                  model.removeNodeFromParent(C);
               }
            }));
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
p1999
 
Posts: 4
Joined: Tue Apr 16, 2013 6:30 am

Re: Bug with CheckBoxTreeSelectionModel

Postby JIDE Support » Mon May 20, 2013 11:17 am

Thanks for the bug report. Reproduced and will fix it in next regular release.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Bug with CheckBoxTreeSelectionModel

Postby JIDE Support » Thu Jun 13, 2013 6:44 pm

Just so you know, this is fixed in 3.5.6 just released.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 17 guests

cron