@@ -54,7 +54,10 @@ ProcessWatcher::ProcessWatcher( RemotePlugin * _p ) :
5454
5555void 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
128136RemotePlugin::~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