MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / onDataWrittenToSocket

Method onDataWrittenToSocket

Engine/ProcessHandler.cpp:158–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void
159ProcessHandler::onDataWrittenToSocket()
160{
161 ///always running in the main thread
162 assert( QThread::currentThread() == qApp->thread() );
163
164 QString str = QString::fromUtf8( _bgProcessOutputSocket->readLine() );
165 while ( str.endsWith( QLatin1Char('\n') ) ) {
166 str.chop(1);
167 }
168 _processLog.append( QString::fromUtf8("Message received: ") + str + QLatin1Char('\n') );
169 if ( str.startsWith( QString::fromUtf8(kFrameRenderedStringShort) ) ) {
170 str = str.remove( QString::fromUtf8(kFrameRenderedStringShort) );
171
172 double progressPercent = 0.;
173 int foundProgress = str.lastIndexOf( QString::fromUtf8(kProgressChangedStringShort) );
174 if (foundProgress != -1) {
175 QString progressStr = str.mid(foundProgress);
176 progressStr.remove( QString::fromUtf8(kProgressChangedStringShort) );
177 progressPercent = progressStr.toDouble();
178 str = str.mid(0, foundProgress);
179 }
180 if ( !str.isEmpty() ) {
181 //The report does not have extended timer infos
182 Q_EMIT frameRendered(str.toInt(), progressPercent);
183 }
184 } else if ( str.startsWith( QString::fromUtf8(kRenderingFinishedStringShort) ) ) {
185 ///don't do anything
186 } else if ( str.startsWith( QString::fromUtf8(kBgProcessServerCreatedShort) ) ) {
187 str = str.remove( QString::fromUtf8(kBgProcessServerCreatedShort) );
188 ///the bg process wants us to create the pipe for its input
189 if (!_bgProcessInputSocket) {
190 _bgProcessInputSocket = new QLocalSocket();
191 QObject::connect( _bgProcessInputSocket, SIGNAL(connected()), this, SLOT(onInputPipeConnectionMade()) );
192 _bgProcessInputSocket->connectToServer(str, QLocalSocket::ReadWrite);
193 }
194 } else if ( str.startsWith( QString::fromUtf8(kRenderingStartedShort) ) ) {
195 ///if the user pressed cancel prior to the pipe being created, wait for it to be created and send the abort
196 ///message right away
197 if (_earlyCancel) {
198 _bgProcessInputSocket->waitForConnected(5000);
199 _earlyCancel = false;
200 onProcessCanceled();
201 }
202 } else {
203 _processLog.append( QString::fromUtf8("Error: Unable to interpret message.\n") );
204 throw std::runtime_error("ProcessHandler::onDataWrittenToSocket() received erroneous message");
205 }
206}
207
208void
209ProcessHandler::onInputPipeConnectionMade()

Callers

nothing calls this directly

Calls 3

appendMethod · 0.80
removeMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected