diff --git a/include/ConfigManager.h b/include/ConfigManager.h index ad3a12373dd..3e5c0578f0b 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -32,9 +32,9 @@ #include #include #include +#include #include "export.h" -#include "MemoryManager.h" class LmmsCore; @@ -51,9 +51,9 @@ const QString TRACK_ICON_PATH = "track_icons/"; const QString LOCALE_PATH = "locale/"; -class EXPORT ConfigManager +class EXPORT ConfigManager : public QObject { - MM_OPERATORS + Q_OBJECT public: static inline ConfigManager * inst() { @@ -244,6 +244,8 @@ class EXPORT ConfigManager // creates the working directory & subdirectories on disk. void createWorkingDir(); +signals: + void valueChanged( QString cls, QString attribute, QString value ); private: static ConfigManager * s_instanceOfMe; diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 4fa3bd4e988..211b363a91a 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -32,6 +32,7 @@ #include #include +#include "ConfigManager.h" #include "BufferManager.h" #include "Engine.h" #include "gui_templates.h" @@ -89,6 +90,10 @@ vestigeInstrument::vestigeInstrument( InstrumentTrack * _instrument_track ) : // now we need a play-handle which cares for calling play() InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); Engine::mixer()->addPlayHandle( iph ); + + connect( ConfigManager::inst(), SIGNAL( valueChanged(QString,QString,QString) ), + this, SLOT( handleConfigChange(QString, QString, QString) ), + Qt::QueuedConnection ); } @@ -170,6 +175,20 @@ void vestigeInstrument::setParameter( void ) } } +void vestigeInstrument::handleConfigChange(QString cls, QString attr, QString value) +{ + if ( cls == "ui" && attr == "vstembedmethod" ) + { + reloadPlugin(); + } +} + +void vestigeInstrument::reloadPlugin() +{ + closePlugin(); + loadFile( m_pluginDLL ); +} + @@ -366,10 +385,6 @@ void vestigeInstrument::closePlugin( void ) } m_pluginMutex.lock(); - if( m_plugin ) - { - delete m_plugin->pluginWidget(); - } delete m_plugin; m_plugin = NULL; m_pluginMutex.unlock(); diff --git a/plugins/vestige/vestige.h b/plugins/vestige/vestige.h index 5faa606c236..df076bbb9cb 100644 --- a/plugins/vestige/vestige.h +++ b/plugins/vestige/vestige.h @@ -74,6 +74,8 @@ class vestigeInstrument : public Instrument protected slots: void setParameter( void ); + void handleConfigChange( QString cls, QString attr, QString value ); + void reloadPlugin(); private: void closePlugin( void ); diff --git a/plugins/vst_base/VstPlugin.cpp b/plugins/vst_base/VstPlugin.cpp index 2b1cbcd0969..8b514770809 100644 --- a/plugins/vst_base/VstPlugin.cpp +++ b/plugins/vst_base/VstPlugin.cpp @@ -587,9 +587,9 @@ void VstPlugin::showUI() void VstPlugin::hideUI() { - RemotePlugin::hideUI(); if ( m_embedMethod == "none" ) { + RemotePlugin::hideUI(); } else if ( pluginWidget() != nullptr ) { diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 1fb8be187b1..734c39c1f0f 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -352,12 +352,15 @@ void ConfigManager::setValue( const QString & cls, { if( m_settings.contains( cls ) ) { - for( stringPairVector::iterator it = m_settings[cls].begin(); - it != m_settings[cls].end(); ++it ) + for( QPair& pair : m_settings[cls]) { - if( ( *it ).first == attribute ) + if( pair.first == attribute ) { - ( *it ).second = value; + if ( pair.second != value ) + { + pair.second = value; + emit valueChanged( cls, attribute, value ); + } return; } } diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index 78b9c0d2351..0d5f2c454a5 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -1019,6 +1019,20 @@ SetupDialog::~SetupDialog() void SetupDialog::accept() { + if( m_warnAfterSetup ) + { + QMessageBox::information( NULL, tr( "Restart LMMS" ), + tr( "Please note that most changes " + "won't take effect until " + "you restart LMMS!" ), + QMessageBox::Ok ); + } + + // Hide dialog before setting values. This prevents an obscure bug + // where non-embedded VST windows would steal focus and prevent LMMS + // from taking mouse input, rendering the application unusable. + QDialog::accept(); + ConfigManager::inst()->setValue( "mixer", "framesperaudiobuffer", QString::number( m_bufferSize ) ); ConfigManager::inst()->setValue( "mixer", "audiodev", @@ -1094,16 +1108,6 @@ void SetupDialog::accept() } ConfigManager::inst()->saveConfigFile(); - - QDialog::accept(); - if( m_warnAfterSetup ) - { - QMessageBox::information( NULL, tr( "Restart LMMS" ), - tr( "Please note that most changes " - "won't take effect until " - "you restart LMMS!" ), - QMessageBox::Ok ); - } }