I appear to have created code that is trashing memory.
Having never had such problems before, i am now settign an Invalid Pointer Operation.
In the following the value of the const string sFilename gets trashed after my call to PromptForXYZPropertiesSettings.
// Allow the user to quickly display the properties of XYZ without needing to display the full Editor
function PromptForXYZProperties(const sFilename:string; var AXYZProperties: TXYZProperties): boolean;
var
PropEditor: TdlgEditor;
begin
PropEditor:= TdlgEditor.create(nil);
try
PropEditor.LoadFromFile(sFilename); <-- sFilename = 'C:\My Folder\Some Folder.txt'
PropEditor.SelectedXYZProperties := AXYZProperties;
// Bypass PropEditor to show form owned by it
Result := PropEditor.PromptForXYZPropertiesSettings;
if Result then
begin
PropEditor.SaveToFile(sFilename); <-- sFilename now somethign like 'B'#1#0#0'ë' or value of a different var
end;
finally
PropEditor.free;
end;
end;
Other Details:
So I would like some advice on how to debug the issue. I was thinking perhaps watching the memory pointer where the sFilename var exists to see where it gets trashed, but not sure how i would do that (obviously needs to be done within the app so is owned memory).
Thanks
Sounds to me like something's trashing your stack. From a casual look at your code I can't see any obvious correctness problems. You've got the right idea: To track this down you need to monitor the value of your string and see when it changes. Here's how you do that:
sFilename and double-click on it.sFileame: string $18FEA8 : $4A0E5C. Those two hex values are the locations of the reference to the string and the string data itself, respectively.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With