From 42b1584cbe0c936cfa0bcd214b0393b0b9a5f2ea Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 29 Jul 2009 17:05:57 +0200 Subject: [PATCH] RemotePlugin: added QSTR_TO_STDSTR macro and use it in LVSL/ZASF QString::toStdString() is not aware of locale specific characters (it just converts to ASCII). Therefore added new macro QSTR_TO_STDSTR which converts a QString to std::string with UTF8 characters. Use this new macro in LMMS VST Support Layer and ZynAddSubFX plugin. This fixes for example VST plugins not being loaded when the path to the DLL contains non-ASCII (e.g. cyrillic) characters. Signed-off-by: Tobias Doerffel (cherry picked from commit f3e13c44275fb7289ebff58ab410778c7d53f2bb) --- include/remote_plugin.h | 2 ++ plugins/vst_base/vst_plugin.cpp | 14 ++++++++------ plugins/zynaddsubfx/zynaddsubfx.cpp | 19 ++++++++++--------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/remote_plugin.h b/include/remote_plugin.h index 6dbfb439a..d6add7ed1 100644 --- a/include/remote_plugin.h +++ b/include/remote_plugin.h @@ -1138,4 +1138,6 @@ void remotePluginClient::doProcessing( void ) #endif +#define QSTR_TO_STDSTR(s) std::string( s.toUtf8().constData() ) + #endif diff --git a/plugins/vst_base/vst_plugin.cpp b/plugins/vst_base/vst_plugin.cpp index 16308530e..f1efb3b4c 100644 --- a/plugins/vst_base/vst_plugin.cpp +++ b/plugins/vst_base/vst_plugin.cpp @@ -111,7 +111,7 @@ vstPlugin::vstPlugin( const QString & _plugin ) : (void) target->winId(); sendMessage( message( IdVstPluginWindowInformation ). - addString( t.toStdString() ) ); + addString( QSTR_TO_STDSTR( t ) ) ); #endif VstHostLanguages hlang = LanguageEnglish; @@ -133,7 +133,7 @@ vstPlugin::vstPlugin( const QString & _plugin ) : p = configManager::inst()->vstDir() + QDir::separator() + p; } - sendMessage( message( IdVstLoadPlugin ).addString( p.toStdString() ) ); + sendMessage( message( IdVstLoadPlugin ).addString( QSTR_TO_STDSTR( p ) ) ); waitForInitDone(); @@ -423,8 +423,9 @@ void vstPlugin::loadChunk( const QByteArray & _chunk ) tf.write( _chunk ); lock(); sendMessage( message( IdLoadSettingsFromFile ). - addString( QDir::toNativeSeparators( - tf.fileName() ).toStdString() ). + addString( + QSTR_TO_STDSTR( + QDir::toNativeSeparators( tf.fileName() ) ) ). addInt( _chunk.size() ) ); waitForMessage( IdLoadSettingsFromFile ); unlock(); @@ -442,8 +443,9 @@ QByteArray vstPlugin::saveChunk( void ) { lock(); sendMessage( message( IdSaveSettingsToFile ). - addString( QDir::toNativeSeparators( - tf.fileName() ).toStdString() ) ); + addString( + QSTR_TO_STDSTR( + QDir::toNativeSeparators( tf.fileName() ) ) ) ); waitForMessage( IdSaveSettingsToFile ); unlock(); a = tf.readAll(); diff --git a/plugins/zynaddsubfx/zynaddsubfx.cpp b/plugins/zynaddsubfx/zynaddsubfx.cpp index 9b952af70..eeac80943 100644 --- a/plugins/zynaddsubfx/zynaddsubfx.cpp +++ b/plugins/zynaddsubfx/zynaddsubfx.cpp @@ -103,8 +103,9 @@ void zynAddSubFx::saveSettings( QDomDocument & _doc, m_plugin->lock(); m_plugin->sendMessage( remotePlugin::message( IdSaveSettingsToFile ). - addString( QDir::toNativeSeparators( - tf.fileName() ).toStdString() ) ); + addString( + QSTR_TO_STDSTR( + QDir::toNativeSeparators( tf.fileName() ) ) ) ); m_plugin->waitForMessage( IdSaveSettingsToFile ); m_plugin->unlock(); QByteArray a = tf.readAll(); @@ -144,8 +145,9 @@ void zynAddSubFx::loadSettings( const QDomElement & _this ) m_plugin->lock(); m_plugin->sendMessage( remotePlugin::message( IdLoadSettingsFromFile ). - addString( QDir::toNativeSeparators( - tf.fileName() ).toStdString() ) ); + addString( + QSTR_TO_STDSTR( + QDir::toNativeSeparators( tf.fileName() ) ) ) ); m_plugin->waitForMessage( IdLoadSettingsFromFile ); m_plugin->unlock(); @@ -161,7 +163,7 @@ void zynAddSubFx::loadFile( const QString & _file ) m_plugin->lock(); m_plugin->sendMessage( remotePlugin::message( IdLoadPresetFromFile ). - addString( _file.toStdString() ) ); + QSTR_TO_STD_STR( _file ) ); m_plugin->waitForMessage( IdLoadPresetFromFile ); m_plugin->unlock(); @@ -230,10 +232,9 @@ void zynAddSubFx::initRemotePlugin( void ) m_plugin->sendMessage( remotePlugin::message( IdZasfPresetDirectory ). - addString( - ( configManager::inst()->factoryPresetsDir() + - QDir::separator() + "ZynAddSubFX" ). - toStdString() ) ); + addString( + QSTR_TO_STDSTR( configManager::inst()->factoryPresetsDir() + + QDir::separator() + "ZynAddSubFX" ) ) ); m_plugin->unlock(); }