--- libgig/trunk/src/RIFF.cpp 2009/04/16 18:25:31 1885 +++ libgig/trunk/src/RIFF.cpp 2009/07/30 08:16:02 1953 @@ -22,6 +22,7 @@ ***************************************************************************/ #include +#include #include #include "RIFF.h" @@ -1383,6 +1384,10 @@ // *************** File *************** // * +//HACK: to avoid breaking DLL compatibility to older versions of libgig we roll the new std::set into the old std::list container, should be replaced on member variable level soon though +#define _GET_RESIZED_CHUNKS() \ + (reinterpret_cast*>(ResizedChunks.front())) + /** @brief Create new RIFF file. * * Use this constructor if you want to create a new RIFF file completely @@ -1398,6 +1403,8 @@ * @see AddSubChunk(), AddSubList(), SetByteOrder() */ File::File(uint32_t FileType) : List(this) { + //HACK: see _GET_RESIZED_CHUNKS() comment + ResizedChunks.push_back(reinterpret_cast(new std::set)); #if defined(WIN32) hFileRead = hFileWrite = INVALID_HANDLE_VALUE; #else @@ -1422,6 +1429,8 @@ std::cout << "File::File("<(new std::set)); #if POSIX hFileRead = hFileWrite = open(path.c_str(), O_RDONLY | O_NONBLOCK); if (hFileRead <= 0) { @@ -1607,7 +1616,8 @@ // first we sum up all positive chunk size changes (and skip all negative ones) unsigned long ulPositiveSizeDiff = 0; - for (std::set::const_iterator iter = ResizedChunks.begin(), end = ResizedChunks.end(); iter != end; ++iter) { + std::set* resizedChunks = _GET_RESIZED_CHUNKS(); + for (std::set::const_iterator iter = resizedChunks->begin(), end = resizedChunks->end(); iter != end; ++iter) { if ((*iter)->GetNewSize() == 0) { throw Exception("There is at least one empty chunk (zero size): " + __resolveChunkPath(*iter)); } @@ -1663,7 +1673,7 @@ if (ulTotalSize < ulActualSize) ResizeFile(ulTotalSize); // forget all resized chunks - ResizedChunks.clear(); + resizedChunks->clear(); } /** @brief Save changes to another file. @@ -1720,7 +1730,7 @@ if (ulTotalSize < ulActualSize) ResizeFile(ulTotalSize); // forget all resized chunks - ResizedChunks.clear(); + _GET_RESIZED_CHUNKS()->clear(); #if POSIX if (hFileWrite) close(hFileWrite); @@ -1765,14 +1775,16 @@ #endif // POSIX DeleteChunkList(); pFile = NULL; + //HACK: see _GET_RESIZED_CHUNKS() comment + delete _GET_RESIZED_CHUNKS(); } void File::LogAsResized(Chunk* pResizedChunk) { - ResizedChunks.insert(pResizedChunk); + _GET_RESIZED_CHUNKS()->insert(pResizedChunk); } void File::UnlogResized(Chunk* pResizedChunk) { - ResizedChunks.erase(pResizedChunk); + _GET_RESIZED_CHUNKS()->erase(pResizedChunk); } unsigned long File::GetFileSize() {