View Issue Details

IDProjectCategoryView StatusLast Update
0003934JEDI VCL00 JVCL Componentspublic2006-10-06 02:33
ReporterjayAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.30 
Summary0003934: JvDBTreeView: Displays same element 2 times when last child is dragged do same parent.
DescriptionI 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
----------------------
Products
   Brand A
   Brand B
   Brand C
Raw Materials
   Supplier 1
   Supplier 2

----------------------
After dragging "Brand C"
----------------------
Products
   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.

Regards
Jay

I actually encoutered this by mistake while testing the functionallity of the component
TagsNo tags attached.

Activities

obones

2006-10-03 03:50

administrator   ~0010279

Please provide the zipped sources of a sample application showing this.

2006-10-03 11:37

 

TestProject.zip (6,929 bytes)

jay

2006-10-03 11:37

reporter   ~0010284

I am sending you the file TestProject.zip 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.

Regards,
Jose Ostos

obones

2006-10-06 02:33

administrator   ~0010296

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: TestProject.zip
2006-10-03 11:37 jay Note Added: 0010284
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