Skip to content

Fix crash when deleting script runner#1958

Merged
mcallegari merged 1 commit intomcallegari:masterfrom
daves003:fix-crash-on-scripts-shutdown
Feb 28, 2026
Merged

Fix crash when deleting script runner#1958
mcallegari merged 1 commit intomcallegari:masterfrom
daves003:fix-crash-on-scripts-shutdown

Conversation

@daves003
Copy link
Copy Markdown

Description

Avoid deleting the script runner immediately in the slot connected to finished() .
QThread is not quite done executing, so this crashed. Using deleteLater() is explicitly mentioned by Qt to avoid this problem and only delete the thread when it's fully done.

Checklist

  • I have read and followed the QLC+ Coding Guidelines.
  • My code adheres to the project's coding style, including:
    • Placing opening braces { on a new line for functions and class definitions.
    • Consistent use of spaces and indentation.
  • I have tested my changes on the following platforms:
    • Linux
    • Windows
    • macOS

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 33.994%. remained the same
when pulling f5854a1 on daves003:fix-crash-on-scripts-shutdown
into 77c7ea7 on mcallegari:master.

@mcallegari
Copy link
Copy Markdown
Owner

Thanks
@jpue since you worked on #1933, is this somehow related or conflicting? Or perhaps you already observed/solved this?

@jpue
Copy link
Copy Markdown
Contributor

jpue commented Feb 16, 2026

No, I have never encountered any issues related to such crashes while working on the Script function in the past months. Therefore, I did not fix anything.

@daves003 Can you provide a concrete example of this issue or Steps To Reproduce? Or did you just notice it during code review – be it manual, using a linter, or an AI tool?

Furthermore, #1933 just adapts to Script code so that the underlying superclass Function is correctly terminated and deleted after everything Script-related has already been shut down.

I did a quick test on a branch where both this commit and the one from #1933 had been applied and this seems to work fine as well.

@daves003
Copy link
Copy Markdown
Author

I just came across the crash when building some really short looping scripts. So instead of the AppImage I built it locally in debug mode and that showed a this = 0x0 in the script runner.

Repro that crashes consistently for me:

  • New project using QML UI
  • Create a script with just this line: Engine.waitTime(20);
  • Create a chaser with the script as the only step
  • Set hold time to 20ms
  • Make sure the run order is set to loop
  • Preview the chaser
  • Should crash almost immediately

#1933 also looks not directly related to me. I've quickly tested a version with both of the changes and it seems to be running fine.

@jpue
Copy link
Copy Markdown
Contributor

jpue commented Feb 17, 2026

Thank you for the information.

Using the steps, I was able to reproduce the behaviour described above.

However, your fix does not solve this issue for me – QLC+ still crashes in various different Script-related place (might take a couple of seconds), seemingly at random, whereas previously, it was very localised to destructor of the ScriptRunner class, according to some quick debugging.

I was unable to find the root cause in the time available.

@daves003
Copy link
Copy Markdown
Author

Interesting, it looked stable for me so far. I'll keep using this branch and see if I can catch crashes in other places.

@mcallegari mcallegari merged commit f6786d5 into mcallegari:master Feb 28, 2026
9 checks passed
@mcallegari
Copy link
Copy Markdown
Owner

Merged, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants