Skip to content

Commit

Permalink
Unlock the gui command queue mutex while calling window.open/close fu…
Browse files Browse the repository at this point in the history
…nctions

This allows opening a window from inside the close function.

closes #736
  • Loading branch information
IntegratedQuantum committed Oct 10, 2024
1 parent cf79177 commit 7901c72
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/gui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const GuiCommandQueue = struct { // MARK: GuiCommandQueue
fn executeCommands() void {
mutex.lock();
defer mutex.unlock();
for(commands.items) |command| {
while(commands.popOrNull()) |command| {
switch(command.action) {
.open => {
executeOpenWindowCommand(command.window);
Expand All @@ -80,7 +80,6 @@ const GuiCommandQueue = struct { // MARK: GuiCommandQueue
}
}
}
commands.clearRetainingCapacity();
}

fn executeOpenWindowCommand(window: *GuiWindow) void {
Expand All @@ -95,7 +94,9 @@ const GuiCommandQueue = struct { // MARK: GuiCommandQueue
}
}
openWindows.append(window);
mutex.unlock();
window.onOpenFn();
mutex.lock();
selectedWindow = null;
}

Expand All @@ -111,7 +112,9 @@ const GuiCommandQueue = struct { // MARK: GuiCommandQueue
break;
}
}
mutex.unlock();
window.onCloseFn();
mutex.lock();
}
};

Expand Down

0 comments on commit 7901c72

Please sign in to comment.