From 90f37e27ead979125d70685be7a7ed3a550a73ab Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 22 Oct 2024 13:24:43 +0100 Subject: [PATCH] Windows: Fix DLL build There were a few "ambiguous operator new/delete" errors that were due to inheriting from a private base class that used the leak detector. These errors are resolved by adding the leak detector to the derived classes. JUCE_API was missing from a few useful types, notably the ARA hosting types. --- .../buffers/juce_AudioSampleBuffer.h | 2 ++ .../buffers/juce_FloatVectorOperations.h | 2 +- .../native/juce_Midi_windows.cpp | 2 ++ .../format_types/juce_ARAHosting.h | 20 +++++++++---------- modules/juce_events/timers/juce_Timer.cpp | 2 +- .../juce_Direct2DHwndContext_windows.cpp | 2 ++ .../keyboard/juce_CaretComponent.h | 2 +- .../misc/juce_DropShadower.cpp | 1 + .../mouse/juce_DragAndDropContainer.cpp | 2 +- .../widgets/juce_TextEditor.cpp | 2 +- .../windows/juce_CallOutBox.cpp | 2 +- .../misc/juce_WebBrowserComponent.h | 2 +- .../juce_opengl/opengl/juce_OpenGLContext.cpp | 2 ++ .../marketplace/juce_OnlineUnlockForm.cpp | 2 ++ 14 files changed, 28 insertions(+), 17 deletions(-) diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index b42f987953..cfc841150f 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -45,6 +45,8 @@ template class AudioBuffer { public: + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4661) + //============================================================================== /** Creates an empty buffer with 0 channels and 0 length. */ AudioBuffer() noexcept diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h index 9ba9ff453b..f0c8f359e7 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h @@ -63,7 +63,7 @@ class ScopedNoDenormals; @tags{Audio} */ template -struct FloatVectorOperationsBase +struct JUCE_API FloatVectorOperationsBase { /** Clears a vector of floating point numbers. */ static void JUCE_CALLTYPE clear (FloatType* dest, CountType numValues) noexcept; diff --git a/modules/juce_audio_devices/native/juce_Midi_windows.cpp b/modules/juce_audio_devices/native/juce_Midi_windows.cpp index 15c0bca0d7..241070341e 100644 --- a/modules/juce_audio_devices/native/juce_Midi_windows.cpp +++ b/modules/juce_audio_devices/native/juce_Midi_windows.cpp @@ -728,6 +728,8 @@ private: CriticalSection activeCollectorLock; ReferenceCountedArray activeCollectors; Array activeOutputHandles; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Win32MidiService) }; Array Win32MidiService::MidiInCollector::activeMidiCollectors; diff --git a/modules/juce_audio_processors/format_types/juce_ARAHosting.h b/modules/juce_audio_processors/format_types/juce_ARAHosting.h index f1c2ebc049..9a3d57cd0b 100644 --- a/modules/juce_audio_processors/format_types/juce_ARAHosting.h +++ b/modules/juce_audio_processors/format_types/juce_ARAHosting.h @@ -65,7 +65,7 @@ namespace juce @tags{ARA} */ -class ARAEditGuard +class JUCE_API ARAEditGuard { public: explicit ARAEditGuard (ARA::Host::DocumentController& dcIn); @@ -167,7 +167,7 @@ private: @tags{ARA} */ -class AudioSource : public ManagedARAHandle +class JUCE_API AudioSource : public ManagedARAHandle { public: /** Returns an %ARA versioned struct with the `structSize` correctly set for the currently @@ -235,7 +235,7 @@ public: @tags{ARA} */ -class AudioModification : public ManagedARAHandle +class JUCE_API AudioModification : public ManagedARAHandle { public: /** Returns an %ARA versioned struct with the `structSize` correctly set for the currently @@ -293,7 +293,7 @@ private: @tags{ARA} */ -struct DeletionListener +struct JUCE_API DeletionListener { /** Destructor. */ virtual ~DeletionListener() = default; @@ -318,7 +318,7 @@ struct DeletionListener @tags{ARA} */ -struct PlaybackRegion +struct JUCE_API PlaybackRegion { public: /** Returns an %ARA versioned struct with the `structSize` correctly set for the currently @@ -386,7 +386,7 @@ private: @tags{ARA} */ -class MusicalContext : public ManagedARAHandle +class JUCE_API MusicalContext : public ManagedARAHandle { public: /** Returns an %ARA versioned struct with the `structSize` correctly set for the currently @@ -448,7 +448,7 @@ public: @tags{ARA} */ -class RegionSequence : public ManagedARAHandle +class JUCE_API RegionSequence : public ManagedARAHandle { public: /** Returns an %ARA versioned struct with the `structSize` correctly set for the currently @@ -669,7 +669,7 @@ using EditorRendererInterface = PlaybackRegionRegistry cb); +void JUCE_API createARAFactoryAsync (AudioPluginInstance& instance, std::function cb); } // namespace juce diff --git a/modules/juce_events/timers/juce_Timer.cpp b/modules/juce_events/timers/juce_Timer.cpp index 4c3de7eec1..5f059547c7 100644 --- a/modules/juce_events/timers/juce_Timer.cpp +++ b/modules/juce_events/timers/juce_Timer.cpp @@ -429,7 +429,7 @@ struct LambdaInvoker final : private Timer, std::function function; - JUCE_DECLARE_NON_COPYABLE (LambdaInvoker) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LambdaInvoker) }; void JUCE_CALLTYPE Timer::callAfterDelay (int milliseconds, std::function f) diff --git a/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp index da6e174f80..bb99e00bcc 100644 --- a/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp @@ -53,6 +53,8 @@ private: thread.join(); } + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SwapChainThread) + private: Direct2DHwndContext::HwndPimpl& owner; HANDLE swapChainEventHandle = nullptr; diff --git a/modules/juce_gui_basics/keyboard/juce_CaretComponent.h b/modules/juce_gui_basics/keyboard/juce_CaretComponent.h index ac13f0dd21..acd7dc9e81 100644 --- a/modules/juce_gui_basics/keyboard/juce_CaretComponent.h +++ b/modules/juce_gui_basics/keyboard/juce_CaretComponent.h @@ -84,7 +84,7 @@ private: bool shouldBeShown() const; void timerCallback() override; - JUCE_DECLARE_NON_COPYABLE (CaretComponent) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CaretComponent) }; } // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/modules/juce_gui_basics/misc/juce_DropShadower.cpp index 6d23471d86..01e9aee6d1 100644 --- a/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/modules/juce_gui_basics/misc/juce_DropShadower.cpp @@ -177,6 +177,7 @@ private: std::map> listeners; JUCE_DECLARE_WEAK_REFERENCEABLE (VirtualDesktopWatcher) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VirtualDesktopWatcher) }; class DropShadower::ParentVisibilityChangedListener final : public ComponentListener diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp index 7bb0998e7d..88fe008996 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp @@ -404,7 +404,7 @@ private: && sourceToCheck.getIndex() == originalInputSourceIndex); } - JUCE_DECLARE_NON_COPYABLE (DragImageComponent) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragImageComponent) }; diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 41063ce336..a8d01dd58d 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -883,7 +883,7 @@ private: return createIgnoredAccessibilityHandler (*this); } - JUCE_DECLARE_NON_COPYABLE (TextHolderComponent) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextHolderComponent) }; //============================================================================== diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index 7397597ae7..2fc1b00a97 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp @@ -83,7 +83,7 @@ public: std::unique_ptr content; CallOutBox callout; - JUCE_DECLARE_NON_COPYABLE (CallOutBoxCallback) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CallOutBoxCallback) }; CallOutBox& CallOutBox::launchAsynchronously (std::unique_ptr content, Rectangle area, Component* parent) diff --git a/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h b/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h index 00baa0ecc0..bedd2ba2c9 100644 --- a/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h +++ b/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h @@ -50,7 +50,7 @@ class WebBrowserComponent; types using the WebBrowserComponent::Options::withOptionsFrom function as they have to be constructed before the WebBrowserComponent. */ -class WebViewLifetimeListener +class JUCE_API WebViewLifetimeListener { public: virtual ~WebViewLifetimeListener() = default; diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 2a933d415a..b548ffb567 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -1224,6 +1224,8 @@ private: if (auto* cachedImage = CachedImage::get (*getComponent())) cachedImage->checkViewportBounds(); } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Attachment) }; //============================================================================== diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp index f6de1f09c0..fe0a58afee 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp @@ -45,6 +45,8 @@ struct Spinner final : public Component, { getLookAndFeel().drawSpinningWaitAnimation (g, Colours::darkgrey, 0, 0, getWidth(), getHeight()); } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Spinner) }; struct OnlineUnlockForm::OverlayComp final : public Component,