MCPcopy Create free account
hub / github.com/MrKepzie/Natron / run

Method run

Engine/ExistenceCheckThread.cpp:102–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void
103ExistenceCheckerThread::run()
104{
105 _imp->socket.reset( new QLocalSocket() );
106 _imp->socket->connectToServer(_imp->comServerPipePath, QLocalSocket::ReadWrite);
107
108 if ( !_imp->socket->waitForConnected() ) {
109 std::cerr << "Failed to connect local socket to " << _imp->comServerPipePath.toStdString() << std::endl;
110
111 return;
112 }
113
114 for (;; ) {
115 {
116 QMutexLocker k(&_imp->mustQuitMutex);
117 if (_imp->mustQuit) {
118 _imp->mustQuit = false;
119 _imp->mustQuitCond.wakeOne();
120
121 return;
122 }
123 }
124
125
126 //Sleep until we need to check again
127 msleep(NATRON_BREAKPAD_CHECK_FOR_CRASH_REPORTER_EXISTENCE_MS);
128
129
130 qint64 writeOK;
131 {
132 QString tosend(_imp->checkMessage);
133 tosend.push_back( QChar::fromLatin1('\n') );
134 writeOK = _imp->socket->write( tosend.toStdString().c_str() );
135 }
136 if (writeOK >= 0) {
137 _imp->socket->flush();
138
139 bool receivedAcknowledgement = false;
140 while ( _imp->socket->waitForReadyRead(NATRON_BREAKPAD_WAIT_FOR_CRASH_REPORTER_ACK_MS) ) {
141 //we received something, if it's not the ackknowledgement packet, recheck
142 QString str = QString::fromUtf8( _imp->socket->readLine() );
143 while ( str.endsWith( QChar::fromLatin1('\n') ) ) {
144 str.chop(1);
145 }
146 if (str == _imp->acknowledgementMessage) {
147 receivedAcknowledgement = true;
148 break;
149 }
150 }
151
152 if (!receivedAcknowledgement) {
153 std::cerr << tr("Crash reporter process does not seem to be responding anymore. This pipe %1 might be used somewhere else.").arg(_imp->comServerPipePath).toStdString() << std::endl;
154 /*
155 We did not receive te acknowledgement, hence quit
156 */
157 Q_EMIT otherProcessUnreachable();
158
159 return;

Callers

nothing calls this directly

Calls 5

toStdStringMethod · 0.80
resetMethod · 0.45
push_backMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected