fix(ui): null-guard agent access and refocus input after token insert
AgentMap.Instance() and AgentChatLog.Instance() can return null during zone transitions. Capture pointers into locals and short-circuit the FlagMarkerCount/LinkedItem deref when null so the entries are correctly greyed out without faulting. Add Activate/ActivatePos after each append so the input box regains focus and the caret lands after the token, matching the SymbolPicker and AutoComplete insert paths.
This commit is contained in:
@@ -1130,18 +1130,29 @@ public sealed class ChatLogWindow : Window
|
|||||||
// so the inserted token cannot expand to nothing.
|
// so the inserted token cannot expand to nothing.
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
var flagSet = AgentMap.Instance()->FlagMarkerCount > 0;
|
// Null-check before deref: pointers can be null during zone transitions.
|
||||||
|
var agentMap = AgentMap.Instance();
|
||||||
|
var flagSet = agentMap != null && agentMap->FlagMarkerCount > 0;
|
||||||
using (ImRaii.Disabled(!flagSet))
|
using (ImRaii.Disabled(!flagSet))
|
||||||
{
|
{
|
||||||
if (ImGui.Selectable(HellionStrings.ChatLog_Insert_MapFlag))
|
if (ImGui.Selectable(HellionStrings.ChatLog_Insert_MapFlag))
|
||||||
|
{
|
||||||
Chat += "<flag>";
|
Chat += "<flag>";
|
||||||
|
Activate = true;
|
||||||
|
ActivatePos = Chat.Length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemSet = AgentChatLog.Instance()->LinkedItem.ItemId != 0;
|
var agentChat = AgentChatLog.Instance();
|
||||||
|
var itemSet = agentChat != null && agentChat->LinkedItem.ItemId != 0;
|
||||||
using (ImRaii.Disabled(!itemSet))
|
using (ImRaii.Disabled(!itemSet))
|
||||||
{
|
{
|
||||||
if (ImGui.Selectable(HellionStrings.ChatLog_Insert_ItemLink))
|
if (ImGui.Selectable(HellionStrings.ChatLog_Insert_ItemLink))
|
||||||
|
{
|
||||||
Chat += "<item>";
|
Chat += "<item>";
|
||||||
|
Activate = true;
|
||||||
|
ActivatePos = Chat.Length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user