mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 14:55:25 +00:00
fix startup procedure for async WinMain
This commit is contained in:
parent
80ac022c46
commit
1adb6440db
@ -511,9 +511,9 @@ inline fn initEventLoopAndCallWinMain() std.os.windows.INT {
|
||||
};
|
||||
defer loop.deinit();
|
||||
|
||||
var result: u8 = undefined;
|
||||
var frame: @Frame(callMainAsync) = undefined;
|
||||
_ = @asyncCall(&frame, &result, callMainAsync, .{loop});
|
||||
var result: std.os.windows.INT = undefined;
|
||||
var frame: @Frame(callWinMainAsync) = undefined;
|
||||
_ = @asyncCall(&frame, &result, callWinMainAsync, .{loop});
|
||||
loop.run();
|
||||
return result;
|
||||
}
|
||||
@ -532,6 +532,14 @@ fn callMainAsync(loop: *std.event.Loop) callconv(.Async) u8 {
|
||||
return callMain();
|
||||
}
|
||||
|
||||
fn callWinMainAsync(loop: *std.event.Loop) callconv(.Async) std.os.windows.INT {
|
||||
// This prevents the event loop from terminating at least until main() has returned.
|
||||
// TODO This shouldn't be needed here; it should be in the event loop code.
|
||||
loop.beginOneEvent();
|
||||
defer loop.finishOneEvent();
|
||||
return call_wWinMain();
|
||||
}
|
||||
|
||||
// This is not marked inline because it is called with @asyncCall when
|
||||
// there is an event loop.
|
||||
pub fn callMain() u8 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user