mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-09 03:16:33 +00:00
gtk: fix duplicate signal handlers (#9001)
Signal handlers are connected to surface objects in two spots - when a tab is added to a page and when the split tree changes. This resulted in duplicate signal handlers being added for each surface. This was most noticeable when copying the selection to the clipboard - you would see two "Copied to clipboard" toasts. Ensure that there is only one signal handler by removing any old ones before adding the new ones.
This commit is contained in:
@@ -697,6 +697,19 @@ pub const Window = extern struct {
|
||||
var it = tree.iterator();
|
||||
while (it.next()) |entry| {
|
||||
const surface = entry.view;
|
||||
// Before adding any new signal handlers, disconnect any that we may
|
||||
// have added before. Otherwise we may get multiple handlers for the
|
||||
// same signal.
|
||||
_ = gobject.signalHandlersDisconnectMatched(
|
||||
surface.as(gobject.Object),
|
||||
.{ .data = true },
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
self,
|
||||
);
|
||||
|
||||
_ = Surface.signals.@"present-request".connect(
|
||||
surface,
|
||||
*Self,
|
||||
|
Reference in New Issue
Block a user