DIANIUX INNOVA SL
Main Loop Watch Dog Timer for Qt & QML
When the main loop freezes, this component can kill or restart the current application, just by adding two lines of code.
You can also use the application restart function, for a complete restart of your application.
See in action (video)
How it works:
- A timer activated by the main loop triggers watch function every 250 ms.
- Another timer, triggered by a QThread, checks the status of whatchdog status every 250ms.
- This function should not affect the performance of the application.
- In case the app is suspended, the watchdog timer function restarts.
- When the watchdog timer is activated, the application aborts its execution or restarts (configurable)
create object in main function, just before main loop exec:
mainLoopWdt wdt(true,2000, 5000,0, &app); wdt.startWdt(); return app.exec();
- Ubuntu 20.04
- MacOS Big Sur
- Windows 10
Tested main loop locks:
- QML js infinite loop
- C++ infinite loop
- C++ mutex double lock
- Windows : QProcess::startDetached + std::exit (application arguments are kept)
- Linux & macOs : exec (application arguments are kept)
Delayed restart estrategy
- Windows : cmd.exe
- Linux & MacOs : bash
Qt LPGL App Template (create a 100 % compliant desktop/mobile Qt application using LGPLv3 libraries): https://marketplace.qt.io/products/qt-lgpl-app-template
Miguel Angel Pons, Dianiux Innova SL https://www.dianiuxinnova.com email@example.com
I recommend this product
Very useful and didactic.