View Issue Details

IDProjectCategoryView StatusLast Update
0004284JEDI VCL00 JVCL Componentspublic2007-10-31 04:56
ReporterlawAssigned ToAHUser 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.34 
Summary0004284: JvDBTreeView invalid class typecast
Descriptionif 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;
TagsNo tags attached.

Activities

law

2007-10-30 20:05

reporter   ~0014008

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;

AHUser

2007-10-31 04:55

developer   ~0014009

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