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
commit
7ac9de7d83
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue