Browse Source

Small fixes to drag-and-drop, leak detector.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
a768d7410f
8 changed files with 87 additions and 69 deletions
  1. +33
    -36
      juce_amalgamated.cpp
  2. +11
    -1
      juce_amalgamated.h
  3. +1
    -1
      src/core/juce_LeakedObjectDetector.h
  4. +12
    -0
      src/core/juce_PlatformDefs.h
  5. +6
    -4
      src/gui/components/windows/juce_ComponentPeer.cpp
  6. +2
    -4
      src/gui/graphics/imaging/juce_Image.cpp
  7. +3
    -5
      src/native/mac/juce_mac_CoreGraphicsContext.mm
  8. +19
    -18
      src/native/mac/juce_mac_NSViewComponentPeer.mm

+ 33
- 36
juce_amalgamated.cpp View File

@@ -77614,26 +77614,28 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point<in
class AsyncFileDropMessage : public CallbackMessage class AsyncFileDropMessage : public CallbackMessage
{ {
public: public:
AsyncFileDropMessage (Component* target_, const Point<int>& position_, const StringArray& files_)
: target (target_), position (position_), files (files_)
AsyncFileDropMessage (Component* target_, FileDragAndDropTarget* dropTarget_,
const Point<int>& position_, const StringArray& files_)
: target (target_), dropTarget (dropTarget_), position (position_), files (files_)
{ {
} }


void messageCallback() void messageCallback()
{ {
if (target != 0) if (target != 0)
target->filesDropped (files, position.getX(), position.getY());
dropTarget->filesDropped (files, position.getX(), position.getY());
} }


private: private:
Component::SafePointer<Component> target; Component::SafePointer<Component> target;
FileDragAndDropTarget* dropTarget;
Point<int> position; Point<int> position;
StringArray files; StringArray files;


// (NB: don't make this non-copyable, which messes up in VC) // (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; imageData = imageDataAllocated;
} }


~SoftwareSharedImage()
{
}

Image::ImageType getType() const Image::ImageType getType() const
{ {
return Image::SoftwareImage; return Image::SoftwareImage;
@@ -94876,6 +94874,8 @@ public:


private: private:
HeapBlock<uint8> imageDataAllocated; HeapBlock<uint8> imageDataAllocated;

JUCE_LEAK_DETECTOR (SoftwareSharedImage);
}; };


Image::SharedImage* Image::SharedImage::createSoftwareImage (Image::PixelFormat format, int width, int height, bool clearImage) 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; return format == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault;
#endif #endif
} }

JUCE_LEAK_DETECTOR (CoreGraphicsImage);
}; };


Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage) Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage)
@@ -266844,10 +266846,6 @@ private:
{ {
} }


~SavedState()
{
}

FillType fillType; FillType fillType;
Font font; Font font;
CGFontRef fontRef; CGFontRef fontRef;
@@ -266982,7 +266980,7 @@ private:
CGContextConcatCTM (context, t); CGContextConcatCTM (context, t);
} }


JUCE_DECLARE_NON_COPYABLE (CoreGraphicsContext);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext);
}; };


LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext() LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext()
@@ -271062,6 +271060,8 @@ private:
return format == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault; return format == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault;
#endif #endif
} }

JUCE_LEAK_DETECTOR (CoreGraphicsImage);
}; };


Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage) Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage)
@@ -271576,10 +271576,6 @@ private:
{ {
} }


~SavedState()
{
}

FillType fillType; FillType fillType;
Font font; Font font;
CGFontRef fontRef; CGFontRef fontRef;
@@ -271714,7 +271710,7 @@ private:
CGContextConcatCTM (context, t); CGContextConcatCTM (context, t);
} }


JUCE_DECLARE_NON_COPYABLE (CoreGraphicsContext);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext);
}; };


LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext() LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext()
@@ -273411,28 +273407,29 @@ void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable
} }
} }


class AsyncRepaintMessage : public CallbackMessage
{
public:
NSViewComponentPeer* const peer;
const Rectangle<int> rect;

AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle<int>& rect_)
: peer (peer_), rect (rect_)
{
}

void messageCallback()
{
if (ComponentPeer::isValidPeer (peer))
peer->repaint (rect);
}
};

void NSViewComponentPeer::repaint (const Rectangle<int>& area) void NSViewComponentPeer::repaint (const Rectangle<int>& area)
{ {
if (insideDrawRect) if (insideDrawRect)
{ {
class AsyncRepaintMessage : public CallbackMessage
{
public:
AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle<int>& rect_)
: peer (peer_), rect (rect_)
{
}

void messageCallback()
{
if (ComponentPeer::isValidPeer (peer))
peer->repaint (rect);
}

private:
NSViewComponentPeer* const peer;
const Rectangle<int> rect;
};

(new AsyncRepaintMessage (this, area))->post(); (new AsyncRepaintMessage (this, area))->post();
} }
else else


+ 11
- 1
juce_amalgamated.h View File

@@ -675,6 +675,16 @@
JUCE_DECLARE_NON_COPYABLE(className)\ JUCE_DECLARE_NON_COPYABLE(className)\
JUCE_LEAK_DETECTOR(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 #if JUCE_CATCH_UNHANDLED_EXCEPTIONS


#define JUCE_TRY try #define JUCE_TRY try
@@ -3201,7 +3211,7 @@ private:


@see JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, LeakedObjectDetector @see JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, LeakedObjectDetector
*/ */
#define JUCE_LEAK_DETECTOR(OwnerClass) LeakedObjectDetector<OwnerClass> leakDetector ## __LINE__;
#define JUCE_LEAK_DETECTOR(OwnerClass) LeakedObjectDetector<OwnerClass> JUCE_JOIN_MACRO (leakDetector, __LINE__);
#else #else
#define JUCE_LEAK_DETECTOR(OwnerClass) #define JUCE_LEAK_DETECTOR(OwnerClass)
#endif #endif


+ 1
- 1
src/core/juce_LeakedObjectDetector.h View File

@@ -126,7 +126,7 @@ private:
@see JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, LeakedObjectDetector @see JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, LeakedObjectDetector
*/ */
#define JUCE_LEAK_DETECTOR(OwnerClass) LeakedObjectDetector<OwnerClass> leakDetector ## __LINE__;
#define JUCE_LEAK_DETECTOR(OwnerClass) LeakedObjectDetector<OwnerClass> JUCE_JOIN_MACRO (leakDetector, __LINE__);
#else #else
#define JUCE_LEAK_DETECTOR(OwnerClass) #define JUCE_LEAK_DETECTOR(OwnerClass)
#endif #endif


+ 12
- 0
src/core/juce_PlatformDefs.h View File

@@ -191,6 +191,18 @@
JUCE_DECLARE_NON_COPYABLE(className)\ JUCE_DECLARE_NON_COPYABLE(className)\
JUCE_LEAK_DETECTOR(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 #if JUCE_CATCH_UNHANDLED_EXCEPTIONS


+ 6
- 4
src/gui/components/windows/juce_ComponentPeer.cpp View File

@@ -512,26 +512,28 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point<in
class AsyncFileDropMessage : public CallbackMessage class AsyncFileDropMessage : public CallbackMessage
{ {
public: public:
AsyncFileDropMessage (Component* target_, const Point<int>& position_, const StringArray& files_)
: target (target_), position (position_), files (files_)
AsyncFileDropMessage (Component* target_, FileDragAndDropTarget* dropTarget_,
const Point<int>& position_, const StringArray& files_)
: target (target_), dropTarget (dropTarget_), position (position_), files (files_)
{ {
} }
void messageCallback() void messageCallback()
{ {
if (target != 0) if (target != 0)
target->filesDropped (files, position.getX(), position.getY());
dropTarget->filesDropped (files, position.getX(), position.getY());
} }
private: private:
Component::SafePointer<Component> target; Component::SafePointer<Component> target;
FileDragAndDropTarget* dropTarget;
Point<int> position; Point<int> position;
StringArray files; StringArray files;
// (NB: don't make this non-copyable, which messes up in VC) // (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();
} }
} }
} }


+ 2
- 4
src/gui/graphics/imaging/juce_Image.cpp View File

@@ -65,10 +65,6 @@ public:
imageData = imageDataAllocated; imageData = imageDataAllocated;
} }
~SoftwareSharedImage()
{
}
Image::ImageType getType() const Image::ImageType getType() const
{ {
return Image::SoftwareImage; return Image::SoftwareImage;
@@ -88,6 +84,8 @@ public:
private: private:
HeapBlock<uint8> imageDataAllocated; HeapBlock<uint8> imageDataAllocated;
JUCE_LEAK_DETECTOR (SoftwareSharedImage);
}; };
Image::SharedImage* Image::SharedImage::createSoftwareImage (Image::PixelFormat format, int width, int height, bool clearImage) Image::SharedImage* Image::SharedImage::createSoftwareImage (Image::PixelFormat format, int width, int height, bool clearImage)


+ 3
- 5
src/native/mac/juce_mac_CoreGraphicsContext.mm View File

@@ -126,6 +126,8 @@ private:
return format == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault; return format == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault;
#endif #endif
} }
JUCE_LEAK_DETECTOR (CoreGraphicsImage);
}; };
Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage) Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, int width, int height, bool clearImage)
@@ -646,10 +648,6 @@ private:
{ {
} }
~SavedState()
{
}
FillType fillType; FillType fillType;
Font font; Font font;
CGFontRef fontRef; CGFontRef fontRef;
@@ -784,7 +782,7 @@ private:
CGContextConcatCTM (context, t); CGContextConcatCTM (context, t);
} }
JUCE_DECLARE_NON_COPYABLE (CoreGraphicsContext);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext);
}; };
LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext() LowLevelGraphicsContext* CoreGraphicsImage::createLowLevelContext()


+ 19
- 18
src/native/mac/juce_mac_NSViewComponentPeer.mm View File

@@ -1674,28 +1674,29 @@ void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable
} }
//============================================================================== //==============================================================================
class AsyncRepaintMessage : public CallbackMessage
{
public:
NSViewComponentPeer* const peer;
const Rectangle<int> rect;
AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle<int>& rect_)
: peer (peer_), rect (rect_)
{
}
void messageCallback()
{
if (ComponentPeer::isValidPeer (peer))
peer->repaint (rect);
}
};
void NSViewComponentPeer::repaint (const Rectangle<int>& area) void NSViewComponentPeer::repaint (const Rectangle<int>& area)
{ {
if (insideDrawRect) if (insideDrawRect)
{ {
class AsyncRepaintMessage : public CallbackMessage
{
public:
AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle<int>& rect_)
: peer (peer_), rect (rect_)
{
}
void messageCallback()
{
if (ComponentPeer::isValidPeer (peer))
peer->repaint (rect);
}
private:
NSViewComponentPeer* const peer;
const Rectangle<int> rect;
};
(new AsyncRepaintMessage (this, area))->post(); (new AsyncRepaintMessage (this, area))->post();
} }
else else


Loading…
Cancel
Save