From 5d79ee593dfdfa085d4d8cad6d1ebc0eec5b9734 Mon Sep 17 00:00:00 2001 From: Eric Phister <52085794+amzn-phist@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:53:56 -0500 Subject: [PATCH] Fixes a crash with UI interaction (#1567) When Wwise Gem is not enabled, this will fix a nullptr deref crash when interacting with Audio Controls Editor. Also fixes another issue in the same function where getting the current level name was garbage because a temporary QString was created and immediately destructed. --- .../Source/Editor/AudioControlsEditorWindow.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp index 7625f44a66..abe5a8a58e 100644 --- a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp +++ b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp @@ -290,6 +290,12 @@ namespace AudioControls //-------------------------------------------------------------------------------------------// void CAudioControlsEditorWindow::UpdateAudioSystemData() { + IAudioSystemEditor* audioSystemImpl = CAudioControlsEditorPlugin::GetAudioSystemEditorImpl(); + if (!audioSystemImpl) + { + return; + } + Audio::SAudioRequest oConfigDataRequest; oConfigDataRequest.nFlags = Audio::eARF_PRIORITY_HIGH; @@ -310,17 +316,17 @@ namespace AudioControls oConfigDataRequest.pData = &oParseGlobalRequestData; Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequest, oConfigDataRequest); - //parse the AudioSystem level-specific config data - const char* levelName = GetIEditor()->GetLevelName().toUtf8().data(); + // parse the AudioSystem level-specific config data + AZStd::string levelName{ GetIEditor()->GetLevelName().toUtf8().data() }; AZ::StringFunc::Path::Join(sControlsPath.c_str(), "levels", sControlsPath); - AZ::StringFunc::Path::Join(sControlsPath.c_str(), levelName, sControlsPath); + AZ::StringFunc::Path::Join(sControlsPath.c_str(), levelName.c_str(), sControlsPath); Audio::SAudioManagerRequestData oParseLevelRequestData(sControlsPath.c_str(), Audio::eADS_LEVEL_SPECIFIC); oConfigDataRequest.pData = &oParseLevelRequestData; Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequest, oConfigDataRequest); // inform the middleware specific plugin that the data has been saved // to disk (in case it needs to update something) - CAudioControlsEditorPlugin::GetAudioSystemEditorImpl()->DataSaved(); + audioSystemImpl->DataSaved(); } //-------------------------------------------------------------------------------------------//