View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003256 | JEDI VCL | 00 JVCL Components | public | 2005-10-05 02:14 | 2005-11-26 05:26 |
Reporter | ivan_ra | Assigned To | obones | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.00 | ||||
Target Version | Fixed in Version | 3.10 | |||
Summary | 0003256: TJvDBTreeView: correct solution for change visibility | ||||
Description | "Active" TJvDBTreeView from 3.00 release changes visibility with many exceptions "invalid variant conversion". You can check out it when your TJvDBTreeView is in docked form or simply by hide and show form with TJvDBTreeView. That was fixed in CVS rewision 1.36 by overriding of 2 methods: procedure TJvCustomDBTreeView.CreateWnd; begin inherited CreateWnd; if Assigned(FDataLink) and Assigned(FDataLink.DataSet) then FDataLink.DataSet.Active := FSavedActive; end; procedure TJvCustomDBTreeView.DestroyWnd; begin if Assigned(FDataLink) and Assigned(FDataLink.DataSet) then begin FSavedActive := FDataLink.DataSet.Active; FDataLink.DataSet.Active := False; end; inherited DestroyWnd; end; Now TJvDBTreeView recreates every time when it shows after hide. But this 2 methods completely remove information about TJvDBTreeView expanded state and selected node. This is not comfortable for users. Moreover, unregulated closing and opening of FDataLink.DataSet is very bad practice | ||||
Additional Information | I suggest solution to copletly restore TJvDBTreeView after hiding, and without change of FDataLink.DataSet state: type TJvCustomDBTreeView = class(TJvCustomTreeView) private ... FMastersStream:TStream; // minor change of interface ... end; destructor TJvCustomDBTreeView.Destroy; begin if assigned(FMastersStream) then FreeAndNil(FMastersStream); ... end; procedure TJvCustomDBTreeView.DestroyWnd; var Node: TTreeNode; temp:string; l:integer; begin if Items.Count > 0 then begin // save master values into stream FMastersStream:= TMemoryStream.Create; Node := Items.GetFirstNode; while Node <> nil do begin // save MasterValue as string temp:=VarToStr(TJvDBTreeNode(Node).MasterValue); l:=length(temp); FMastersStream.Write(l,SizeOf(l)); FMastersStream.Write(temp[1],l); Node := Node.GetNext; end; end; inherited DestroyWnd; end; procedure TJvCustomDBTreeView.CreateWnd; var Node: TTreeNode; temp:string; l:integer; begin inherited CreateWnd; // tree is restored. Now we must restore information about Master Values if assigned(FMastersStream) and (Items.Count > 0) then begin Node := Items.GetFirstNode; FMastersStream.Position:=0; while Node <> nil do begin FMastersStream.Read(l,SizeOf(l)); SetLength(temp,l); FMastersStream.Read(temp[1],l); TJvDBTreeNode(Node).SetMasterValue(temp); Node := Node.GetNext; end; FreeAndNil(FMastersStream); end; end; | ||||
Tags | No tags attached. | ||||
|
Please remove unexpected closing of dataset from code. Put shown solution into CVS. It's just like TTreeView .CreateWnd and .DestroyWnd, nothing else. Also there is new incorrect code in Change2 (from last VCS): procedure TJvCustomDBTreeView.Change2(Node: TTreeNode); begin if Node <> nil then begin if (Node as TJvDBTreeNode).FMasterValue = Unassigned then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ when FMasterValue = null it raises variant conversion exception. This is correct code: if VarIsEmpty((Node as TJvDBTreeNode).FMasterValue) then |
|
This is in the process of being reviewed. Note: I was the one who put the "solution" in, but I left a note saying i was not satisfied with it. Your solution seems much more acceptable, I'll put it in as soon as I have reviewed it. |
|
This is now in CVS. Please, next time, create a new issue instead of putting a comment into an existing one. This makes our life easier |
Date Modified | Username | Field | Change |
---|---|---|---|
2005-10-05 02:14 | ivan_ra | New Issue | |
2005-11-25 01:36 | ivan_ra | Note Added: 0008156 | |
2005-11-25 02:51 | ivan_ra | Note Edited: 0008156 | |
2005-11-26 05:15 | obones | Note Added: 0008165 | |
2005-11-26 05:15 | obones | Status | new => acknowledged |
2005-11-26 05:26 | obones | Status | acknowledged => resolved |
2005-11-26 05:26 | obones | Resolution | open => fixed |
2005-11-26 05:26 | obones | Assigned To | => obones |
2005-11-26 05:26 | obones | Note Added: 0008166 |