Skip to content

Commit 9c9290e

Browse files
DomClarkzonkmachine
authored andcommitted
Support more than 62 simultaneous VST plugins for Qt<5.10
1 parent 614bca7 commit 9c9290e

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

include/RemotePlugin.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,9 +755,15 @@ class ProcessWatcher : public QThread
755755
}
756756

757757

758-
void quit()
758+
void stop()
759759
{
760760
m_quit = true;
761+
quit();
762+
}
763+
764+
void reset()
765+
{
766+
m_quit = false;
761767
}
762768

763769
private:
@@ -864,6 +870,9 @@ public slots:
864870
QProcess m_process;
865871
ProcessWatcher m_watcher;
866872

873+
QString m_exec;
874+
QStringList m_args;
875+
867876
QMutex m_commMutex;
868877
bool m_splitChannels;
869878
#ifdef USE_QT_SHMEM

src/core/RemotePlugin.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ ProcessWatcher::ProcessWatcher( RemotePlugin * _p ) :
5454

5555
void ProcessWatcher::run()
5656
{
57-
while( !m_quit && m_plugin->isRunning() )
57+
m_plugin->m_process.start( m_plugin->m_exec, m_plugin->m_args );
58+
exec();
59+
m_plugin->m_process.moveToThread( m_plugin->thread() );
60+
while( !m_quit && m_plugin->messagesLeft() )
5861
{
5962
msleep( 200 );
6063
}
@@ -120,14 +123,19 @@ RemotePlugin::RemotePlugin() :
120123
qWarning( "Unable to start the server." );
121124
}
122125
#endif
126+
connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
127+
this, SLOT( processFinished( int, QProcess::ExitStatus ) ),
128+
Qt::DirectConnection );
129+
connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
130+
&m_watcher, SLOT( quit() ), Qt::DirectConnection );
123131
}
124132

125133

126134

127135

128136
RemotePlugin::~RemotePlugin()
129137
{
130-
m_watcher.quit();
138+
m_watcher.stop();
131139
m_watcher.wait();
132140

133141
if( m_failed == false )
@@ -200,6 +208,11 @@ bool RemotePlugin::init(const QString &pluginExecutable,
200208
return failed();
201209
}
202210

211+
// ensure the watcher is ready in case we're running again
212+
// (e.g. 32-bit VST plugins on Windows)
213+
m_watcher.wait();
214+
m_watcher.reset();
215+
203216
QStringList args;
204217
#ifdef SYNC_WITH_SHM_FIFO
205218
// swap in and out for bidirectional communication
@@ -212,15 +225,15 @@ bool RemotePlugin::init(const QString &pluginExecutable,
212225
#ifndef DEBUG_REMOTE_PLUGIN
213226
m_process.setProcessChannelMode( QProcess::ForwardedChannels );
214227
m_process.setWorkingDirectory( QCoreApplication::applicationDirPath() );
215-
m_process.start( exec, args );
228+
m_exec = exec;
229+
m_args = args;
230+
// we start the process on the watcher thread to work around QTBUG-8819
231+
m_process.moveToThread( &m_watcher );
216232
m_watcher.start( QThread::LowestPriority );
217233
#else
218234
qDebug() << exec << args;
219235
#endif
220236

221-
connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
222-
this, SLOT( processFinished( int, QProcess::ExitStatus ) ) );
223-
224237
#ifndef SYNC_WITH_SHM_FIFO
225238
struct pollfd pollin;
226239
pollin.fd = m_server;

0 commit comments

Comments
 (0)