-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: don't copy App and apprt.App #5509
base: main
Are you sure you want to change the base?
Conversation
I'm not against it but again... why now? Is this change for change sake or is there a motivating thing you're working on? |
Yeah, as I was working on some of the changes needed to get the GTK apprt structs to use DerivedConfigs instead of using the "raw" config this made some things easier. Plus it's more consistent with how the other GTK structs are handled (Window, Tab, Surface). |
Besides avoiding copying, this allows consumers to choose to allocate these structs on the stack or to allocate on the heap. It also gives the apprt.App a stable pointer sooner in the process.
9edf0eb
to
01d4fd4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a little thing. Also i agree having app be a stable pointer would have been useful for me at some point(though it's also not that bad to have to allocate a couple objects for callbacks) but is there a reason that CoreApp needs a stable pointer?
2ded43e
to
81f10bc
Compare
I don't have a particular use case or need at this time but made the change now for consistency's sake. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the churn on this part
try core_app.init(global.alloc); | ||
errdefer { | ||
core_app.deinit(); | ||
global.alloc.destroy(core_app); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of the error defer has to be above the init so if the init fails then it will be destroyed. The ordering will still be correct as the second errdefer runs first see this as an example
const std = @import("std");
fn fail() !void {
return error.Fail;
}
pub fn main() !void {
errdefer std.debug.print("prints second\n", .{});
errdefer std.debug.print("prints first\n", .{});
try fail();
}
Besides avoiding copying, this allows consumers to choose to allocate these structs on the stack or to allocate on the heap. It also gives the apprt.App a stable pointer sooner in the process.