FLTK logo

[branch-1.3] 50e398a - macOS: Fl::add_timeout() must always create a new timer (#248)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[branch-1.3] 50e398a - macOS: Fl::add_timeout() must always create a new timer (#248) "Albrecht Schlosser" Jul 25, 2021  
 
commit 50e398a52c629fe9a572b9f0120bc21c1afecbc6
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Sun Jul 25 14:54:45 2021 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Sun Jul 25 14:54:45 2021 +0200

    macOS: Fl::add_timeout() must always create a new timer (#248)
    
    The old version would reschedule an existing timer if a matching timer
    existed already which was unique to macOS.
    
    The new behavior is consistent on all platforms and allows to create
    multiple timer entries with the same callback and userdata.
    
    Backported from 1.4: 135ba3a7e1e40df3df1949eee800eaf8c8b67416

 src/Fl_cocoa.mm | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git src/Fl_cocoa.mm src/Fl_cocoa.mm
index 606d624..5b2260f 100644
--- src/Fl_cocoa.mm
+++ src/Fl_cocoa.mm
@@ -558,18 +558,7 @@ static void do_timer(CFRunLoopTimerRef timer, void* data)
 
 void Fl::add_timeout(double time, Fl_Timeout_Handler cb, void* data)
 {
-  // check, if this timer slot exists already
-  for (int i = 0; i < mac_timer_used; ++i) {
-    MacTimeout& t = mac_timers[i];
-    // if so, simply change the fire interval
-    if (t.callback == cb  &&  t.data == data) {
-      t.next_timeout = CFAbsoluteTimeGetCurrent() + time;
-      CFRunLoopTimerSetNextFireDate(t.timer, t.next_timeout );
-      t.pending = 1;
-      return;
-    }
-  }
-  // no existing timer to use. Create a new one:
+  // always create a new timer entry
   fl_intptr_t timer_id = -1;
   // find an empty slot in the timer array
   for (int i = 0; i < mac_timer_used; ++i) {
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.