Comment 23 for bug 728197

Revision history for this message
Uwe Klotz (uklotzde-deactivatedaccount) wrote :

My proposal for an in-process solution:
- Use QSaveFile (Qt 5) whenever writing to files
   - Not essential, but a nice safety feature
- Implement caching of TIOs by their absolute file path to ensure that there is only a single TIO for each file at any time
   - TIOs are only created by the cache
   - The file path of a TIO must only be modified through the cache
   - The cache is responsible for deleting the TIO after all references to it have been dropped
- SoundSourceProxy: Always construct with a TIO and store both (smart) pointers in a TrackAudioSource wrapper object
   - Delete constructor SoundSourceProxy(QString qFilename, ...)
   - SoundSourceProxy::openAudioSource() returns an AudioSourcePointer that actually points to a TrackAudioSource wrapper object
   - TrackAudioSource
      - Implements the AudioSource API by delegating to the actual AudioSource
      -1st member: TrackPointer
      - 2nd member: AudioSourcePointer
      -> AudioSource is closed/destroyed before TIO when TrackAudioSource is destroyed

Consequences: If a TIO is finally destroyed by the TIO cache there will be no more open AudioSources reading from the file. The file can now safely be modified before the TIO object is actually deleted.