diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index 37e217f628..a5834682c7 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -1031,6 +1031,8 @@ public: { const bool wasValid = isValid(); + wrapper.setVisible (false); + removeChildComponent (&wrapper); wrapper.setView (nil); if (wasValid) diff --git a/modules/juce_core/network/juce_NamedPipe.cpp b/modules/juce_core/network/juce_NamedPipe.cpp index 405ba8f486..d257f16deb 100644 --- a/modules/juce_core/network/juce_NamedPipe.cpp +++ b/modules/juce_core/network/juce_NamedPipe.cpp @@ -25,7 +25,6 @@ BEGIN_JUCE_NAMESPACE -//============================================================================== bool NamedPipe::openExisting (const String& pipeName) { currentPipeName = pipeName; diff --git a/modules/juce_core/network/juce_NamedPipe.h b/modules/juce_core/network/juce_NamedPipe.h index c072ce7026..7490fe2ac9 100644 --- a/modules/juce_core/network/juce_NamedPipe.h +++ b/modules/juce_core/network/juce_NamedPipe.h @@ -26,8 +26,6 @@ #ifndef __JUCE_NAMEDPIPE_JUCEHEADER__ #define __JUCE_NAMEDPIPE_JUCEHEADER__ -#include "../threads/juce_CriticalSection.h" - //============================================================================== /** @@ -102,7 +100,6 @@ private: class Pimpl; ScopedPointer pimpl; String currentPipeName; - CriticalSection lock; bool openInternal (const String& pipeName, const bool createPipe); diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index 1520066ce4..2803826f22 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -132,8 +132,8 @@ void Button::setToggleState (const bool shouldBeOn, { if (shouldBeOn != lastToggleState) { - if (isOn != shouldBeOn) // this test means that if the value is void rather than explicitly set to - isOn = shouldBeOn; // false, it won't be changed unless the required value is true. + if (getToggleState() != shouldBeOn) // this test means that if the value is void rather than explicitly set to + isOn = shouldBeOn; // false, it won't be changed unless the required value is true. lastToggleState = shouldBeOn; repaint(); diff --git a/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/modules/juce_gui_basics/native/juce_mac_Windowing.mm index 3090235dd1..bb0e5f12fd 100644 --- a/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -346,11 +346,13 @@ Image juce_createIconForFile (const File& file) //============================================================================== void SystemClipboard::copyTextToClipboard (const String& text) { - [[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] - owner: nil]; + NSPasteboard* pb = [NSPasteboard generalPasteboard]; - [[NSPasteboard generalPasteboard] setString: juceStringToNS (text) - forType: NSStringPboardType]; + [pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] + owner: nil]; + + [pb setString: juceStringToNS (text) + forType: NSStringPboardType]; } String SystemClipboard::getTextFromClipboard() diff --git a/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h b/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h index 4eb05556f9..6368dd8f29 100644 --- a/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h +++ b/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h @@ -108,19 +108,13 @@ public: //============================================================================== /** @internal */ void paint (Graphics& g); - /** @internal */ - void* originalWndProc; private: class Pimpl; - friend class Pimpl; friend class ScopedPointer ; ScopedPointer control; bool mouseEventsAllowed; - void setControlBounds (const Rectangle& bounds) const; - void setControlVisible (bool b) const; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ActiveXControlComponent); }; diff --git a/modules/juce_gui_extra/embedding/juce_UIViewComponent.h b/modules/juce_gui_extra/embedding/juce_UIViewComponent.h index 15ebe035cf..f7a6cf40b1 100644 --- a/modules/juce_gui_extra/embedding/juce_UIViewComponent.h +++ b/modules/juce_gui_extra/embedding/juce_UIViewComponent.h @@ -84,5 +84,4 @@ private: }; #endif - #endif // __JUCE_UIVIEWCOMPONENT_JUCEHEADER__ diff --git a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h index ca6456bfb8..a6a726ebcf 100644 --- a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h +++ b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h @@ -75,9 +75,9 @@ public: if (wrapperWindow == 0) { Rect r; - r.left = getScreenX(); - r.top = getScreenY(); - r.right = r.left + getWidth(); + r.left = getScreenX(); + r.top = getScreenY(); + r.right = r.left + getWidth(); r.bottom = r.top + getHeight(); CreateNewWindow (kDocumentWindowClass, @@ -101,10 +101,10 @@ public: { kEventClassWindow, kEventWindowGetClickActivation }, { kEventClassWindow, kEventWindowHandleDeactivate }, { kEventClassWindow, kEventWindowBoundsChanging }, - { kEventClassMouse, kEventMouseDown }, - { kEventClassMouse, kEventMouseMoved }, - { kEventClassMouse, kEventMouseDragged }, - { kEventClassMouse, kEventMouseUp}, + { kEventClassMouse, kEventMouseDown }, + { kEventClassMouse, kEventMouseMoved }, + { kEventClassMouse, kEventMouseDragged }, + { kEventClassMouse, kEventMouseUp}, { kEventClassWindow, kEventWindowDrawContent }, { kEventClassWindow, kEventWindowShown }, { kEventClassWindow, kEventWindowHidden } @@ -179,7 +179,7 @@ public: HIRect r; r.origin.x = 0; r.origin.y = 0; - r.size.width = (float) getWidth(); + r.size.width = (float) getWidth(); r.size.height = (float) getHeight(); HIViewSetFrame (embeddedView, &r); } @@ -187,9 +187,9 @@ public: if (wrapperWindow != 0) { Rect wr; - wr.left = getScreenX(); - wr.top = getScreenY(); - wr.right = wr.left + getWidth(); + wr.left = getScreenX(); + wr.top = getScreenY(); + wr.right = wr.left + getWidth(); wr.bottom = wr.top + getHeight(); SetWindowBounds (wrapperWindow, kWindowContentRgn, &wr); diff --git a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm index 6577479ab0..b196b1919c 100644 --- a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm +++ b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm @@ -40,7 +40,7 @@ public: ~Pimpl() { - [view removeFromSuperview]; + removeFromParent(); [view release]; } @@ -77,10 +77,7 @@ public: if (currentPeer != peer) { - if ([view superview] != nil) - [view removeFromSuperview]; // Must be careful not to call this unless it's required - e.g. some Apple AU views - // override the call and use it as a sign that they're being deleted, which breaks everything.. - + removeFromParent(); currentPeer = peer; if (peer != nullptr) @@ -111,6 +108,13 @@ private: Component& owner; ComponentPeer* currentPeer; + void removeFromParent() + { + if ([view superview] != nil) + [view removeFromSuperview]; // Must be careful not to call this unless it's required - e.g. some Apple AU views + // override the call and use it as a sign that they're being deleted, which breaks everything.. + } + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl); }; diff --git a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index 84b4721e89..ae319611a7 100644 --- a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -205,14 +205,14 @@ namespace ActiveXHelpers class ActiveXControlComponent::Pimpl : public ComponentMovementWatcher { public: - //============================================================================== Pimpl (HWND hwnd, ActiveXControlComponent& owner_) : ComponentMovementWatcher (&owner_), owner (owner_), controlHWND (0), storage (new ActiveXHelpers::JuceIStorage()), clientSite (new ActiveXHelpers::JuceIOleClientSite (hwnd)), - control (nullptr) + control (nullptr), + originalWndProc (0) { } @@ -228,16 +228,25 @@ public: storage->Release(); } + void setControlBounds (const Rectangle& bounds) const + { + if (controlHWND != 0) + MoveWindow (controlHWND, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), TRUE); + } + + void setControlVisible (bool shouldBeVisible) const + { + if (controlHWND != 0) + ShowWindow (controlHWND, shouldBeVisible ? SW_SHOWNA : SW_HIDE); + } + //============================================================================== void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) { Component* const topComp = owner.getTopLevelComponent(); if (topComp->getPeer() != nullptr) - { - const Point pos (topComp->getLocalPoint (&owner, Point())); - owner.setControlBounds (Rectangle (pos.getX(), pos.getY(), owner.getWidth(), owner.getHeight())); - } + setControlBounds (topComp->getLocalArea (&owner, owner.getLocalBounds())); } void componentPeerChanged() @@ -247,7 +256,7 @@ public: void componentVisibilityChanged() { - owner.setControlVisible (owner.isShowing()); + setControlVisible (owner.isShowing()); componentPeerChanged(); } @@ -290,7 +299,7 @@ public: break; } - return CallWindowProc ((WNDPROC) ax->originalWndProc, hwnd, message, wParam, lParam); + return CallWindowProc (ax->control->originalWndProc, hwnd, message, wParam, lParam); } } @@ -305,12 +314,13 @@ public: IStorage* storage; IOleClientSite* clientSite; IOleObject* control; + WNDPROC originalWndProc; + }; //============================================================================== ActiveXControlComponent::ActiveXControlComponent() - : originalWndProc (0), - mouseEventsAllowed (true) + : mouseEventsAllowed (true) { ActiveXHelpers::activeXComps.add (this); } @@ -337,7 +347,7 @@ bool ActiveXControlComponent::createControl (const void* controlIID) if (peer != nullptr) { - const Point pos (getTopLevelComponent()->getLocalPoint (this, Point())); + const Rectangle bounds (getTopLevelComponent()->getLocalArea (this, getLocalBounds())); HWND hwnd = (HWND) peer->getNativeHandle(); ScopedPointer newControl (new Pimpl (hwnd, *this)); @@ -352,21 +362,21 @@ bool ActiveXControlComponent::createControl (const void* controlIID) if (OleSetContainedObject (newControl->control, TRUE) == S_OK) { RECT rect; - rect.left = pos.getX(); - rect.top = pos.getY(); - rect.right = pos.getX() + getWidth(); - rect.bottom = pos.getY() + getHeight(); + rect.left = bounds.getX(); + rect.top = bounds.getY(); + rect.right = bounds.getRight(); + rect.bottom = bounds.getBottom(); if (newControl->control->DoVerb (OLEIVERB_SHOW, 0, newControl->clientSite, 0, hwnd, &rect) == S_OK) { control = newControl; - setControlBounds (Rectangle (pos.getX(), pos.getY(), getWidth(), getHeight())); - control->controlHWND = ActiveXHelpers::getHWND (this); if (control->controlHWND != 0) { - originalWndProc = (void*) (pointer_sized_int) GetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC); + control->setControlBounds (bounds); + + control->originalWndProc = (void*) (pointer_sized_int) GetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC); SetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC, (LONG_PTR) Pimpl::activeXHookWndProc); } @@ -382,7 +392,6 @@ bool ActiveXControlComponent::createControl (const void* controlIID) void ActiveXControlComponent::deleteControl() { control = nullptr; - originalWndProc = 0; } void* ActiveXControlComponent::queryInterface (const void* iid) const @@ -396,18 +405,6 @@ void* ActiveXControlComponent::queryInterface (const void* iid) const return nullptr; } -void ActiveXControlComponent::setControlBounds (const Rectangle& newBounds) const -{ - if (control->controlHWND != 0) - MoveWindow (control->controlHWND, newBounds.getX(), newBounds.getY(), newBounds.getWidth(), newBounds.getHeight(), TRUE); -} - -void ActiveXControlComponent::setControlVisible (const bool shouldBeVisible) const -{ - if (control->controlHWND != 0) - ShowWindow (control->controlHWND, shouldBeVisible ? SW_SHOWNA : SW_HIDE); -} - void ActiveXControlComponent::setMouseEventsAllowed (const bool eventsCanReachControl) { mouseEventsAllowed = eventsCanReachControl;