aboutsummaryrefslogtreecommitdiffstats
path: root/taglib/toolkit
diff options
context:
space:
mode:
Diffstat (limited to 'taglib/toolkit')
-rw-r--r--taglib/toolkit/tfile.cpp12
-rw-r--r--taglib/toolkit/tfile.h3
2 files changed, 10 insertions, 5 deletions
diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp
index 30cc9fbc..d0a6116f 100644
--- a/taglib/toolkit/tfile.cpp
+++ b/taglib/toolkit/tfile.cpp
@@ -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;
}
diff --git a/taglib/toolkit/tfile.h b/taglib/toolkit/tfile.h
index 7df774a0..7e6f2b93 100644
--- a/taglib/toolkit/tfile.h
+++ b/taglib/toolkit/tfile.h
@@ -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.
*/