0dd3b02
@@ -60,7 +60,11 @@ public: | |||
CGColorSpaceRelease (colourSpace); | |||
} | |||
~CoreGraphicsPixelData() override; | |||
~CoreGraphicsPixelData() override | |||
{ | |||
freeCachedImageRef(); | |||
CGContextRelease (context); | |||
} | |||
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override | |||
{ | |||
@@ -185,14 +189,6 @@ private: | |||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsPixelData) | |||
}; | |||
// The following implementation is outside of the class definition to avoid spurious | |||
// warning messages when dynamically loading libraries at runtime on macOS | |||
CoreGraphicsPixelData::~CoreGraphicsPixelData() | |||
{ | |||
freeCachedImageRef(); | |||
CGContextRelease (context); | |||
} | |||
ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const | |||
{ | |||
return *new CoreGraphicsPixelData (format == Image::RGB ? Image::ARGB : format, width, height, clearImage); | |||
@@ -586,10 +586,24 @@ public: | |||
CFRelease (numberRef); | |||
} | |||
// The implementation of at least one overridden function needs to be outside | |||
// of the class definition to avoid spurious warning messages when dynamically | |||
// loading libraries at runtime on macOS... | |||
~OSXTypeface() override; | |||
~OSXTypeface() override | |||
{ | |||
if (attributedStringAtts != nullptr) | |||
CFRelease (attributedStringAtts); | |||
if (fontRef != nullptr) | |||
{ | |||
#if JUCE_MAC && defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 | |||
if (dataCopy.getSize() != 0) | |||
CTFontManagerUnregisterGraphicsFont (fontRef, nullptr); | |||
#endif | |||
CGFontRelease (fontRef); | |||
} | |||
if (ctFontRef != nullptr) | |||
CFRelease (ctFontRef); | |||
} | |||
float getAscent() const override { return ascent; } | |||
float getDescent() const override { return 1.0f - ascent; } | |||
@@ -719,25 +733,6 @@ private: | |||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSXTypeface) | |||
}; | |||
OSXTypeface::~OSXTypeface() | |||
{ | |||
if (attributedStringAtts != nullptr) | |||
CFRelease (attributedStringAtts); | |||
if (fontRef != nullptr) | |||
{ | |||
#if JUCE_MAC && defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 | |||
if (dataCopy.getSize() != 0) | |||
CTFontManagerUnregisterGraphicsFont (fontRef, nullptr); | |||
#endif | |||
CGFontRelease (fontRef); | |||
} | |||
if (ctFontRef != nullptr) | |||
CFRelease (ctFontRef); | |||
} | |||
CTFontRef getCTFontFromTypeface (const Font& f) | |||
{ | |||
if (auto* tf = dynamic_cast<OSXTypeface*> (f.getTypeface())) | |||
@@ -56,7 +56,10 @@ namespace TabbedComponentHelpers | |||
//============================================================================== | |||
struct TabbedComponent::ButtonBar : public TabbedButtonBar | |||
{ | |||
ButtonBar (TabbedComponent& tabComp, TabbedButtonBar::Orientation o); | |||
ButtonBar (TabbedComponent& tabComp, TabbedButtonBar::Orientation o) | |||
: TabbedButtonBar (o), owner (tabComp) | |||
{ | |||
} | |||
void currentTabChanged (int newCurrentTabIndex, const String& newTabName) | |||
{ | |||
@@ -83,13 +86,6 @@ struct TabbedComponent::ButtonBar : public TabbedButtonBar | |||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonBar) | |||
}; | |||
// The following implementation is outside of the class definition to avoid spurious | |||
// warning messages when dynamically loading libraries at runtime on macOS | |||
TabbedComponent::ButtonBar::ButtonBar (TabbedComponent& tabComp, TabbedButtonBar::Orientation o) | |||
: TabbedButtonBar (o), owner (tabComp) | |||
{ | |||
} | |||
//============================================================================== | |||
TabbedComponent::TabbedComponent (TabbedButtonBar::Orientation orientation) | |||
{ | |||
@@ -55,7 +55,10 @@ struct HeaderItemComponent : public PopupMenu::CustomComponent | |||
setName (name); | |||
} | |||
void paint (Graphics& g) override; | |||
void paint (Graphics& g) override | |||
{ | |||
getLookAndFeel().drawPopupMenuSectionHeader (g, getLocalBounds(), getName()); | |||
} | |||
void getIdealSize (int& idealWidth, int& idealHeight) override | |||
{ | |||
@@ -94,7 +97,13 @@ struct ItemComponent : public Component | |||
addMouseListener (&parent, false); | |||
} | |||
~ItemComponent() override; | |||
~ItemComponent() override | |||
{ | |||
if (customComp != nullptr) | |||
setItem (*customComp, nullptr); | |||
removeChildComponent (customComp.get()); | |||
} | |||
void getIdealSize (int& idealWidth, int& idealHeight, const int standardItemHeight) | |||
{ | |||
@@ -264,7 +273,13 @@ struct MenuWindow : public Component | |||
getMouseState (Desktop::getInstance().getMainMouseSource()); // forces creation of a mouse source watcher for the main mouse | |||
} | |||
~MenuWindow() override; | |||
~MenuWindow() override | |||
{ | |||
getActiveWindows().removeFirstMatchingValue (this); | |||
Desktop::getInstance().removeGlobalMouseListener (this); | |||
activeSubMenu.reset(); | |||
items.clear(); | |||
} | |||
//============================================================================== | |||
void paint (Graphics& g) override | |||
@@ -998,7 +1013,14 @@ public: | |||
startTimerHz (20); | |||
} | |||
void handleMouseEvent (const MouseEvent& e); | |||
void handleMouseEvent (const MouseEvent& e) | |||
{ | |||
if (! window.windowIsStillValid()) | |||
return; | |||
startTimerHz (20); | |||
handleMousePosition (e.getScreenPosition()); | |||
} | |||
void timerCallback() override | |||
{ | |||
@@ -1228,7 +1250,11 @@ struct NormalComponentWrapper : public PopupMenu::CustomComponent | |||
addAndMakeVisible (comp); | |||
} | |||
void getIdealSize (int& idealWidth, int& idealHeight) override; | |||
void getIdealSize (int& idealWidth, int& idealHeight) override | |||
{ | |||
idealWidth = width; | |||
idealHeight = height; | |||
} | |||
void resized() override | |||
{ | |||
@@ -1243,44 +1269,6 @@ struct NormalComponentWrapper : public PopupMenu::CustomComponent | |||
}; | |||
// The following implementations are outside of the class definitions to avoid spurious | |||
// warning messages when dynamically loading libraries at runtime on macOS | |||
void PopupMenu::HelperClasses::HeaderItemComponent::paint (Graphics& g) | |||
{ | |||
getLookAndFeel().drawPopupMenuSectionHeader (g, getLocalBounds(), getName()); | |||
} | |||
PopupMenu::HelperClasses::ItemComponent::~ItemComponent() | |||
{ | |||
if (customComp != nullptr) | |||
setItem (*customComp, nullptr); | |||
removeChildComponent (customComp.get()); | |||
} | |||
PopupMenu::HelperClasses::MenuWindow::~MenuWindow() | |||
{ | |||
getActiveWindows().removeFirstMatchingValue (this); | |||
Desktop::getInstance().removeGlobalMouseListener (this); | |||
activeSubMenu.reset(); | |||
items.clear(); | |||
} | |||
void PopupMenu::HelperClasses::MouseSourceState::handleMouseEvent (const MouseEvent& e) | |||
{ | |||
if (! window.windowIsStillValid()) | |||
return; | |||
startTimerHz (20); | |||
handleMousePosition (e.getScreenPosition()); | |||
} | |||
void PopupMenu::HelperClasses::NormalComponentWrapper::getIdealSize (int& idealWidth, int& idealHeight) | |||
{ | |||
idealWidth = width; | |||
idealHeight = height; | |||
} | |||
//============================================================================== | |||
PopupMenu::PopupMenu (const PopupMenu& other) | |||
: items (other.items), | |||