我似乎已经创建了破坏内存的代码.
从来没有遇到过这样的问题,我现在设置了一个无效的指针操作.
在下面,我调用PromptForXYZPropertiesSettings后,const字符串sFilename的值被删除.
// 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;
Run Code Online (Sandbox Code Playgroud)
其他详情:
所以我想就如何调试问题提出一些建议.我想也许正在观察sFilename var存在的内存指针,看看它在哪里被删除,但不知道我会怎么做(显然需要在应用程序中完成所以拥有内存).
谢谢
听起来像是在捣乱你的筹码.从随便看看你的代码我看不出任何明显的正确性问题.您有正确的想法:要跟踪此情况,您需要监控字符串的值并查看其更改时间.这是你如何做到这一点:
sFilename并双击它.sFileame: string $18FEA8 : $4A0E5C.这两个十六进制值分别是对字符串的引用和字符串数据本身的位置.| 归档时间: |
|
| 查看次数: |
1241 次 |
| 最近记录: |