]> granicus.if.org Git - taglib/commitdiff
Do not delete the IOStream object in TagLib::File
authorLukáš Lalinský <lalinsky@gmail.com>
Thu, 6 Sep 2012 17:43:52 +0000 (19:43 +0200)
committerLukáš Lalinský <lalinsky@gmail.com>
Thu, 6 Sep 2012 17:43:52 +0000 (19:43 +0200)
20 files changed:
taglib/ape/apefile.h
taglib/asf/asffile.h
taglib/flac/flacfile.h
taglib/it/itfile.h
taglib/mod/modfile.h
taglib/mp4/mp4file.h
taglib/mpc/mpcfile.h
taglib/mpeg/mpegfile.h
taglib/ogg/flac/oggflacfile.h
taglib/ogg/oggfile.h
taglib/ogg/speex/speexfile.h
taglib/ogg/vorbis/vorbisfile.h
taglib/riff/aiff/aifffile.h
taglib/riff/wav/wavfile.h
taglib/s3m/s3mfile.h
taglib/toolkit/tfile.cpp
taglib/toolkit/tfile.h
taglib/trueaudio/trueaudiofile.h
taglib/wavpack/wavpackfile.h
taglib/xm/xmfile.h

index 0bdbd422c11cf9cb8ad08498db35605188947a9f..8b187f6a63c483c10a3bc3e6edc30a510eecfb78 100644 (file)
@@ -95,6 +95,9 @@ namespace TagLib {
        * Contructs an WavPack file from \a file.  If \a readProperties is true the
        * file's audio properties will also be read using \a propertiesStyle.  If
        * false, \a propertiesStyle is ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true,
            Properties::ReadStyle propertiesStyle = Properties::Average);
index f0acd728a96f460384e0151015752370ae06a844..3a7eef565eddcd84f05fdc5b7303a7f04c167d26 100644 (file)
@@ -54,6 +54,9 @@ namespace TagLib {
        *
        * \note In the current implementation, both \a readProperties and
        * \a propertiesStyle are ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(FileName file, bool readProperties = true, Properties::ReadStyle propertiesStyle = Properties::Average);
 
@@ -64,6 +67,9 @@ namespace TagLib {
        *
        * \note In the current implementation, both \a readProperties and
        * \a propertiesStyle are ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true, Properties::ReadStyle propertiesStyle = Properties::Average);
 
index 31dfebd78f05d2ee7c029e34421ee91c7e6bd4a5..716d4478ccec0a05be5a8070a93b9aa6b36e14c2 100644 (file)
@@ -97,6 +97,9 @@ namespace TagLib {
        *
        * If this file contains and ID3v2 tag the frames will be created using
        * \a frameFactory.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       // BIC: merge with the above constructor
       File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
index 9c5077428c46063c6a93141e2a29732d31591f75..5584b7cd9ac08976bb01bc2c3f585a06fad5b0b6 100644 (file)
@@ -48,6 +48,9 @@ namespace TagLib {
          * Contructs a Impulse Tracker file from \a stream. If \a readProperties
          * is true the file's audio properties will also be read using
          * \a propertiesStyle. If false, \a propertiesStyle is ignored.
+         *
+         * \note TagLib will *not* take ownership of the stream, the caller is
+         * responsible for deleting it after the File object.
          */
         File(IOStream *stram, bool readProperties = true,
              AudioProperties::ReadStyle propertiesStyle =
index 9e79659c4e285a4e742fedf6c08461055fedb34c..ad1e43b88a3db9d32966829373b3dddfdc74d487 100644 (file)
@@ -49,6 +49,9 @@ namespace TagLib {
        * Contructs a Protracker file from \a stream. If \a readProperties
        * is true the file's audio properties will also be read using
        * \a propertiesStyle. If false, \a propertiesStyle is ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true,
            AudioProperties::ReadStyle propertiesStyle =
index c3613f768b144dbfc0219bbb700be4aaa90eda71..2ed3bea581e087b0bb089a930aaf37ca793201d2 100644 (file)
@@ -65,6 +65,9 @@ namespace TagLib {
        *
        * \note In the current implementation, both \a readProperties and
        * \a propertiesStyle are ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true, Properties::ReadStyle audioPropertiesStyle = Properties::Average);
 
index 61ac6d67e5a8021ded10a8fdf26edcba2135e6d1..167b768e1eab5d6b49af98bac6908e6476d53a13 100644 (file)
@@ -95,6 +95,9 @@ namespace TagLib {
        * Contructs an MPC file from \a file.  If \a readProperties is true the
        * file's audio properties will also be read using \a propertiesStyle.  If
        * false, \a propertiesStyle is ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true,
            Properties::ReadStyle propertiesStyle = Properties::Average);
index 185fced6d4704b7e1641b40285810c68a40e1ebf..9967a99125f494444144a688233b5a1b1be393be 100644 (file)
@@ -99,6 +99,9 @@ namespace TagLib {
        * file's audio properties will also be read using \a propertiesStyle.  If
        * false, \a propertiesStyle is ignored.  The frames will be created using
        * \a frameFactory.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       // BIC: merge with the above constructor
       File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
index d4373795f1d2e398240cc619db020b9309c61178..8558cfdfa185a10bf5c9c9739421a3ace7a8c78b 100644 (file)
@@ -75,6 +75,9 @@ namespace TagLib {
        * Contructs an Ogg/FLAC file from \a file.  If \a readProperties is true
        * the file's audio properties will also be read using \a propertiesStyle.
        * If false, \a propertiesStyle is ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true,
            Properties::ReadStyle propertiesStyle = Properties::Average);
index 1ecf2b9b0019c82af0c2968236f7d99df23134fa..b36daecb1dbd93bdb5f4cd04860d908f926ca259 100644 (file)
@@ -100,6 +100,9 @@ namespace TagLib {
        * \note This constructor is protected since Ogg::File shouldn't be
        * instantiated directly but rather should be used through the codec
        * specific subclasses.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream);
 
index c14cf2aa60d61d87d915716c175630a41f35e079..dfe51ec4d0b1da1bb93f74407e223ac2256812bc 100644 (file)
@@ -67,6 +67,9 @@ namespace TagLib {
          * Contructs a Speex file from \a file.  If \a readProperties is true the
          * file's audio properties will also be read using \a propertiesStyle.  If
          * false, \a propertiesStyle is ignored.
+         *
+         * \note TagLib will *not* take ownership of the stream, the caller is
+         * responsible for deleting it after the File object.
          */
         File(IOStream *stream, bool readProperties = true,
              Properties::ReadStyle propertiesStyle = Properties::Average);
index 15c29d99caaa785fdbfcf9cc51e08668663d321a..6e4d4fc4242e8e8cfbac1fd78e90ea373b088f38 100644 (file)
@@ -74,6 +74,9 @@ namespace TagLib {
        * Contructs a Vorbis file from \a file.  If \a readProperties is true the
        * file's audio properties will also be read using \a propertiesStyle.  If
        * false, \a propertiesStyle is ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true,
            Properties::ReadStyle propertiesStyle = Properties::Average);
index a50c8ecba6b36c4f255b420be2beec944405adad..e1284db08dfb0e1dc39d284b0695cfd0fe71655f 100644 (file)
@@ -69,6 +69,9 @@ namespace TagLib {
          * Contructs an AIFF file from \a file.  If \a readProperties is true the
          * file's audio properties will also be read using \a propertiesStyle.  If
          * false, \a propertiesStyle is ignored.
+         *
+         * \note TagLib will *not* take ownership of the stream, the caller is
+         * responsible for deleting it after the File object.
          */
         File(IOStream *stream, bool readProperties = true,
              Properties::ReadStyle propertiesStyle = Properties::Average);
index 861f3f77e1e9354b2373f2bd22023cc9fa0c50e2..1c470870769ab5186c4fd37b27aaa04301a98809 100644 (file)
@@ -69,6 +69,9 @@ namespace TagLib {
          * Contructs an WAV file from \a file.  If \a readProperties is true the
          * file's audio properties will also be read using \a propertiesStyle.  If
          * false, \a propertiesStyle is ignored.
+         *
+         * \note TagLib will *not* take ownership of the stream, the caller is
+         * responsible for deleting it after the File object.
          */
         File(IOStream *stream, bool readProperties = true,
              Properties::ReadStyle propertiesStyle = Properties::Average);
index 0605b2bfd89db665c6ae9c55cf621bc984a5cf35..c862108ee58375931b5f2a75bd6515fc13356ce2 100644 (file)
@@ -48,6 +48,9 @@ namespace TagLib {
          * Contructs a ScreamTracker III file from \a stream. If \a readProperties
          * is true the file's audio properties will also be read using
          * \a propertiesStyle. If false, \a propertiesStyle is ignored.
+         *
+         * \note TagLib will *not* take ownership of the stream, the caller is
+         * responsible for deleting it after the File object.
          */
         File(IOStream *stream, bool readProperties = true,
              AudioProperties::ReadStyle propertiesStyle =
index 30cc9fbc114a5234aec764c43777a7cab1cc3d33..d0a6116fbed6272efe31cd301d280de4585885dc 100644 (file)
@@ -74,15 +74,17 @@ using namespace TagLib;
 class File::FilePrivate
 {
 public:
-  FilePrivate(IOStream *stream);
+  FilePrivate(IOStream *stream, bool owner);
 
   IOStream *stream;
+  bool streamOwner;
   bool valid;
   static const uint bufferSize = 1024;
 };
 
-File::FilePrivate::FilePrivate(IOStream *stream) :
+File::FilePrivate::FilePrivate(IOStream *stream, bool owner) :
   stream(stream),
+  streamOwner(owner),
   valid(true)
 {
 }
@@ -94,17 +96,17 @@ File::FilePrivate::FilePrivate(IOStream *stream) :
 File::File(FileName fileName)
 {
   IOStream *stream = new FileStream(fileName);
-  d = new FilePrivate(stream);
+  d = new FilePrivate(stream, true);
 }
 
 File::File(IOStream *stream)
 {
-  d = new FilePrivate(stream);
+  d = new FilePrivate(stream, false);
 }
 
 File::~File()
 {
-  if(d->stream)
+  if(d->stream && d->streamOwner)
     delete d->stream;
   delete d;
 }
index 7df774a048060bf98d565ac66fcd05fe2350e4a4..7e6f2b9369cea060745a52de6f88f6e43ba821b1 100644 (file)
@@ -260,6 +260,9 @@ namespace TagLib {
     /*!
      * Construct a File object and use the \a stream instance.
      *
+     * \note TagLib will *not* take ownership of the stream, the caller is
+     * responsible for deleting it after the File object.
+     *
      * \note Constructor is protected since this class should only be
      * instantiated through subclasses.
      */
index 9b0378f7dade3658e912f529622902ce3d68bf6a..e3e1fe62829522bdc3663a0e60c1b343708f8c18 100644 (file)
@@ -100,6 +100,9 @@ namespace TagLib {
        * Contructs an TrueAudio file from \a file.  If \a readProperties is true the
        * file's audio properties will also be read using \a propertiesStyle.  If
        * false, \a propertiesStyle is ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true,
            Properties::ReadStyle propertiesStyle = Properties::Average);
@@ -109,6 +112,9 @@ namespace TagLib {
        * file's audio properties will also be read using \a propertiesStyle.  If
        * false, \a propertiesStyle is ignored. The frames will be created using
        * \a frameFactory.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
            bool readProperties = true,
index 02bac023198e08265e8295f8e2e0f0cab0ea3ed1..5bbbc65a190c3ac3ea5575661fc88560a4fd67e7 100644 (file)
@@ -91,6 +91,9 @@ namespace TagLib {
        * Contructs an WavPack file from \a file.  If \a readProperties is true the
        * file's audio properties will also be read using \a propertiesStyle.  If
        * false, \a propertiesStyle is ignored.
+       *
+       * \note TagLib will *not* take ownership of the stream, the caller is
+       * responsible for deleting it after the File object.
        */
       File(IOStream *stream, bool readProperties = true,
            Properties::ReadStyle propertiesStyle = Properties::Average);
index 1b07010b788585b1203bb2884285af86d6d4e70b..9d1bb71c687141495f377d8e1415b5ad0b351f6d 100644 (file)
@@ -48,6 +48,9 @@ namespace TagLib {
          * Contructs a Extended Module file from \a stream. If \a readProperties
          * is true the file's audio properties will also be read using
          * \a propertiesStyle. If false, \a propertiesStyle is ignored.
+         *
+         * \note TagLib will *not* take ownership of the stream, the caller is
+         * responsible for deleting it after the File object.
          */
         File(IOStream *stream, bool readProperties = true,
              AudioProperties::ReadStyle propertiesStyle =