From 2a6a7de04f75daf242ae9d8c99b349ea7dc6ff7f Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 11 Apr 2021 15:24:54 +0100 Subject: [PATCH] Fix main client name for multiple carlas inside NSM Closes #1279 Signed-off-by: falkTX --- source/backend/CarlaBackend.h | 7 ++++++- source/backend/CarlaStandaloneNSM.cpp | 9 +++++++++ source/backend/engine/CarlaEngineJack.cpp | 12 +----------- source/frontend/carla_backend.py | 3 +++ source/frontend/carla_host.py | 6 +++++- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/source/backend/CarlaBackend.h b/source/backend/CarlaBackend.h index fcc30144d..9efbeb6bd 100644 --- a/source/backend/CarlaBackend.h +++ b/source/backend/CarlaBackend.h @@ -1258,7 +1258,12 @@ typedef enum { /*! * Hide-optional-gui message. */ - NSM_CALLBACK_HIDE_OPTIONAL_GUI = 7 + NSM_CALLBACK_HIDE_OPTIONAL_GUI = 7, + + /*! + * Set client name id message. + */ + NSM_CALLBACK_SET_CLIENT_NAME_ID = 8 } NsmCallbackOpcode; diff --git a/source/backend/CarlaStandaloneNSM.cpp b/source/backend/CarlaStandaloneNSM.cpp index 63edbc606..a99e5e0b6 100644 --- a/source/backend/CarlaStandaloneNSM.cpp +++ b/source/backend/CarlaStandaloneNSM.cpp @@ -179,6 +179,9 @@ public: lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/nsm/client/gui_is_hidden", ""); } break; + + case CB::NSM_CALLBACK_SET_CLIENT_NAME_ID: + break; } } @@ -284,6 +287,12 @@ protected: if (gStandalone.engineCallback != nullptr) { fReadyActionOpen = false; + gStandalone.engineCallback(gStandalone.engineCallbackPtr, + CB::ENGINE_CALLBACK_NSM, + 0, + CB::NSM_CALLBACK_SET_CLIENT_NAME_ID, + 0, 0, 0.0f, + clientNameId); gStandalone.engineCallback(gStandalone.engineCallbackPtr, CB::ENGINE_CALLBACK_NSM, 0, diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index a1a1b6530..d04a07f87 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -1456,17 +1456,7 @@ public: if (fClient == nullptr && clientName != nullptr) { -#ifndef BUILD_BRIDGE - if (pData->options.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS && fClientNamePrefix.isNotEmpty()) - { - truncatedClientName = fClientNamePrefix; - truncatedClientName.truncate(truncatedClientName.rfind(".")); - } - else -#endif - { - truncatedClientName = clientName; - } + truncatedClientName = clientName; truncatedClientName.truncate(getMaxClientNameSize()); } diff --git a/source/frontend/carla_backend.py b/source/frontend/carla_backend.py index e0ec4b5b2..14a72b122 100644 --- a/source/frontend/carla_backend.py +++ b/source/frontend/carla_backend.py @@ -897,6 +897,9 @@ NSM_CALLBACK_SHOW_OPTIONAL_GUI = 6 # Hide-optional-gui message. NSM_CALLBACK_HIDE_OPTIONAL_GUI = 7 +# Set client name id message. +NSM_CALLBACK_SET_CLIENT_NAME_ID = 8 + # --------------------------------------------------------------------------------------------------------------------- # Engine Option # Engine options. diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index c90bec31a..25d319fc5 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -2490,7 +2490,6 @@ class HostWindow(QMainWindow): # Open elif opcode == NSM_CALLBACK_OPEN: - self.fClientName = os.path.basename(valueStr) self.fProjectFilename = QFileInfo(valueStr+".carxp").absoluteFilePath() self.setProperWindowTitle() @@ -2514,6 +2513,11 @@ class HostWindow(QMainWindow): elif opcode == NSM_CALLBACK_HIDE_OPTIONAL_GUI: self.hideForNSM() + # Set client name + elif opcode == NSM_CALLBACK_SET_CLIENT_NAME_ID: + self.fClientName = valueStr + return + self.host.nsm_ready(opcode) # --------------------------------------------------------------------------------------------------------