Re: [fltk.coredev] Fl_Choice initiates infinite loop

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.coredev  ]
Previous Message ]New Message | Reply ]Next Message ]

Re: Fl_Choice initiates infinite loop Rob McDonald 16:36 Jun 16 top right image
On Thursday, June 16, 2022 at 3:00:55 PM UTC-7 Albrecht Schlosser wrote:
OK, taking your earlier reply into account, I changed the demo program to just (u)sleep() inside the callback and can trigger the issue in a reprocucible way. This may be different than your real case but it shows the issue. I'm attaching the modified demo program counter.cxx. I know what is causing the issue, i.e. what happens once it gets triggered, but I don't know yet how to fix it. I'll look deeper into it tomorrow.

What I found out so far:

(1) My first assumption was that the Fl_Counter widget misses the FL_RELEASE event and this can easily be demonstrated by opening a modal window inside the callback. This is test case 1 [change '#if (0)' to '#if (1)' ...] and can be fixed by my previously posted patch.

(2) My new test program works by sleeping at least 100 ms inside the callback. It seems necessary to hold the Fl_Counter button pressed at least this time so the internal repeat timer gets called before the FL_RELEASE event is delivered. This restarts the repeat timer and triggers the (in this case potentially infinite) loop. This happens on both Linux and macOS.

(3) Testing on the Mac I could confirm that commit cf4a832e6 (the one before the timeout changes) does not have this issue.

(4) The problem is obviously in the code of Fl_Counter. It's not a direct regression introduced by the timeout changes but it is revealed by those.

(5) Another attempt to fix all known issues is my a new patch Fl_Counter_v2.patch (attached). It's likely not the final solution (fixing symptoms only) but it's a start.

Rob, can you please:

(a) test and (hopefully) confirm that this patch fixes your issue too?

I tried this patch (thanks for the prompt work).  It helps, but isn't a fix...

When I click the counter, it now increments two values (usually) and then stops.  It doesn't skip from 2 to 4, I see the intermediate 3.  It goes 2, 3, 4 and then stops -- for a single click.

Occasionally (once out of 20+ attempts) it will only increment by one (my sequence switched from even to odd).

(b) open a GitHub Issue describing the issue in a short form so the issue won't be forgotten. You can refer to this discussion for further information [1]. I will investigate further and (hopefully, again) find a proper solution later.

Thanks for finding the issue and your support in testing.

[1] Link:

I'll create the issue.  Thanks for your prompt attention to this.



You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Direct Link to Message ]
bottom left image   bottom right image
Previous Message ]New Message | Reply ]Next Message ]

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