Fix close-popup ImGui stack imbalance, stale region hover, shared resize chord state, window properties leak

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 18:58:30 -04:00
1 parent c04a685f18
commit 146e5d4ff1
5 files changed
+13 -19

No files matched your search

+7 -15
View File
@@ -300,18 +300,11 @@ namespace anm2ed::imgui
shortcut(manager.chords[SHORTCUT_CONFIRM]); shortcut(manager.chords[SHORTCUT_CONFIRM]);
if (ImGui::Button(localize.get(BASIC_YES), widgetSize)) if (ImGui::Button(localize.get(BASIC_YES), widgetSize))
{ {
bool isSaved = true; // A failed save keeps the document (and its popup) open.
if (isDocumentDirty) isSaved = taskbar.save_manual(manager, settings, closeDocumentIndex); auto isSaved = !isDocumentDirty || taskbar.save_manual(manager, settings, closeDocumentIndex);
if (isSaved)
if (!isSaved)
{ {
ImGui::EndPopup(); if (isSpritesheetDirty)
return;
}
if (isSpritesheetDirty)
{
{
for (auto& spritesheet : closeDocument.model.content.spritesheets) for (auto& spritesheet : closeDocument.model.content.spritesheets)
{ {
auto id = spritesheet.id; auto id = spritesheet.id;
@@ -332,11 +325,10 @@ namespace anm2ed::imgui
} }
} }
} }
} auto index = closeDocumentIndex;
manager.command_push({.runManager = [index](Manager& manager) { manager.close(index); }});
close();
} }
auto index = closeDocumentIndex;
manager.command_push({.runManager = [index](Manager& manager) { manager.close(index); }});
close();
} }
ImGui::SameLine(); ImGui::SameLine();
+1 -1
View File
@@ -244,6 +244,7 @@ namespace anm2ed::imgui
drawList->AddRectFilled(min, max, ImGui::GetColorU32(to_imvec4(vec4(backgroundColor, 1.0f)))); drawList->AddRectFilled(min, max, ImGui::GetColorU32(to_imvec4(vec4(backgroundColor, 1.0f))));
image_premultiplied_draw(this->texture, to_imvec2(size)); image_premultiplied_draw(this->texture, to_imvec2(size));
hoveredRegionId = -1;
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
{ {
auto input = canvas_input_get(manager, isFocused); auto input = canvas_input_get(manager, isFocused);
@@ -301,7 +302,6 @@ namespace anm2ed::imgui
if (tool == tool::DRAW && input.isRightDown) useTool = tool::ERASE; if (tool == tool::DRAW && input.isRightDown) useTool = tool::ERASE;
if (tool == tool::ERASE && input.isRightDown) useTool = tool::DRAW; if (tool == tool::ERASE && input.isRightDown) useTool = tool::DRAW;
hoveredRegionId = -1;
if (useTool == tool::PAN && spritesheet && texture && texture->is_valid() && isMouseOverCanvas) if (useTool == tool::PAN && spritesheet && texture && texture->is_valid() && isMouseOverCanvas)
for (auto& region : spritesheet->regions) for (auto& region : spritesheet->regions)
{ {
+2 -3
View File
@@ -201,7 +201,6 @@ namespace anm2ed::imgui
}; };
constexpr FrameResize FRAME_RESIZES[] = {{SHORTCUT_SHORTEN_FRAME, EDIT_SHORTEN_FRAME, -1}, constexpr FrameResize FRAME_RESIZES[] = {{SHORTCUT_SHORTEN_FRAME, EDIT_SHORTEN_FRAME, -1},
{SHORTCUT_EXTEND_FRAME, EDIT_EXTEND_FRAME, 1}}; {SHORTCUT_EXTEND_FRAME, EDIT_EXTEND_FRAME, 1}};
static bool isResizeChordHeld[std::size(FRAME_RESIZES)]{};
for (int i = 0; i < (int)std::size(FRAME_RESIZES); ++i) for (int i = 0; i < (int)std::size(FRAME_RESIZES); ++i)
{ {
auto resize = FRAME_RESIZES[i]; auto resize = FRAME_RESIZES[i];
@@ -211,7 +210,7 @@ namespace anm2ed::imgui
std::erase_if(selectedFrames, is_trigger_reference); std::erase_if(selectedFrames, is_trigger_reference);
if (!selectedFrames.empty()) if (!selectedFrames.empty())
{ {
if (!isResizeChordHeld[i]) edit_begin_push(resize.edit); if (resizeChordTabIds[i] != document.tabId) edit_begin_push(resize.edit);
command_push( command_push(
[=, this](Manager&, Document& document) [=, this](Manager&, Document& document)
{ {
@@ -222,7 +221,7 @@ namespace anm2ed::imgui
document.change(); document.change();
}); });
} }
isResizeChordHeld[i] = isPressed; resizeChordTabIds[i] = isPressed ? document.tabId : 0;
} }
auto isPreviousFrame = shortcut(manager.chords[SHORTCUT_PREVIOUS_FRAME], shortcut::GLOBAL); auto isPreviousFrame = shortcut(manager.chords[SHORTCUT_PREVIOUS_FRAME], shortcut::GLOBAL);
+2
View File
@@ -146,6 +146,8 @@ namespace anm2ed::imgui
float draggedFrameWidth{}; float draggedFrameWidth{};
bool isDraggedFrameSnapshot{}; bool isDraggedFrameSnapshot{};
FrameMoveDrag frameMoveDrag{}; FrameMoveDrag frameMoveDrag{};
// The tab a held shorten/extend chord is editing (0 when released), so a held chord starts one undo entry per document.
std::uint64_t resizeChordTabIds[2]{};
std::optional<Reference> frameSelectionAnchor{}; std::optional<Reference> frameSelectionAnchor{};
int animationLengthEditIndex{-1}; int animationLengthEditIndex{-1};
std::vector<TimelineRow> rowDragReferences{}; std::vector<TimelineRow> rowDragReferences{};
+1
View File
@@ -189,6 +189,7 @@ namespace anm2ed
SDL_SetBooleanProperty(windowProperties, SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, true); SDL_SetBooleanProperty(windowProperties, SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, true);
window = SDL_CreateWindowWithProperties(windowProperties); window = SDL_CreateWindowWithProperties(windowProperties);
SDL_DestroyProperties(windowProperties);
if (!window) if (!window)
{ {