From f990723d6ff6dca124300c85329a69f79084a8d6 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 30 Oct 2017 15:00:34 +0000 Subject: [PATCH] Added a Visual Studio compiler bug workaround --- examples/audio plugin host/Source/GraphEditorPanel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/audio plugin host/Source/GraphEditorPanel.cpp b/examples/audio plugin host/Source/GraphEditorPanel.cpp index 7ed59e5526..5d4d05e588 100644 --- a/examples/audio plugin host/Source/GraphEditorPanel.cpp +++ b/examples/audio plugin host/Source/GraphEditorPanel.cpp @@ -600,8 +600,14 @@ GraphEditorPanel::ConnectorComponent* GraphEditorPanel::getComponentForConnectio GraphEditorPanel::PinComponent* GraphEditorPanel::findPinAt (Point pos) const { for (auto* fc : nodes) - if (auto* pin = dynamic_cast (fc->getComponentAt (pos.toInt() - fc->getPosition()))) + { + // NB: A Visual Studio optimiser error means we have to put this Component* in a local + // variable before trying to cast it, or it gets mysteriously optimised away.. + auto* comp = fc->getComponentAt (pos.toInt() - fc->getPosition()); + + if (auto* pin = dynamic_cast (comp)) return pin; + } return nullptr; }