Hello Stephen,
thank you for providing us the example project via e-mail. For the sake of completeness I have uploaded this project also to this thread. It can be found here: example project. To upload files to a thread you can use the following button:
The still running timers can be explained by a peculiarity of Garbage Collection when prototyping an application. In target system, the Garbage Collection runs after each screen update. That means all unused object sare released almost immediately. During prototyping, we trigger the Garbage Collection seldom, approx. every 0.25 .. 10 sec. depending on the activity in the application. An object not used anymore can therefore continue living for few seconds. A timer existing in such object can thus continue fireing. Please see also the section Force Garbage Collection.
In your concrete example, the timers are configure to run periodically (the property Period is configured). One possible approach to correct the behavior could thus be the configuration of the timers as 'single shot' timers and not 'periodic' timer. For this purpose you set the property Period to the value 0 and set the property Begin to the value 5000. Doing this you specify only the initial delay and no period. The timers will fire only once. See also Specify the timer interval and the initial delay.
Furthermore, in case of any random events like user or system events but also periodical timer events, it is recommendable to test whether the component in question is still acting as dialog. Due to race conditions and delays during transitions between dialogs, it is not excluded that a component receives an event although it does not act anymore as dialog (it has been dismissed). Please see the section Identify the active Dialogs and avoid race conditions explaining such possible error situation. This chapter explains also how to handle such race conditions.
In your case one possible approach could be following if-condition at the beginning of the slot methods triggered by the timers. The condition tests whether the timer does belong to the actually active dialog. If not, the event is ignored. For example, the slot method slotSwitch2Panel1 is expected to be called from Panel3. Therefore test whether Panel 3 is still the active dialog:
I hope it helps you further.
Best regards
Paul