SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

Timer infinite pop-up. #902

Open LItterBoy-GB opened 1 year ago

LItterBoy-GB commented 1 year ago
  1. SketchUp/LayOut Version: Sketchup 2023
  2. OS Platform: windows 11 x64 Although the repeated parameter gave false, the code block of the timer has been continuously executed due to the bullet box getting stuck.

bug code

    UI.start_timer(0.001, false) {
      UI.messagebox 'asdf'
    }

Current solution

    id = UI.start_timer(0.001, false) {
      UI.stop_timer id
      UI.messagebox 'asdf'
    }
DanRathbun commented 1 year ago

Did you read the documentation for the UI::start_timer method ?

It clearly states:

Note that there is a bug that if you open a modal window in a non-repeating timer the timer will repeat until the window is closed.

It has been like this since forever.

The solution is not to open modal windows (message boxes, inputboxes, the Preferences panel, the Welcome dialog, modal web dialogs, etc.,) from a non-repeating timer block. Or a repeating timer block.

I cannot think of any good reason to do so.

thomthom commented 1 year ago

For deferred execution of some code that might block the thread, you can use this pattern as a workaround:

https://github.com/thomthom/extension-sources/blob/f091659390beb1dfb5864868a84955f706beb9bd/src/tt_extension_sources/utils/execution.rb#L7-L14

LItterBoy-GB commented 1 year ago

Sorry, I didn't carefully read the method statement

sketchup[bot] commented 1 year ago

Logged as: SKEXT-3720

DanRathbun commented 1 year ago

Cross reference with: SKEXT-3775

Fredosixx commented 6 months ago

This old problem would deserve to be fixed....