From a8a602f7a2f7d19fac3c8c4cd514141c1258ce97 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Thu, 3 Dec 2009 11:22:38 +0000 Subject: [PATCH] Couple of small fixes for mac midi and win32 threads, and fixed a memory leak in the demo app. --- .../juce demo/src/demos/RenderingTestComponent.cpp | 3 ++- juce_amalgamated.cpp | 14 +++++++------- src/native/mac/juce_mac_CoreMidi.cpp | 6 +++--- src/native/windows/juce_win32_Threads.cpp | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/extras/juce demo/src/demos/RenderingTestComponent.cpp b/extras/juce demo/src/demos/RenderingTestComponent.cpp index c1e3a2f51a..0cb133d3f8 100644 --- a/extras/juce demo/src/demos/RenderingTestComponent.cpp +++ b/extras/juce demo/src/demos/RenderingTestComponent.cpp @@ -35,6 +35,7 @@ public: { setOpaque (true); averageTime = 0; + svgDrawable = 0; rgbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoJpeg_jpg, RenderingTestComponent::demoJpeg_jpgSize); argbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoPng_png, RenderingTestComponent::demoPng_pngSize); @@ -334,7 +335,7 @@ private: void createSVGDrawable() { - svgDrawable = 0; + deleteAndZero (svgDrawable); MemoryInputStream iconsFileStream (BinaryData::icons_zip, BinaryData::icons_zipSize, false); ZipFile icons (&iconsFileStream, false); diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 9a981a6f10..292b72ee82 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -234198,7 +234198,7 @@ bool InterProcessLock::enter (const int timeOutMillisecs) throw() { if (reentrancyLevel++ == 0) { - internal = CreateMutex (0, TRUE, name); + internal = CreateMutex (0, TRUE, "Global\\" + name); if (internal != 0 && GetLastError() == ERROR_ALREADY_EXISTS) { @@ -264828,8 +264828,8 @@ static bool makeSureClientExists() class MidiPortAndEndpoint { public: - MidiPortAndEndpoint (MIDIPortRef port, MIDIEndpointRef endpoint) throw() - : port (port), endPoint (endpoint) + MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) throw() + : port (port_), endPoint (endPoint_) { } @@ -264838,7 +264838,7 @@ public: if (port != 0) MIDIPortDispose (port); - if (endPoint != 0) + if (port == 0 && endPoint != 0) // if port == 0, it means we created the endpoint, so it's safe to delete it MIDIEndpointDispose (endPoint); } @@ -272540,8 +272540,8 @@ static bool makeSureClientExists() class MidiPortAndEndpoint { public: - MidiPortAndEndpoint (MIDIPortRef port, MIDIEndpointRef endpoint) throw() - : port (port), endPoint (endpoint) + MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) throw() + : port (port_), endPoint (endPoint_) { } @@ -272550,7 +272550,7 @@ public: if (port != 0) MIDIPortDispose (port); - if (endPoint != 0) + if (port == 0 && endPoint != 0) // if port == 0, it means we created the endpoint, so it's safe to delete it MIDIEndpointDispose (endPoint); } diff --git a/src/native/mac/juce_mac_CoreMidi.cpp b/src/native/mac/juce_mac_CoreMidi.cpp index aeae3a17eb..805ceb4735 100644 --- a/src/native/mac/juce_mac_CoreMidi.cpp +++ b/src/native/mac/juce_mac_CoreMidi.cpp @@ -236,8 +236,8 @@ static bool makeSureClientExists() class MidiPortAndEndpoint { public: - MidiPortAndEndpoint (MIDIPortRef port, MIDIEndpointRef endpoint) throw() - : port (port), endPoint (endpoint) + MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) throw() + : port (port_), endPoint (endPoint_) { } @@ -246,7 +246,7 @@ public: if (port != 0) MIDIPortDispose (port); - if (endPoint != 0) + if (port == 0 && endPoint != 0) // if port == 0, it means we created the endpoint, so it's safe to delete it MIDIEndpointDispose (endPoint); } diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index a0b1523973..8b9a29a127 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -357,7 +357,7 @@ bool InterProcessLock::enter (const int timeOutMillisecs) throw() { if (reentrancyLevel++ == 0) { - internal = CreateMutex (0, TRUE, name); + internal = CreateMutex (0, TRUE, "Global\\" + name); if (internal != 0 && GetLastError() == ERROR_ALREADY_EXISTS) {