Quantcast
Channel: Installation and Deployment
Viewing all articles
Browse latest Browse all 22112

Prevent concurrent access from different threads?

$
0
0
Hi, I was wondering whether I could have some views on the following. My application uses a thread to run a simulation and generate simulation data. A thread is used so that my application’s GUI can remain responsive. Now, while a simulation is being run, my application’s main thread makes successive calls to QTimer::singleShot() to fetch any new simulation data that has been generated, as well as to plot whatever the user wants to visualise. The user can decide on what to visualise by creating/removing traces, this through my application’s GUI. If I pre-select some traces and run a simulation, then everything works as expected. However, if, during a simulation, I remove a trace, then my application may crash. This is because the fetching function I call from QTimer::singleShot() goes through all the different traces and update them. Now, if a trace has been removed during a simulation and, more importantly, in the middle of my fetching function, then my fetching function might try to use a trace which doesn’t exist anymore, hence the crash. So, what would you do to avoid this problem? I originally thought I could solve this problem by using a mutex, but that failed and I believe this might be because of my fetching function being called through QTimer::singleShot() and therefore running in its own thread? Anyway, any idea/help on the above would be much appreciated… Cheers, Alan.

Viewing all articles
Browse latest Browse all 22112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>