/* This private slot is used by the launch() functions to close standard input. */ void QProcess::closeStdinLaunch() { disconnect( this, SIGNAL(wroteToStdin()), this, SLOT(closeStdinLaunch()) ); closeStdin(); emit launchFinished(); }
int Q3Process::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: readyReadStdout(); break; case 1: readyReadStderr(); break; case 2: processExited(); break; case 3: wroteToStdin(); break; case 4: launchFinished(); break; case 5: tryTerminate(); break; case 6: kill(); break; case 7: writeToStdin((*reinterpret_cast< const QByteArray(*)>(_a[1]))); break; case 8: writeToStdin((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 9: closeStdin(); break; case 10: socketRead((*reinterpret_cast< int(*)>(_a[1]))); break; case 11: socketWrite((*reinterpret_cast< int(*)>(_a[1]))); break; case 12: timeout(); break; case 13: closeStdinLaunch(); break; } _id -= 14; } return _id; }
/*! \reimp */ void QProcess::connectNotify( const char * signal ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcess::connectNotify(): signal %s has been connected", signal ); #endif if ( !ioRedirection ) if ( qstrcmp( signal, SIGNAL(readyReadStdout()) )==0 || qstrcmp( signal, SIGNAL(readyReadStderr()) )==0 ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcess::connectNotify(): set ioRedirection to TRUE" ); #endif setIoRedirection( TRUE ); return; } if ( !notifyOnExit && qstrcmp( signal, SIGNAL(processExited()) )==0 ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcess::connectNotify(): set notifyOnExit to TRUE" ); #endif setNotifyOnExit( TRUE ); return; } if ( !wroteToStdinConnected && qstrcmp( signal, SIGNAL(wroteToStdin()) )==0 ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcess::connectNotify(): set wroteToStdinConnected to TRUE" ); #endif setWroteStdinConnected( TRUE ); return; } }
bool QProcess::qt_emit( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->signalOffset() ) { case 0: readyReadStdout(); break; case 1: readyReadStderr(); break; case 2: processExited(); break; case 3: wroteToStdin(); break; case 4: launchFinished(); break; default: return QObject::qt_emit(_id,_o); } return TRUE; }
/*! \overload The data \a buf is written to standard input with writeToStdin() using the QString::local8Bit() representation of the strings. */ bool QProcess::launch( const QString& buf, QStringList *env ) { if ( start( env ) ) { if ( !buf.isEmpty() ) { connect( this, SIGNAL(wroteToStdin()), this, SLOT(closeStdinLaunch()) ); writeToStdin( buf ); } else { closeStdin(); emit launchFinished(); } return TRUE; } else { emit launchFinished(); return FALSE; } }
void Q3Process::socketWrite( int ) { DWORD written; while ( !d->stdinBuf.isEmpty() && isRunning() ) { if ( !WriteFile( d->pipeStdin[1], d->stdinBuf.head()->data() + d->stdinBufRead, qMin( 8192, int(d->stdinBuf.head()->size() - d->stdinBufRead) ), &written, 0 ) ) { d->lookup->start( 100 ); return; } d->stdinBufRead += written; if ( d->stdinBufRead == (DWORD)d->stdinBuf.head()->size() ) { d->stdinBufRead = 0; delete d->stdinBuf.dequeue(); if ( wroteToStdinConnected && d->stdinBuf.isEmpty() ) emit wroteToStdin(); } } }
/*! \reimp */ void QProcess::disconnectNotify( const char * ) { if ( ioRedirection && receivers( SIGNAL(readyReadStdout()) ) ==0 && receivers( SIGNAL(readyReadStderr()) ) ==0 ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcess::disconnectNotify(): set ioRedirection to FALSE" ); #endif setIoRedirection( FALSE ); } if ( notifyOnExit && receivers( SIGNAL(processExited()) ) == 0 ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcess::disconnectNotify(): set notifyOnExit to FALSE" ); #endif setNotifyOnExit( FALSE ); } if ( wroteToStdinConnected && receivers( SIGNAL(wroteToStdin()) ) == 0 ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcess::disconnectNotify(): set wroteToStdinConnected to FALSE" ); #endif setWroteStdinConnected( FALSE ); } }
// ------------------------------------------------------------------------ void SimMessage::slotCloseStdin() { SimProcess.closeStdin(); disconnect(&SimProcess, SIGNAL(wroteToStdin()), 0, 0); }
// --------------------------------------------------- // Converts a spice netlist into Qucs format and outputs it. void SimMessage::nextSPICE() { QString Line; for(;;) { // search for next SPICE component Line = *(Collect.begin()); Collect.remove(Collect.begin()); if(Line == "*") { // worked on all components ? startSimulator(); // <<<<<================== go on === return; } if(Line.left(5) == "SPICE") { if(Line.at(5) != 'o') insertSim = true; else insertSim = false; break; } Collect.append(Line); } QString FileName = Line.section('"', 1,1); Line = Line.section('"', 2); // port nodes if(Line.isEmpty()) makeSubcircuit = false; else makeSubcircuit = true; QStringList com; com << (QucsSettings.BinDir + "qucsconv"); if(makeSubcircuit) com << "-g" << "_ref"; com << "-if" << "spice" << "-of" << "qucs"; SimProcess.setArguments(com); QFile SpiceFile; if(FileName.find(QDir::separator()) < 0) // add path ? SpiceFile.setName(QucsWorkDir.path() + QDir::separator() + FileName); else SpiceFile.setName(FileName); if(!SpiceFile.open(IO_ReadOnly)) { ErrText->insert(tr("ERROR: Cannot open SPICE file \"%1\".").arg(FileName)); FinishSimulation(-1); return; } if(makeSubcircuit) { Stream << "\n.Def:" << properName(FileName) << " "; Line.replace(',', ' '); Stream << Line; if(!Line.isEmpty()) Stream << " _ref"; } Stream << "\n"; ProgressText = ""; if(!SimProcess.start()) { ErrText->insert(tr("ERROR: Cannot start QucsConv!")); FinishSimulation(-1); return; } QByteArray SpiceContent = SpiceFile.readAll(); SpiceFile.close(); SimProcess.writeToStdin(SpiceContent); connect(&SimProcess, SIGNAL(wroteToStdin()), SLOT(slotCloseStdin())); }