mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Fix crash when the chat window gets a message before the GUI finished initializing.
fixes #649
This commit is contained in:
parent
b50ffa5ea7
commit
57d32338fb
@ -38,6 +38,24 @@ var fadeOutEnd: u32 = 0;
|
||||
pub var input: *TextInput = undefined;
|
||||
var hideInput: bool = true;
|
||||
|
||||
pub fn init() void {
|
||||
history = .init(main.globalAllocator);
|
||||
expirationTime = .init(main.globalAllocator);
|
||||
messageQueue = .init(main.globalAllocator, 16);
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
for(history.items) |label| {
|
||||
label.deinit();
|
||||
}
|
||||
history.deinit();
|
||||
while(messageQueue.dequeue()) |msg| {
|
||||
main.globalAllocator.free(msg);
|
||||
}
|
||||
messageQueue.deinit();
|
||||
expirationTime.deinit();
|
||||
}
|
||||
|
||||
fn refresh() void {
|
||||
if(window.rootComponent) |old| {
|
||||
old.verticalList.children.clearRetainingCapacity();
|
||||
@ -69,25 +87,20 @@ fn refresh() void {
|
||||
}
|
||||
|
||||
pub fn onOpen() void {
|
||||
history = .init(main.globalAllocator);
|
||||
expirationTime = .init(main.globalAllocator);
|
||||
messageQueue = .init(main.globalAllocator, 16);
|
||||
historyStart = 0;
|
||||
fadeOutEnd = 0;
|
||||
input = TextInput.init(.{0, 0}, 256, 32, "", .{.callback = &sendMessage});
|
||||
refresh();
|
||||
}
|
||||
|
||||
pub fn onClose() void {
|
||||
for(history.items) |label| {
|
||||
while(history.popOrNull()) |label| {
|
||||
label.deinit();
|
||||
}
|
||||
history.deinit();
|
||||
while(messageQueue.dequeue()) |msg| {
|
||||
main.globalAllocator.free(msg);
|
||||
}
|
||||
messageQueue.deinit();
|
||||
expirationTime.deinit();
|
||||
expirationTime.clearRetainingCapacity();
|
||||
historyStart = 0;
|
||||
fadeOutEnd = 0;
|
||||
input.deinit();
|
||||
window.rootComponent.?.verticalList.children.clearRetainingCapacity();
|
||||
window.rootComponent.?.deinit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user