mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fix a crash on shutdown when DanglingStreamChecker gets destroyed before LeakCounter instances.
This commit is contained in:
parent
833446fe89
commit
4ff0c9c881
1 changed files with 14 additions and 3 deletions
|
|
@ -25,9 +25,10 @@ namespace juce
|
|||
|
||||
#if JUCE_DEBUG
|
||||
|
||||
//==============================================================================
|
||||
struct DanglingStreamChecker
|
||||
{
|
||||
DanglingStreamChecker() {}
|
||||
DanglingStreamChecker() = default;
|
||||
|
||||
~DanglingStreamChecker()
|
||||
{
|
||||
|
|
@ -38,12 +39,20 @@ struct DanglingStreamChecker
|
|||
nastiness..
|
||||
*/
|
||||
jassert (activeStreams.size() == 0);
|
||||
|
||||
// We need to flag when this helper struct has been destroyed to prevent some
|
||||
// nasty order-of-static-destruction issues
|
||||
hasBeenDestroyed = true;
|
||||
}
|
||||
|
||||
Array<void*, CriticalSection> activeStreams;
|
||||
|
||||
static bool hasBeenDestroyed;
|
||||
};
|
||||
|
||||
bool DanglingStreamChecker::hasBeenDestroyed = false;
|
||||
static DanglingStreamChecker danglingStreamChecker;
|
||||
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -51,14 +60,16 @@ OutputStream::OutputStream()
|
|||
: newLineString (NewLine::getDefault())
|
||||
{
|
||||
#if JUCE_DEBUG
|
||||
danglingStreamChecker.activeStreams.add (this);
|
||||
if (! DanglingStreamChecker::hasBeenDestroyed)
|
||||
danglingStreamChecker.activeStreams.add (this);
|
||||
#endif
|
||||
}
|
||||
|
||||
OutputStream::~OutputStream()
|
||||
{
|
||||
#if JUCE_DEBUG
|
||||
danglingStreamChecker.activeStreams.removeFirstMatchingValue (this);
|
||||
if (! DanglingStreamChecker::hasBeenDestroyed)
|
||||
danglingStreamChecker.activeStreams.removeFirstMatchingValue (this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue