Two distinct problems/questions, but since they're in the same application, I decided to put them to the same topic for the sake of simplicity.
My sound problem: in my application(a free 2D game), I use QSound to play short (2-5 seconds) sounds. Since I need real-time instant playing (e.g. weapon shot) without any delay, I instantiate QSound in advance, stored in member variables. Later, when it's needed, I just call play() so it plays it immediately. This is how sound playback works in my application. Problem: it happens sometimes (actually quite often) that when I've regularly exited the application on my Nokia E52, menu navigation sounds are muted. So when I navigate or press the soft keys anywhere, everything is silent (note that the device is not put to Silent mode or anything similar). Other system sounds, however, seem to play fine (e.g. when a sis installation is finished, or when an error is noticed for invalid sisx signature). Only device reboot solves this problem. Note that I don't call QSound::stop() anywhere.
My QMovie question:
There is a specified list of gif animations, e.g. a1.gif, a2.gif, a3.gif, ... an.gif. I use QMovie to play them, and I have multiple objects that need these animations independently. For example, at a particular moment, object1 needs a2.gif, object2 needs a6.gif and object3 needs a1.gif to be played. Generally, each object might need any of a1.gif, a2.gif, ... to be played, at any time, and possibly with different timing. Consequently, I can't instantiate a single QMovie for each gif animation, because QMovie is stateful (e.g. the current frame is stored) and its current playback state might be different for each client object. For instance, both obj1 and obj2 might be playing a2.gif, but in a different phase, so I can't make just one QMovie for a2.gif that will be shared by all objects. On the other hand, e.g. if I instantiate 25 QMovie objects for a1.gif (because 25 objects need it), it looks like a waste of resources. How big overhead does this mean? I know QMovie internally opens and reads an IO device i.e. QFile. What happens if 25 QMovie objects read from the same file e.g. a1.gif? If I disable frame caching, is it efficient enough, or should I make an own class to use instead of QMovie? In other words, is QMovie playback memory intensive, and even if not, is QMovie a lightweight class with little overhead?
Re: QMovie and QSound question
Unfortunately, I don't understand how the fact you mention about QSound is relevant to my problem. I've never used resources for it, I use wav files installed in the application folder. And it works fine, the sounds are played perfectly in my application. As I've written, my problem is that after I exit my application, device (i.e. mobile phone) sounds on my E52 does not seem to play, at least when navigating in the menus (such as Control Panel, or anywhere else).
Regarding QMovie, based on what you've written, it seems that there is no way to share it (without making an own class to replace QMovie). Consequently, my current solution probably loads the same gif file multiple times when I instantiate QMovie more times with the same gif for different client objects (in other words, the QFile uses shared read access in it). (My current solution works fine, so the gif is obviously shared, just on file level, not on memory level then.) In order to save memory, I suppose it's a good idea to make a custom class, which acts as QMovie in most respects, but allows sharing the resource, if possible. The gif in the memory is stateless after all, just the playback activity (e.g. the current frame i.e. the position of the movie) is stateful.