From f24f7b638c15ab2770f67c53484480eeac662bab Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 19 Nov 2012 23:29:39 +0000 Subject: [PATCH] Modal component fix. Minor tweaks. --- .../format_types/juce_VSTPluginFormat.cpp | 5 +-- .../juce_InterprocessConnection.cpp | 12 +++--- .../components/juce_ModalComponentManager.cpp | 39 +++++++++---------- .../opengl/juce_OpenGLGraphicsContext.cpp | 3 +- .../juce_opengl/opengl/juce_OpenGLHelpers.cpp | 4 +- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 60d076af3a..c01b38d4e0 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -2254,11 +2254,10 @@ private: #pragma warning (pop) - int w, h; RECT r; GetWindowRect (pluginHWND, &r); - w = r.right - r.left; - h = r.bottom - r.top; + int w = r.right - r.left; + int h = r.bottom - r.top; if (rect != nullptr) { diff --git a/modules/juce_events/interprocess/juce_InterprocessConnection.cpp b/modules/juce_events/interprocess/juce_InterprocessConnection.cpp index 5ed60090ff..0d9d9597a8 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnection.cpp +++ b/modules/juce_events/interprocess/juce_InterprocessConnection.cpp @@ -129,10 +129,9 @@ bool InterprocessConnection::isConnected() const String InterprocessConnection::getConnectedHostName() const { if (pipe != nullptr) - { return "localhost"; - } - else if (socket != nullptr) + + if (socket != nullptr) { if (! socket->isLocal()) return socket->getHostName(); @@ -236,14 +235,13 @@ void InterprocessConnection::connectionLostInt() struct DataDeliveryMessage : public Message { - DataDeliveryMessage (InterprocessConnection* owner_, const MemoryBlock& data_) - : owner (owner_), data (data_) + DataDeliveryMessage (InterprocessConnection* ipc, const MemoryBlock& d) + : owner (ipc), data (d) {} void messageCallback() { - InterprocessConnection* const ipc = owner; - if (ipc != nullptr) + if (InterprocessConnection* const ipc = owner) ipc->messageReceived (data); } diff --git a/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp b/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp index 923e1446cb..c7e0ad2bd5 100644 --- a/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp +++ b/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp @@ -236,7 +236,7 @@ void ModalComponentManager::bringModalComponentsToFront (bool topOneShouldGrabFo class ModalComponentManager::ReturnValueRetriever : public ModalComponentManager::Callback { public: - ReturnValueRetriever (int& value_, bool& finished_) : value (value_), finished (finished_) {} + ReturnValueRetriever (int& v, bool& done) : value (v), finished (done) {} void modalStateFinished (int returnValue) { @@ -256,29 +256,28 @@ int ModalComponentManager::runEventLoopForCurrentComponent() // This can only be run from the message thread! jassert (MessageManager::getInstance()->isThisTheMessageThread()); - Component* currentlyModal = getModalComponent (0); - - if (currentlyModal == nullptr) - return 0; - - WeakReference prevFocused (Component::getCurrentlyFocusedComponent()); - int returnValue = 0; - bool finished = false; - attachCallback (currentlyModal, new ReturnValueRetriever (returnValue, finished)); - JUCE_TRY + if (Component* currentlyModal = getModalComponent (0)) { - while (! finished) - { - if (! MessageManager::getInstance()->runDispatchLoopUntil (20)) - break; - } - } - JUCE_CATCH_EXCEPTION + WeakReference prevFocused (Component::getCurrentlyFocusedComponent()); - if (prevFocused != nullptr) - prevFocused->grabKeyboardFocus(); + bool finished = false; + attachCallback (currentlyModal, new ReturnValueRetriever (returnValue, finished)); + + JUCE_TRY + { + while (! finished) + { + if (! MessageManager::getInstance()->runDispatchLoopUntil (20)) + break; + } + } + JUCE_CATCH_EXCEPTION + + if (prevFocused != nullptr && ! prevFocused->isCurrentlyBlockedByAnotherModalComponent()) + prevFocused->grabKeyboardFocus(); + } return returnValue; } diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 217c0fb39e..a5610976c4 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -1041,10 +1041,11 @@ struct StateHelpers { context.extensions.glBufferData (GL_ARRAY_BUFFER, numVertices * sizeof (VertexInfo), vertexData, GL_DYNAMIC_DRAW); glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, 0); + JUCE_CHECK_OPENGL_ERROR numVertices = 0; } - ShaderQuadQueue& operator= (const ShaderQuadQueue&); + JUCE_DECLARE_NON_COPYABLE (ShaderQuadQueue); }; //============================================================================== diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp index e17d218d8a..f6b1e706e4 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp @@ -261,9 +261,7 @@ OpenGLTextureFromImage::OpenGLTextureFromImage (const Image& image) imageHeight (image.getHeight()) { JUCE_CHECK_OPENGL_ERROR - OpenGLFrameBuffer* const fb = OpenGLImageType::getFrameBufferFrom (image); - - if (fb != nullptr) + if (OpenGLFrameBuffer* const fb = OpenGLImageType::getFrameBufferFrom (image)) { textureID = fb->getTextureID(); fullWidthProportion = 1.0f;