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

Method run

Engine/ExistenceCheckThread.cpp:106–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void
107ExistenceCheckerThread::run()
108{
109#ifdef DEBUG
110 boost_adaptbx::floating_point::exception_trapping trap(boost_adaptbx::floating_point::exception_trapping::division_by_zero |
111 boost_adaptbx::floating_point::exception_trapping::invalid |
112 boost_adaptbx::floating_point::exception_trapping::overflow);
113#endif
114 _imp->socket.reset( new QLocalSocket() );
115 _imp->socket->connectToServer(_imp->comServerPipePath, QLocalSocket::ReadWrite);
116
117 if ( !_imp->socket->waitForConnected() ) {
118 std::cerr << "Failed to connect local socket to " << _imp->comServerPipePath.toStdString() << std::endl;
119
120 return;
121 }
122
123 for (;; ) {
124 {
125 QMutexLocker k(&_imp->mustQuitMutex);
126 if (_imp->mustQuit) {
127 _imp->mustQuit = false;
128 _imp->mustQuitCond.wakeOne();
129
130 return;
131 }
132 }
133
134
135 //Sleep until we need to check again
136 msleep(NATRON_BREAKPAD_CHECK_FOR_CRASH_REPORTER_EXISTENCE_MS);
137
138
139 qint64 writeOK;
140 {
141 QString tosend(_imp->checkMessage);
142 tosend.push_back( QChar::fromLatin1('\n') );
143 writeOK = _imp->socket->write( tosend.toStdString().c_str() );
144 }
145 if (writeOK >= 0) {
146 _imp->socket->flush();
147
148 bool receivedAcknowledgement = false;
149 while ( _imp->socket->waitForReadyRead(NATRON_BREAKPAD_WAIT_FOR_CRASH_REPORTER_ACK_MS) ) {
150 //we received something, if it's not the ackknowledgement packet, recheck
151 QString str = QString::fromUtf8( _imp->socket->readLine() );
152 while ( str.endsWith( QChar::fromLatin1('\n') ) ) {
153 str.chop(1);
154 }
155 if (str == _imp->acknowledgementMessage) {
156 receivedAcknowledgement = true;
157 break;
158 }
159 }
160
161 if (!receivedAcknowledgement) {
162 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;
163 /*

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