| 173 | |
| 174 | |
| 175 | bool RemotePlugin::init(const QString &pluginExecutable, |
| 176 | bool waitForInitDoneMsg , QStringList extraArgs) |
| 177 | { |
| 178 | lock(); |
| 179 | if( m_failed ) |
| 180 | { |
| 181 | #ifdef SYNC_WITH_SHM_FIFO |
| 182 | reset( new shmFifo(), new shmFifo() ); |
| 183 | #endif |
| 184 | m_failed = false; |
| 185 | } |
| 186 | QString exec = QFileInfo(QDir("plugins:"), pluginExecutable).absoluteFilePath(); |
| 187 | #ifdef LMMS_BUILD_APPLE |
| 188 | // search current directory first |
| 189 | QString curDir = QCoreApplication::applicationDirPath() + "/" + pluginExecutable; |
| 190 | if( QFile( curDir ).exists() ) |
| 191 | { |
| 192 | exec = curDir; |
| 193 | } |
| 194 | #endif |
| 195 | #ifdef LMMS_BUILD_WIN32 |
| 196 | if( ! exec.endsWith( ".exe", Qt::CaseInsensitive ) ) |
| 197 | { |
| 198 | exec += ".exe"; |
| 199 | } |
| 200 | #endif |
| 201 | |
| 202 | if( ! QFile( exec ).exists() ) |
| 203 | { |
| 204 | qWarning( "Remote plugin '%s' not found.", |
| 205 | exec.toUtf8().constData() ); |
| 206 | m_failed = true; |
| 207 | unlock(); |
| 208 | return failed(); |
| 209 | } |
| 210 | |
| 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 | |
| 216 | QStringList args; |
| 217 | #ifdef SYNC_WITH_SHM_FIFO |
| 218 | // swap in and out for bidirectional communication |
| 219 | args << QString::number( out()->shmKey() ); |
| 220 | args << QString::number( in()->shmKey() ); |
| 221 | #else |
| 222 | args << m_socketFile; |
| 223 | #endif |
| 224 | args << extraArgs; |
| 225 | #ifndef DEBUG_REMOTE_PLUGIN |
| 226 | m_process.setProcessChannelMode( QProcess::ForwardedChannels ); |
| 227 | m_process.setWorkingDirectory( QCoreApplication::applicationDirPath() ); |
| 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 ); |
| 232 | m_watcher.start( QThread::LowestPriority ); |
nothing calls this directly
no test coverage detected