Einzelnen Beitrag anzeigen

Trafel21

Registriert seit: 16. Nov 2018
69 Beiträge
 
#9

AW: Ungültige Zeigeroperation

  Alt 16. Mai 2019, 05:25
Hallöle...

Der Fehler riecht danach, daß ein Objekt, was im Dictionary liegt, extern vom Dictionary mit Free freigeben wurde. Dann hat das Dictionary nur einen Pointer der nicht mehr existiert. Prüfe mal darauf.

Zeige mal wie du die Objekte erzeugst und in das Dictionary legst.
Guten Morgen das passiert so:


Code:
// neuen Anruf mit CallID anlegen
bc_AsteriskCallDictionaryDataModule.AddDictValue(GetCurrentCallID(StrBuffer));
Code:
procedure Tbc_AsteriskCallDictionaryDataModule.AddDictValue(ACallID: String);
var lCallInstance: TCallInstance;
begin

  if not fCallInstanceDictionary.TryGetValue(ACallID, lCallInstance) then
  begin
  lCallInstance := TCallInstance.Create;
  lCallInstance.CallID := ACallID;

  fCallInstanceDictionary.Add(ACallID, lCallInstance);
  end
end;
Wenn ich Werte innerhalb der CallInstance bearbeiten möchte ruf ich die trygetvalue von Dictionary auf

Bspw.:

Code:
function Tbc_AsteriskCallDictionaryDataModule.GetChannelID(ACallID: String): String;
var lCallInstance: TCallInstance;
begin
  if (fCallInstanceDictionary.TryGetValue(ACallID, lCallInstance)) then
  result := lCallInstance.ChannelID;
end;

procedure Tbc_AsteriskCallDictionaryDataModule.SetCallEnd(ACallID: String; AToday: TDateTime);
var lCallInstance: TCallInstance;
begin
  if(fCallInstanceDictionary.TryGetValue(ACallID, lCallInstance)) then
  begin
    lCallInstance.CallEnd := AToday;
  end;
end;
  Mit Zitat antworten Zitat