Mercurial > hg > svcore
changeset 1364:b812df0351d9 3.0-integration
Fix (I think) crash on exit on Windows having loaded an mp3
author | Chris Cannam |
---|---|
date | Thu, 12 Jan 2017 17:29:59 +0000 |
parents | 39271c98cbdd |
children | 3382d914e110 |
files | data/fileio/MP3FileReader.cpp |
diffstat | 1 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fileio/MP3FileReader.cpp Tue Jan 10 16:56:48 2017 +0000 +++ b/data/fileio/MP3FileReader.cpp Thu Jan 12 17:29:59 2017 +0000 @@ -32,6 +32,14 @@ #include <id3tag.h> #endif +#ifdef _WIN32 +#include <io.h> +#include <fcntl.h> +#else +#include <fcntl.h> +#include <unistd.h> +#endif + #include <QFileInfo> #include <QTextCodec> @@ -176,7 +184,13 @@ #ifdef HAVE_ID3TAG - id3_file *file = id3_file_fdopen(fd, ID3_FILE_MODE_READONLY); +#ifdef _WIN32 + int id3fd = _dup(fd); +#else + int id3fd = dup(fd); +#endif + + id3_file *file = id3_file_fdopen(id3fd, ID3_FILE_MODE_READONLY); if (!file) return; // We can do this a lot more elegantly, but we'll leave that for @@ -185,7 +199,7 @@ id3_tag *tag = id3_file_tag(file); if (!tag) { SVDEBUG << "MP3FileReader::loadTags: No ID3 tag found" << endl; - id3_file_close(file); + id3_file_close(file); // also closes our dup'd fd return; } @@ -206,8 +220,7 @@ } } - // We don't id3_file_close(file) because that closes the fd, which - // was only lent to us + id3_file_close(file); // also closes our dup'd fd #else SVDEBUG << "MP3FileReader::loadTags: ID3 tag support not compiled in" << endl;