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
0004284 [JEDI VCL] 00 JVCL Components crash always 2007-10-30 19:15 2007-10-31 04:56
Reporter law View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0004284: JvDBTreeView invalid class typecast
Description if I inherit from TJvCustomDBTreeView, then TJvDBTreeNode.MoveTo raises exc. invalid class typeclass.

here's the solution:
procedure TJvDBTreeNode.MoveTo(Destination: TTreeNode; Mode: TNodeAttachMode);
var
  PersistNode: Boolean;
  TV: TJvDBTreeView;
begin
  if Destination <> nil then
  begin
    // If we are trying to move ourselves in the same parent and we are
    // already the last child, there is no point in moving us.
    // It's even dangerous as it triggers Mantis 3934
    if not ((Parent = Destination) and (Self = Destination.GetLastChild) and (Mode = naAddChild)) then
    begin
      //+law 20071030
      //TV := TreeView as TJvDBTreeView;
      TV := TreeView as TJvCustomDBTreeView;
      //-law
      PersistNode := TV.FPersistentNode;
      TV.MoveTo(Self as TJvDBTreeNode, Destination as TJvDBTreeNode, Mode);
      TV.FPersistentNode := True;
      if (Destination <> nil) and Destination.HasChildren and (Destination.Count = 0) then
        Free
      else
        inherited MoveTo(Destination, Mode);
      TV.FPersistentNode := PersistNode;
    end;
  end;
end;
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0014008)
law (reporter)
2007-10-30 20:05

working fix is here, sorry:
procedure TJvDBTreeNode.MoveTo(Destination: TTreeNode; Mode: TNodeAttachMode);
var
  PersistNode: Boolean;
  //+law 20071030
  //TV: TJvDBTreeView;
  TV: TJvCustomDBTreeView;
  //-law
begin
  if Destination <> nil then
  begin
    // If we are trying to move ourselves in the same parent and we are
    // already the last child, there is no point in moving us.
    // It's even dangerous as it triggers Mantis 3934
    if not ((Parent = Destination) and (Self = Destination.GetLastChild) and (Mode = naAddChild)) then
    begin
      //+law 20071030
      //TV := TreeView as TJvDBTreeView;
      TV := TreeView as TJvCustomDBTreeView;
      //-law
      PersistNode := TV.FPersistentNode;
      TV.MoveTo(Self as TJvDBTreeNode, Destination as TJvDBTreeNode, Mode);
      TV.FPersistentNode := True;
      if (Destination <> nil) and Destination.HasChildren and (Destination.Count = 0) then
        Free
      else
        inherited MoveTo(Destination, Mode);
      TV.FPersistentNode := PersistNode;
    end;
  end;
end;
(0014009)
AHUser (developer)
2007-10-31 04:55

Fixed. The TJvCustomDBTreeView.DragDrop method was also affected by the same bug.

- Issue History
Date Modified Username Field Change
2007-10-30 19:15 law New Issue
2007-10-30 20:05 law Note Added: 0014008
2007-10-31 04:55 AHUser Status new => resolved
2007-10-31 04:55 AHUser Fixed in Version => Daily / SVN
2007-10-31 04:55 AHUser Resolution open => fixed
2007-10-31 04:55 AHUser Assigned To => AHUser
2007-10-31 04:55 AHUser Note Added: 0014009


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