Skip to content

Ensure ticker cleanup in watch functions #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clipboard_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func watch(ctx context.Context, t Format) <-chan []byte {
ti := time.NewTicker(time.Second)
last := Read(t)
go func() {
defer ti.Stop()
for {
select {
case <-ctx.Done():
Expand Down
1 change: 1 addition & 0 deletions clipboard_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func watch(ctx context.Context, t Format) <-chan []byte {
ti := time.NewTicker(time.Second)
lastCount := C.long(C.clipboard_change_count())
go func() {
defer ti.Stop()
for {
select {
case <-ctx.Done():
Expand Down
1 change: 1 addition & 0 deletions clipboard_ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func watch(ctx context.Context, t Format) <-chan []byte {
ti := time.NewTicker(time.Second)
last := Read(t)
go func() {
defer ti.Stop()
for {
select {
case <-ctx.Done():
Expand Down
1 change: 1 addition & 0 deletions clipboard_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func watch(ctx context.Context, t Format) <-chan []byte {
ti := time.NewTicker(time.Second)
last := Read(t)
go func() {
defer ti.Stop()
for {
select {
case <-ctx.Done():
Expand Down
1 change: 1 addition & 0 deletions clipboard_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ func watch(ctx context.Context, t Format) <-chan []byte {
go func() {
// not sure if we are too slow or the user too fast :)
ti := time.NewTicker(time.Second)
defer ti.Stop()
cnt, _, _ := getClipboardSequenceNumber.Call()
ready <- struct{}{}
for {
Expand Down
Loading