diff --git a/OSC/Source/OSC/Private/OscSettings.cpp b/OSC/Source/OSC/Private/OscSettings.cpp index bc14df7..03e65bb 100644 --- a/OSC/Source/OSC/Private/OscSettings.cpp +++ b/OSC/Source/OSC/Private/OscSettings.cpp @@ -161,7 +161,7 @@ void UOscSettings::ClearKeyInputs(UOscDispatcher & dispatcher) { // Unregister here, not in the OscReceiverInputKey destructor // because it would crash at the application exit. - dispatcher.UnregisterReceiver(&receiver); + dispatcher.UnregisterReceiver(receiver.get()); } _keyReceivers.Reset(0); } @@ -171,7 +171,8 @@ void UOscSettings::UpdateKeyInputs(UOscDispatcher & dispatcher) ClearKeyInputs(dispatcher); for(const auto & address : Inputs) { - _keyReceivers.Emplace(address); - dispatcher.RegisterReceiver(&_keyReceivers.Last()); + auto receiver = std::make_unique(address); + dispatcher.RegisterReceiver(receiver.get()); + _keyReceivers.Add(std::move(receiver)); } } diff --git a/OSC/Source/OSC/Private/OscSettings.h b/OSC/Source/OSC/Private/OscSettings.h index b6b89d0..95ce3ee 100644 --- a/OSC/Source/OSC/Private/OscSettings.h +++ b/OSC/Source/OSC/Private/OscSettings.h @@ -73,5 +73,5 @@ private: TSharedRef _sendSocket; TArray> _sendAddresses; TMap _sendAddressesIndex; - TArray _keyReceivers; + TArray> _keyReceivers; }; diff --git a/OSC/Source/OSC/Private/Receive/OscReceiverInterface.h b/OSC/Source/OSC/Private/Receive/OscReceiverInterface.h index 0901967..0a21ab1 100644 --- a/OSC/Source/OSC/Private/Receive/OscReceiverInterface.h +++ b/OSC/Source/OSC/Private/Receive/OscReceiverInterface.h @@ -6,6 +6,7 @@ /// Base class to receive OSC messages. struct IOscReceiverInterface { + virtual ~IOscReceiverInterface() {} virtual const FString & GetAddressFilter() const = 0; virtual void SendEvent(const FName & Address, const TArray & Data, const FString & SenderIp) = 0; };