Skip to content

AnimatedLabel Thread hangs after WaitingDialog closed #595

@Kapral67

Description

@Kapral67

It is possible for the AnimatedLabel::createSpinningLine component's thread to hang after the WaitingDialog that owns it is closed.

A quick fix could be to explicitly call AnimatedLabel::stopAnimation in WaitingDIalog::close (the spinning line would need to become an instance variable of the WaitingDialog class).

Although, I think a better solution would be some fix within the AnimatedLabel class itself.

Proof of Concept:

final DefaultTerminalFactory terminalFactory = new DefaultTerminalFactory();
try (final Screen screen = terminalFactory.createScreen()) {
    screen.startScreen();

    // POC
    final WindowBasedTextGUI textGUI = new MultiWindowTextGUI(screen);
    final WaitingDialog waitingDialog = WaitingDialog.createDialog("TITLE", "TEXT");
    waitingDialog.showDialog(textGUI, false);
    CompletableFuture.runAsync(() -> {
                         try {
                             Thread.sleep(5000);
                         } catch (final InterruptedException e) {
                             Thread.currentThread().interrupt();
                             throw new RuntimeException(e);
                         } finally {
                             waitingDialog.close();
                         }
                     }, Executors.newSingleThreadExecutor())
                     .exceptionally(e -> {
                         throw new RuntimeException(e);
                     });
    waitingDialog.waitUntilClosed();
    System.out.println("WAIT DIALOG CLOSED");

} catch (final IOException e) {
    throw new RuntimeException(e);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions