diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 0bee55f76e..16b6be0940 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -2582,7 +2582,7 @@ void VSTPluginInstance::updateStoredProgramNames() { if (effect != nullptr && getNumPrograms() > 0) { - char nm [256] = { 0 }; + char nm[256] = { 0 }; // only do this if the plugin can't use indexed names.. if (dispatch (effGetProgramNameIndexed, 0, -1, nm, 0) == 0) @@ -2605,24 +2605,28 @@ void VSTPluginInstance::updateStoredProgramNames() const String VSTPluginInstance::getCurrentProgramName() { + String name; + if (effect != nullptr) { - char nm [256] = { 0 }; - dispatch (effGetProgramName, 0, 0, nm, 0); + { + char nm[256] = { 0 }; + dispatch (effGetProgramName, 0, 0, nm, 0); + name = String (CharPointer_UTF8 (nm)).trim(); + } const int index = getCurrentProgram(); + if (programNames[index].isEmpty()) { while (programNames.size() < index) programNames.add (String::empty); - programNames.set (index, String (nm).trim()); + programNames.set (index, name); } - - return String (nm).trim(); } - return String::empty; + return name; } //==============================================================================