diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 8e122f63f5..370b9cd90e 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -77614,26 +77614,28 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point& position_, const StringArray& files_) - : target (target_), position (position_), files (files_) + AsyncFileDropMessage (Component* target_, FileDragAndDropTarget* dropTarget_, + const Point& position_, const StringArray& files_) + : target (target_), dropTarget (dropTarget_), position (position_), files (files_) { } void messageCallback() { if (target != 0) - target->filesDropped (files, position.getX(), position.getY()); + dropTarget->filesDropped (files, position.getX(), position.getY()); } private: Component::SafePointer target; + FileDragAndDropTarget* dropTarget; Point position; StringArray files; // (NB: don't make this non-copyable, which messes up in VC) }; - (new AsyncFileDropMessage (targetComp, targetComp->getLocalPoint (component, position), files))->post(); + (new AsyncFileDropMessage (targetComp, target, targetComp->getLocalPoint (component, position), files))->post(); } } } @@ -94853,10 +94855,6 @@ public: imageData = imageDataAllocated; } - ~SoftwareSharedImage() - { - } - Image::ImageType getType() const { return Image::SoftwareImage; @@ -94876,6 +94874,8 @@ public: private: HeapBlock imageDataAllocated; + + JUCE_LEAK_DETECTOR (SoftwareSharedImage); }; Image::SharedImage* Image::SharedImage::createSoftwareImage (Image::PixelFormat format, int width, int height, bool clearImage) @@ -266330,6 +266330,8 @@ private: return format == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault; #endif } + + JUCE_LEAK_DETECTOR (CoreGraphicsImage); }; Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage) @@ -266844,10 +266846,6 @@ private: { } - ~SavedState() - { - } - FillType fillType; Font font; CGFontRef fontRef; @@ -266982,7 +266980,7 @@ private: CGContextConcatCTM (context, t); } - JUCE_DECLARE_NON_COPYABLE (CoreGraphicsContext); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext); }; LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext() @@ -271062,6 +271060,8 @@ private: return format == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault; #endif } + + JUCE_LEAK_DETECTOR (CoreGraphicsImage); }; Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage) @@ -271576,10 +271576,6 @@ private: { } - ~SavedState() - { - } - FillType fillType; Font font; CGFontRef fontRef; @@ -271714,7 +271710,7 @@ private: CGContextConcatCTM (context, t); } - JUCE_DECLARE_NON_COPYABLE (CoreGraphicsContext); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext); }; LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext() @@ -273411,28 +273407,29 @@ void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable } } -class AsyncRepaintMessage : public CallbackMessage -{ -public: - NSViewComponentPeer* const peer; - const Rectangle rect; - - AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle& rect_) - : peer (peer_), rect (rect_) - { - } - - void messageCallback() - { - if (ComponentPeer::isValidPeer (peer)) - peer->repaint (rect); - } -}; - void NSViewComponentPeer::repaint (const Rectangle& area) { if (insideDrawRect) { + class AsyncRepaintMessage : public CallbackMessage + { + public: + AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle& rect_) + : peer (peer_), rect (rect_) + { + } + + void messageCallback() + { + if (ComponentPeer::isValidPeer (peer)) + peer->repaint (rect); + } + + private: + NSViewComponentPeer* const peer; + const Rectangle rect; + }; + (new AsyncRepaintMessage (this, area))->post(); } else diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 4099502d76..e7344d6db7 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -675,6 +675,16 @@ JUCE_DECLARE_NON_COPYABLE(className)\ JUCE_LEAK_DETECTOR(className) +#if ! DOXYGEN + #define JUCE_JOIN_MACRO_HELPER(a, b) a ## b +#endif + +/** Good old C macro concatenation helper. + This combines two items (which may themselves be macros) into a single string, + avoiding the pitfalls of the ## macro operator. +*/ +#define JUCE_JOIN_MACRO(a, b) JUCE_JOIN_MACRO_HELPER (a, b) + #if JUCE_CATCH_UNHANDLED_EXCEPTIONS #define JUCE_TRY try @@ -3201,7 +3211,7 @@ private: @see JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, LeakedObjectDetector */ - #define JUCE_LEAK_DETECTOR(OwnerClass) LeakedObjectDetector leakDetector ## __LINE__; + #define JUCE_LEAK_DETECTOR(OwnerClass) LeakedObjectDetector JUCE_JOIN_MACRO (leakDetector, __LINE__); #else #define JUCE_LEAK_DETECTOR(OwnerClass) #endif diff --git a/src/core/juce_LeakedObjectDetector.h b/src/core/juce_LeakedObjectDetector.h index c4041cbed3..025ea48774 100644 --- a/src/core/juce_LeakedObjectDetector.h +++ b/src/core/juce_LeakedObjectDetector.h @@ -126,7 +126,7 @@ private: @see JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, LeakedObjectDetector */ - #define JUCE_LEAK_DETECTOR(OwnerClass) LeakedObjectDetector leakDetector ## __LINE__; + #define JUCE_LEAK_DETECTOR(OwnerClass) LeakedObjectDetector JUCE_JOIN_MACRO (leakDetector, __LINE__); #else #define JUCE_LEAK_DETECTOR(OwnerClass) #endif diff --git a/src/core/juce_PlatformDefs.h b/src/core/juce_PlatformDefs.h index 59174f5969..84720ae3bd 100644 --- a/src/core/juce_PlatformDefs.h +++ b/src/core/juce_PlatformDefs.h @@ -191,6 +191,18 @@ JUCE_DECLARE_NON_COPYABLE(className)\ JUCE_LEAK_DETECTOR(className) + +//============================================================================== +#if ! DOXYGEN + #define JUCE_JOIN_MACRO_HELPER(a, b) a ## b +#endif + +/** Good old C macro concatenation helper. + This combines two items (which may themselves be macros) into a single string, + avoiding the pitfalls of the ## macro operator. +*/ +#define JUCE_JOIN_MACRO(a, b) JUCE_JOIN_MACRO_HELPER (a, b) + //============================================================================== #if JUCE_CATCH_UNHANDLED_EXCEPTIONS diff --git a/src/gui/components/windows/juce_ComponentPeer.cpp b/src/gui/components/windows/juce_ComponentPeer.cpp index 91125834d1..a11e29488c 100644 --- a/src/gui/components/windows/juce_ComponentPeer.cpp +++ b/src/gui/components/windows/juce_ComponentPeer.cpp @@ -512,26 +512,28 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point& position_, const StringArray& files_) - : target (target_), position (position_), files (files_) + AsyncFileDropMessage (Component* target_, FileDragAndDropTarget* dropTarget_, + const Point& position_, const StringArray& files_) + : target (target_), dropTarget (dropTarget_), position (position_), files (files_) { } void messageCallback() { if (target != 0) - target->filesDropped (files, position.getX(), position.getY()); + dropTarget->filesDropped (files, position.getX(), position.getY()); } private: Component::SafePointer target; + FileDragAndDropTarget* dropTarget; Point position; StringArray files; // (NB: don't make this non-copyable, which messes up in VC) }; - (new AsyncFileDropMessage (targetComp, targetComp->getLocalPoint (component, position), files))->post(); + (new AsyncFileDropMessage (targetComp, target, targetComp->getLocalPoint (component, position), files))->post(); } } } diff --git a/src/gui/graphics/imaging/juce_Image.cpp b/src/gui/graphics/imaging/juce_Image.cpp index 1133658fb3..be779c8b0f 100644 --- a/src/gui/graphics/imaging/juce_Image.cpp +++ b/src/gui/graphics/imaging/juce_Image.cpp @@ -65,10 +65,6 @@ public: imageData = imageDataAllocated; } - ~SoftwareSharedImage() - { - } - Image::ImageType getType() const { return Image::SoftwareImage; @@ -88,6 +84,8 @@ public: private: HeapBlock imageDataAllocated; + + JUCE_LEAK_DETECTOR (SoftwareSharedImage); }; Image::SharedImage* Image::SharedImage::createSoftwareImage (Image::PixelFormat format, int width, int height, bool clearImage) diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index c69085b559..5ef7243428 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -126,6 +126,8 @@ private: return format == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault; #endif } + + JUCE_LEAK_DETECTOR (CoreGraphicsImage); }; Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage) @@ -646,10 +648,6 @@ private: { } - ~SavedState() - { - } - FillType fillType; Font font; CGFontRef fontRef; @@ -784,7 +782,7 @@ private: CGContextConcatCTM (context, t); } - JUCE_DECLARE_NON_COPYABLE (CoreGraphicsContext); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext); }; LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext() diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 934781fbee..868bf6acdd 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -1674,28 +1674,29 @@ void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable } //============================================================================== -class AsyncRepaintMessage : public CallbackMessage -{ -public: - NSViewComponentPeer* const peer; - const Rectangle rect; - - AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle& rect_) - : peer (peer_), rect (rect_) - { - } - - void messageCallback() - { - if (ComponentPeer::isValidPeer (peer)) - peer->repaint (rect); - } -}; - void NSViewComponentPeer::repaint (const Rectangle& area) { if (insideDrawRect) { + class AsyncRepaintMessage : public CallbackMessage + { + public: + AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle& rect_) + : peer (peer_), rect (rect_) + { + } + + void messageCallback() + { + if (ComponentPeer::isValidPeer (peer)) + peer->repaint (rect); + } + + private: + NSViewComponentPeer* const peer; + const Rectangle rect; + }; + (new AsyncRepaintMessage (this, area))->post(); } else