Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003934 [JEDI VCL] 00 JVCL Components major always 2006-09-29 21:48 2006-10-06 02:33
Reporter jay View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0003934: JvDBTreeView: Displays same element 2 times when last child is dragged do same parent.
Description I have a DbTree that has several Elements on the first level ("Products", "Raw Materials"). The first Level "Products" has several children ("Brand A", "Brand B", "Brand C"). If I drag the last element "Brand C" to its parent "Productos", "Brand C" now appears 2 times at the end of the "Products" tree.

The worst thing is that if I then try to move "Brand C" again, the system hangs, (I assume it enters into an infinite loop).
Initial View
   Brand A
   Brand B
   Brand C
Raw Materials
   Supplier 1
   Supplier 2

After dragging "Brand C"
   Brand A
   Brand B
   Brand C
   Brand C
Raw Materials
   Supplier 1
   Supplier 2
The 2 "Brand C" elements show as selected. If I try to do anything with the "Brand C" elements again. it hangs.

I made a small change that appears to fix this, but I am convinced that it is not the best solution, it is just a work-around since I really don't understand the real problem.

Inside the "procedure TJvCustomDBTreeView.DragDrop" On Line number 1333 is following code:

      (Selected as TJvDBTreeNode).MoveTo(AnItem, AttachMode);

Before this line, I insert the code:

      if (Selected as TJvDBTreeNode).Parent.AbsoluteIndex <> AnItem.AbsoluteIndex then

So it now looks like:

      if (Selected as TJvDBTreeNode).Parent.AbsoluteIndex <> AnItem.AbsoluteIndex then
      (Selected as TJvDBTreeNode).MoveTo(AnItem, AttachMode);

In this particular case, the error occurs because I am moving the last child "Brand C" to its same parent "Products". Theoritically, this should not be done and what the code does is check if the element is being moved to the same parent, in which case it ignores the move.

However, the problem is probably really somewhere inside the TJvDBTreeNode.MoveTo procedure that is somehow not handling the move correctly under the condition that it is the last child that is being moved to exactly the same position.

I hope I explained the problem clearly so that it can be properly fixed, since my patch is really not that good.

Please feel free to cantact me if you have any doubts.


I actually encoutered this by mistake while testing the functionallity of the component
Additional Information
Tags No tags attached.
Attached Files zip file icon [^] (6,929 bytes) 2006-10-03 11:37

- Relationships

-  Notes
obones (administrator)
2006-10-03 03:50

Please provide the zipped sources of a sample application showing this.
jay (reporter)
2006-10-03 11:37

I am sending you the file that contains a small program that reproduces the situation along with an image of how it appears on the screen.

To reproduce, drag "Brand C" into "Products". You may have to do it 2 times for the situation to appear. Once it happens ("Brand C" shows 2 times), if you try to move "Brand C" to any other place, the system hangs and you can't even exit the program.

Please advice me if you need anything else.

Jose Ostos
obones (administrator)
2006-10-06 02:33

Thanks for the example, it was just fine.
As you guessed, the real reason was in MoveTo and this is where I fixed it. Basically, if we are adding the node in its current parent and it's already the last child then we don't do anything.
These changes are in SVN.

- Issue History
Date Modified Username Field Change
2006-09-29 21:48 jay New Issue
2006-10-03 03:50 obones Note Added: 0010279
2006-10-03 03:50 obones Status new => feedback
2006-10-03 11:37 jay File Added:
2006-10-03 11:37 jay Note Added: 0010284
2006-10-03 11:38 jay Issue Monitored: jay
2006-10-06 02:33 obones Status feedback => resolved
2006-10-06 02:33 obones Fixed in Version => Daily / SVN
2006-10-06 02:33 obones Resolution open => fixed
2006-10-06 02:33 obones Assigned To => obones
2006-10-06 02:33 obones Note Added: 0010296

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker