mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 06:42:12 +00:00
- blocked the destructor in the sound font reader base class.
If ZMusic is to act like an external library it may not call delete on external objects because there is no guarantee that they use the same allocator. Deletion must be done as a virtual function to ensure that the correct operator delete gets called, which, unlike the actual destructor is not virtual itself.
This commit is contained in:
parent
7156611643
commit
fe0a6b00ce
4 changed files with 8 additions and 6 deletions
|
@ -224,8 +224,8 @@ struct VectorReader : public MemoryReader
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// The follpwing two functions are needed to allow using UTF-8 in the file interface.
|
||||
// fopen on Windows is only safe for ASCII,
|
||||
// The following two functions are needed to allow using UTF-8 in the file interface.
|
||||
// fopen on Windows is only safe for ASCII.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
|
@ -271,10 +271,12 @@ inline bool fileExists(const char *fn)
|
|||
|
||||
class SoundFontReaderInterface
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
virtual ~SoundFontReaderInterface() {}
|
||||
public:
|
||||
virtual struct FileInterface* open_file(const char* fn) = 0;
|
||||
virtual void add_search_path(const char* path) = 0;
|
||||
virtual void close() { delete this; }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -703,7 +703,7 @@ Instruments::~Instruments()
|
|||
drumset[i] = NULL;
|
||||
}
|
||||
}
|
||||
if (sfreader != nullptr) delete sfreader;
|
||||
if (sfreader != nullptr) sfreader->close();
|
||||
sfreader = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ Instruments::~Instruments()
|
|||
free_tone_bank();
|
||||
free_instrument_map();
|
||||
|
||||
if (sfreader != nullptr) delete sfreader;
|
||||
if (sfreader != nullptr) sfreader->close();
|
||||
}
|
||||
|
||||
void Instruments::free_instrument(Instrument *ip)
|
||||
|
|
|
@ -1326,7 +1326,7 @@ void Instruments::load_patch(struct _mdi *mdi, unsigned short patchid)
|
|||
Instruments::~Instruments()
|
||||
{
|
||||
FreePatches();
|
||||
delete sfreader;
|
||||
sfreader->close();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue