[Qgis-developer] Rendering Real-Time Data in QGIS

Martin Dobias wonder.sk at gmail.com
Wed Apr 29 05:28:36 EDT 2009


On Sat, Apr 25, 2009 at 11:38 AM, Florian El Ahdab <felahdab at gmail.com> wrote:
> [...]
>
> Here is my problem:
> When I create 1 of those items, everything works fine. With a map loaded, I
> can see the Item moving around every 500ms.
> But when I create 10 of those items (and consequently 10 threads), I can see
> them moving but qgis crashes randomly (between 1 and 10 seconds max).
> I suspect this is because there is no synchronization in the access to the
> Item data when the thread moves the item.
> I have tried to freeze the MapCanvas before updating the position... but it
> doesn't work either.
>
> Wonder:
> If my explanations are clear enough, can you help me?
> Can you detail a little bit further how you would do such a thing for a
> large amount of tracks (let's say 5000...).

Is it really necessary to use threads here? Usually much simpler
approach is to use a timer that updates the items once in a while. And
you don't have to worry about large number of threads and
synchronisation.

> If there is a need for synchronization, how can I synchronize the access to
> the items that I have to add to the MapCanvas (which doesn't synchronize
> before using the data apparently.)

Yes, you have to synchronize the threads, otherwise you'll have
concurrency problems. Everything shared among threads must be accessed
safely, i.e. using mutexes, semaphores, r/w locks etc...

Martin


More information about the Qgis-developer mailing list