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.
pull/9010/head
Mitchell Hashimoto 2025-10-03 06:53:29 -07:00 committed by GitHub
commit 7ac9de7d83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 0 deletions

View File

@ -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,