Skip to content

Fix threading-related crashes from 'clear clipboard' timer

David Scaife requested to merge d2/PasswordSafe:fix-clipboard-crashes into master

The "clear clipboard" timer runs clear_clipboard() on its own thread, which makes a call to Gtk.Clipboard and this appears to cause thread safety issues. More often than not, it works fine - but occasionally causes the app to crash or freeze. The easiest way to reproduce this is to set the clear clipboard time to one second and click one of the Copy buttons until it crashes/freezes (with > 1s delay so it actually fires instead of resetting the timer). For me this usually happens within 10-15 clicks.

This patch makes the timer fire via GLib.idle_add (consistent with the other usages of threading.Timer) to resolve the threading issue.

This should fix the crashes reported in #68 (closed).

It might also be related to #142 (closed), though this is only based on having seen the same threading errors when this occurs - there's no mention of copying passwords etc in that issue though so I can't be certain.

Edited by David Scaife

Merge request reports