mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-20 02:36:22 +03:00
apprt/gtk: copy the app id because we need to own it according to docs
This commit is contained in:
@ -37,6 +37,7 @@ pub const App = struct {
|
|||||||
|
|
||||||
core_app: *CoreApp,
|
core_app: *CoreApp,
|
||||||
|
|
||||||
|
app_id: [:0]const u8,
|
||||||
app: *c.GtkApplication,
|
app: *c.GtkApplication,
|
||||||
ctx: *c.GMainContext,
|
ctx: *c.GMainContext,
|
||||||
|
|
||||||
@ -50,9 +51,13 @@ pub const App = struct {
|
|||||||
// rid of this dep.
|
// rid of this dep.
|
||||||
if (!glfw.init(.{})) return error.GlfwInitFailed;
|
if (!glfw.init(.{})) return error.GlfwInitFailed;
|
||||||
|
|
||||||
|
// We have to copy our app ID because GTK says we own it.
|
||||||
|
var app_id = try core_app.alloc.dupeZ(u8, opts.id);
|
||||||
|
errdefer core_app.alloc.free(app_id);
|
||||||
|
|
||||||
// Create our GTK Application which encapsulates our process.
|
// Create our GTK Application which encapsulates our process.
|
||||||
const app = @ptrCast(?*c.GtkApplication, c.gtk_application_new(
|
const app = @ptrCast(?*c.GtkApplication, c.gtk_application_new(
|
||||||
opts.id.ptr,
|
app_id.ptr,
|
||||||
|
|
||||||
// GTK >= 2.74
|
// GTK >= 2.74
|
||||||
if (@hasDecl(c, "G_APPLICATION_DEFAULT_FLAGS"))
|
if (@hasDecl(c, "G_APPLICATION_DEFAULT_FLAGS"))
|
||||||
@ -104,6 +109,7 @@ pub const App = struct {
|
|||||||
|
|
||||||
return .{
|
return .{
|
||||||
.core_app = core_app,
|
.core_app = core_app,
|
||||||
|
.app_id = app_id,
|
||||||
.app = app,
|
.app = app,
|
||||||
.ctx = ctx,
|
.ctx = ctx,
|
||||||
.cursor_default = cursor_default,
|
.cursor_default = cursor_default,
|
||||||
@ -122,6 +128,8 @@ pub const App = struct {
|
|||||||
c.g_object_unref(self.cursor_ibeam);
|
c.g_object_unref(self.cursor_ibeam);
|
||||||
c.g_object_unref(self.cursor_default);
|
c.g_object_unref(self.cursor_default);
|
||||||
|
|
||||||
|
self.core_app.alloc.free(self.app_id);
|
||||||
|
|
||||||
glfw.terminate();
|
glfw.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user