gpt4 book ai didi

delphi - Delphi 中的堆栈溢出

转载 作者:行者123 更新时间:2023-12-03 14:58:06 26 4
gpt4 key购买 nike

我正在 StackOverflow.com 上发布我的 Stack Overflow 问题。讽刺是最好的!

无论如何。我在 SkypeReply 事件处理程序上调用此过程,该处理程序被多次触发:

  Procedure OnCategoryRename;
Var
CategoryID : Integer;
sCtgName : String;
Begin
if (AnsiContainsStr(pCommand.Reply,'GROUP')) and (AnsiContainsStr(pCommand.Reply,'DISPLAYNAME')) then
begin
sCtgName := pCommand.Reply;
Delete(sCtgName,1,Pos('GROUP',sCtgName)+5);
CategoryID := StrToInt(Trim(LeftStr(sCtgName,Pos(' ',sCtgName))));
sCtgName := GetCategoryByID(CategoryID).DisplayName; // Removing THIS line does not produce a Stack Overflow!
ShowMessage(sCtgName);
end;

这样做的想法是循环遍历我的 Skype 组列表,以查看哪个组已重命名。据我所知,这并不重要,因为我的 S.O 被发现出现在这里

Function GetCategoryByID(ID : Integer):IGroup;
Var
I : Integer;
Category : IGroup;
Begin
// Make the default result nil
Result := nil;

// Loop thru the CUSTOM CATEGORIES of the ONLY SKYPE CONTROL used in this project
// (which 100% positive IS attached ;) )
for I := 1 to frmMain.Skype.CustomGroups.Count do
Begin
// The Category Variable
Category := frmMain.Skype.CustomGroups.Item[I];
// If the current category ID returned by the loop matches the passed ID
if Category.Id = ID then
begin
// Return the Category as Result (IGroup)
Result := Category;
// Exit the function.
Exit;
end;
End;
End;

当我在 Result := Category; 设置断点时和单步执行,这两行会一遍又一遍地执行!

当我注释掉第一个代码片段中的 sCtgName := GetCategoryByID(CategoryID).DisplayName; 时,没有溢出,消息显示时间应该到了。但是,GetCategoryByID是我编写的一个函数,我也编写了一个类似的函数,它工作得很好(GetCategoryByName),所以我不明白为什么它决定重复

// Return the Category as Result (IGroup)
Result := Category;
// Exit the function.
Exit;

一遍又一遍。

编辑:以下是重现它的方法:https://gist.github.com/813389

编辑:这是我的 CallStack,根据要求: CallStack

编辑2:更多信息: More Info

最佳答案

确保在关闭“优化”、打开“堆栈帧”和“使用调试.dcu”的情况下编译项目,以获得尽可能详细的调用堆栈。然后在此处发布当您遇到堆栈溢出时获得的调用堆栈(如果您无法从中识别问题的性质)。

关于delphi - Delphi 中的堆栈溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4909511/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com