diff --git a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index ab96a09904..6321df24f6 100644 --- a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp @@ -29,10 +29,9 @@ namespace WindowsMediaCodec class JuceIStream : public ComBaseClassHelper { public: - JuceIStream (InputStream& source_) noexcept - : source (source_) + JuceIStream (InputStream& in) noexcept + : ComBaseClassHelper (0), source (in) { - resetReferenceCount(); } JUCE_COMRESULT Commit (DWORD) { return S_OK; } diff --git a/modules/juce_core/native/juce_win32_ComSmartPtr.h b/modules/juce_core/native/juce_win32_ComSmartPtr.h index ab775b011d..2cf3b725af 100644 --- a/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/modules/juce_core/native/juce_win32_ComSmartPtr.h @@ -97,14 +97,12 @@ template class ComBaseClassHelperBase : public ComClass { public: - ComBaseClassHelperBase() : refCount (1) {} + ComBaseClassHelperBase (unsigned int initialRefCount) : refCount (initialRefCount) {} virtual ~ComBaseClassHelperBase() {} ULONG __stdcall AddRef() { return ++refCount; } ULONG __stdcall Release() { const ULONG r = --refCount; if (r == 0) delete this; return r; } - void resetReferenceCount() noexcept { refCount = 0; } - protected: ULONG refCount; }; @@ -115,7 +113,7 @@ template class ComBaseClassHelper : public ComBaseClassHelperBase { public: - ComBaseClassHelper() {} + ComBaseClassHelper (unsigned int initialRefCount = 1) : ComBaseClassHelperBase (initialRefCount) {} ~ComBaseClassHelper() {} JUCE_COMRESULT QueryInterface (REFIID refId, void** result) diff --git a/modules/juce_graphics/colour/juce_Colour.cpp b/modules/juce_graphics/colour/juce_Colour.cpp index 9c4b45e2ad..8da7189e9c 100644 --- a/modules/juce_graphics/colour/juce_Colour.cpp +++ b/modules/juce_graphics/colour/juce_Colour.cpp @@ -115,7 +115,7 @@ namespace ColourHelpers if (h < 3.0f) return PixelARGB (alpha, x, intV, (uint8) roundToInt (v * (1.0f - (s * (1.0f - f))))); if (h < 4.0f) return PixelARGB (alpha, x, (uint8) roundToInt (v * (1.0f - s * f)), intV); if (h < 5.0f) return PixelARGB (alpha, (uint8) roundToInt (v * (1.0f - (s * (1.0f - f)))), x, intV); - else return PixelARGB (alpha, intV, x, (uint8) roundToInt (v * (1.0f - s * f))); + return PixelARGB (alpha, intV, x, (uint8) roundToInt (v * (1.0f - s * f))); } float hue, saturation, brightness; diff --git a/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp b/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp index bcdee3f3d8..f7e9eb8a82 100644 --- a/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp +++ b/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp @@ -27,15 +27,15 @@ #if JUCE_USE_DIRECTWRITE namespace DirectWriteTypeLayout { - class CustomDirectWriteTextRenderer : public ComBaseClassHelper + class CustomDirectWriteTextRenderer : public ComBaseClassHelper { public: - CustomDirectWriteTextRenderer (IDWriteFontCollection* const fontCollection_) - : fontCollection (fontCollection_), + CustomDirectWriteTextRenderer (IDWriteFontCollection* const fonts) + : ComBaseClassHelper (0), + fontCollection (fonts), currentLine (-1), lastOriginY (-10000.0f) { - resetReferenceCount(); } JUCE_COMRESULT QueryInterface (REFIID refId, void** result) diff --git a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index cfea903f94..cbc0253cf8 100644 --- a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -54,7 +54,7 @@ namespace ActiveXHelpers class JuceOleInPlaceFrame : public ComBaseClassHelper { public: - JuceOleInPlaceFrame (HWND window_) : window (window_) {} + JuceOleInPlaceFrame (HWND hwnd) : window (hwnd) {} JUCE_COMRESULT GetWindow (HWND* lphwnd) { *lphwnd = window; return S_OK; } JUCE_COMRESULT ContextSensitiveHelp (BOOL) { return E_NOTIMPL; } @@ -77,8 +77,8 @@ namespace ActiveXHelpers class JuceIOleInPlaceSite : public ComBaseClassHelper { public: - JuceIOleInPlaceSite (HWND window_) - : window (window_), + JuceIOleInPlaceSite (HWND hwnd) + : window (hwnd), frame (new JuceOleInPlaceFrame (window)) {} @@ -161,11 +161,9 @@ namespace ActiveXHelpers HWND getHWND (const ActiveXControlComponent* const component) { HWND hwnd = 0; - const IID iid = IID_IOleWindow; - IOleWindow* const window = (IOleWindow*) component->queryInterface (&iid); - if (window != nullptr) + if (IOleWindow* const window = (IOleWindow*) component->queryInterface (&iid)) { window->GetWindow (&hwnd); window->Release(); @@ -338,12 +336,8 @@ void ActiveXControlComponent::paint (Graphics& g) bool ActiveXControlComponent::createControl (const void* controlIID) { deleteControl(); - ComponentPeer* const peer = getPeer(); - // the component must have already been added to a real window when you call this! - jassert (peer != nullptr); - - if (peer != nullptr) + if (ComponentPeer* const peer = getPeer()) { const Rectangle bounds (getTopLevelComponent()->getLocalArea (this, getLocalBounds())); HWND hwnd = (HWND) peer->getNativeHandle(); @@ -383,6 +377,11 @@ bool ActiveXControlComponent::createControl (const void* controlIID) } } } + else + { + // the component must have already been added to a real window when you call this! + jassertfalse; + } return false; } diff --git a/modules/juce_video/native/juce_win32_CameraDevice.cpp b/modules/juce_video/native/juce_win32_CameraDevice.cpp index da59b4adf9..be6ec5c460 100644 --- a/modules/juce_video/native/juce_win32_CameraDevice.cpp +++ b/modules/juce_video/native/juce_win32_CameraDevice.cpp @@ -677,7 +677,8 @@ private: class GrabberCallback : public ComBaseClassHelperBase { public: - GrabberCallback (DShowCameraDeviceInteral& cam) : owner (cam) {} + GrabberCallback (DShowCameraDeviceInteral& cam) + : ComBaseClassHelperBase (0), owner (cam) {} STDMETHODIMP SampleCB (double, IMediaSample*) { return E_FAIL; }