Einzelnen Beitrag anzeigen

Assertor

Registriert seit: 4. Feb 2006
Ort: Hamburg
1.296 Beiträge
 
Turbo C++
 
#1

Problem mit VST Node Löschen nach Edit

  Alt 27. Jul 2009, 16:27
Hi DPler,

Ich nutze Inplace Editors (IVTEditLink) und habe nun ein Problem damit: Ich möchte einen neuen Node, wenn der Benutzer keine Daten eingegeben hat gleich wieder löschen.

Wo mache ich das am besten?

Delphi-Quellcode:
procedure TEditPropertyLink.DoCancelEdit;
var
  NodeData: PGridNodeData;
  Item: TBLItemSizesObject;
begin
  inherited;
  NodeData := FTree.GetNodeData(FNode);
  // delete added row if user has not entered any data
  if Assigned(NodeData) and (NodeData.FieldData.Name = '') then
  begin
    Item := NodeData.FieldData;
    FTree.DeleteNode(FNode, True);
    // Item.Delete; // remove Item from ObjectList
  end;
end;
Das Problem ist jetzt: Es klappt genau 1x: Benutzer klickt hinzufügen, drückt ESC - alles ok soweit. Benutzer klickt nun erneut hinzufügen: AV, ListIndex Fehler (hier wird versucht bei der OL auf den Index 605800x zuzugreifen - obwohl es nur 4 Elemente gibt), EOutOfMemory - je nach Wahl und Ansatz.

Code zum Hinzufügen:
Delphi-Quellcode:
procedure TfrmEditItemSizes.actAddExecute(Sender: TObject);
var
  Idx: Integer;
  Node: PVirtualNode;
  NodeData: PGridNodeData;
begin
  Idx := FItemSizes.Add;
  Node := vstList.AddChild(nil);
  vstList.ValidateNode(Node, False);
  NodeData := vstList.GetNodeData(Node);
  if Assigned(NodeData) then
  begin
    NodeData.FieldData := FItemSizes[Idx];
    vstList.EditNode(Node, 0);
  end;
end;
Der Record ist so definiert:
Delphi-Quellcode:
type
  TGridNodeData = record
    FieldData: TBLItemSizesObject;
  end;
  PGridNodeData = ^TGridNodeData;
Node wird in InitNode zugewiesen:
Delphi-Quellcode:
procedure TfrmEditItemSizes.vstListInitNode(Sender: TBaseVirtualTree;
  ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
var
  NodeData: PGridNodeData;
begin
  NodeData := Sender.GetNodeData(Node);
  NodeData.FieldData := FItemSizes[Node.Index];
end;
Ich habe schon überlegt, die Nodes besser in vst.OnEditCancelled zu löschen.

Gesucht habe ich schon sehr lange, hier und in Google Aber eine gute Beschreibung zum IVTEditLink finde ich nicht, ich habe mich an die interne Implementation vom TVTEdit und StringEditor gehalten.

Hat jemand eine Idee?

Edit: Ganz vergessen, setzte FastMM4 im FullDebugMode ein, alle Checks manuell eingeschaltet und ScanMemoryPoolForCorruption ist auch an. Der Stacktracke im Debugger ist für mich aber nicht nachvollziehbar an dieser Stelle:

Gruß Assertor

Stacktrace:
Zitat:
:7795fbae kernel32.RaiseException + 0x58
FastMM4.RaiseMemoryCorruptionError
FastMM4.InternalScanSmallBlockPool($40C926,4294967 295,0)
FastMM4.InternalScanMemoryPool(4294967295,0)
FastMM4.ScanMemoryPoolForCorruptions
FastMM4.DebugGetMem(72)
System.@GetMem(???)
System.@NewUnicodeString(???)
:0040331E __linkproc__ __linkproc__ GetMem(Size=????)
Classes.TList.Get(???)
Contnrs.TObjectList.GetItem(???)
DataModuleBLBase.TBaseBLObjectList.GetItem(6050168 )
DataModuleBLItemSizes.TBLItemSizesObjectList.GetIt em(6050168)
FormEditItemSizes.TfrmEditItemSizes.vstListInitNod e($7EA08960,$5C546C,$7E9FA6C0,[])
VirtualTrees.TBaseVirtualTree.DoInitNode($5C546C,$ 7E9FA6C0,[])
VirtualTrees.TBaseVirtualTree.InitNode($7E9FA6C0)
VirtualTrees.TBaseVirtualTree.GetDisplayRect($7E9F A6C0,-1,False,False,False)
VirtualTrees.TBaseVirtualTree.InvalidateNode($7E9F A6C0)
VirtualTrees.TCustomVirtualStringTree.InvalidateNo de($7E9FA6C0)
VirtualTrees.TBaseVirtualTree.DoFocusNode($7E9FA78 0,True)
VirtualTrees.TBaseVirtualTree.SetFocusedNode($7E9F A780)
VirtualTrees.TBaseVirtualTree.EditNode($7E9FA780,0 )
FormEditItemSizes.TfrmEditItemSizes.actAddExecute( $7FF5A330)
Classes.TBasicAction.Execute
ActnList.TContainedAction.Execute
ActnList.TCustomAction.Execute
Classes.TBasicActionLink.Execute(???)
Controls.TControl.Click
StdCtrls.TCustomButton.Click
StdCtrls.TCustomButton.CNCommand(???)
Controls.TControl.WndProc(???)
Controls.TWinControl.WndProc((48401, 1304, 2753816, 0, 1304, 0, 1304, 42, 0, 0))
StdCtrls.TButtonControl.WndProc(???)
Controls.TControl.Perform(???,???,2753816)
Controls.DoControlMsg(???,(no value))
Controls.TWinControl.WMCommand((273, 1304, 0, 2753816, 0))
Forms.TCustomForm.WMCommand(???)
Controls.TControl.WndProc(???)
Controls.TWinControl.WndProc((273, 1304, 2753816, 0, 1304, 0, 1304, 42, 0, 0))
Forms.TCustomForm.WndProc(???)
Controls.TWinControl.MainWndProc(???)
Classes.StdWndProc(2232188,273,1304,2753816)
:7786fd72 ; C:\Windows\system32\USER32.dll
:7786fe4a ; C:\Windows\system32\USER32.dll
:77870943 ; C:\Windows\system32\USER32.dll
:77870b36 USER32.SendMessageW + 0x49
:7511b4b2 ; C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6002.18005_none_5cb7 2f96088b0de0\comctl32.dll
:7511b514 ; C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6002.18005_none_5cb7 2f96088b0de0\comctl32.dll
:7511b61f ; C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6002.18005_none_5cb7 2f96088b0de0\comctl32.dll
:7786fd72 ; C:\Windows\system32\USER32.dll
:7786fe4a ; C:\Windows\system32\USER32.dll
:778709d3 USER32.CallWindowProcW + 0x75
:77870979 USER32.CallWindowProcW + 0x1b
Controls.TWinControl.DefaultHandler(???)
:0046DD44 __linkproc__ TWinControl:efaultHandler(Self=????, Message=????)
:0046DC48 __linkproc__ TWinControl::WndProc(Self=:7FE8E4D0, Message=:0012F9D4)
:0044F515 __linkproc__ TButtonControl::WndProc(Self=????, Message=????)
:00436046 __linkproc__ StdWndProc(Window=2753816, Message=514, WParam=0, LParam=655394)
:7786fd72 ; C:\Windows\system32\USER32.dll
:7786fe4a ; C:\Windows\system32\USER32.dll
:7787018d ; C:\Windows\system32\USER32.dll
:7787022b USER32.DispatchMessageW + 0xf
:0048B436 __linkproc__ TApplication:rocessMessage(Self=????, Msg=????)
Angehängte Dateien
Dateityp: txt project1_memorymanager_eventlog_197.txt (4,4 KB, 1x aufgerufen)
Frederik
  Mit Zitat antworten Zitat