| 1118 | |
| 1119 | |
| 1120 | RemotePluginBase::message RemotePluginBase::waitForMessage( |
| 1121 | const message & _wm, |
| 1122 | bool _busy_waiting ) |
| 1123 | { |
| 1124 | #ifndef BUILD_REMOTE_PLUGIN_CLIENT |
| 1125 | if( _busy_waiting ) |
| 1126 | { |
| 1127 | // No point processing events outside of the main thread |
| 1128 | _busy_waiting = QThread::currentThread() == |
| 1129 | QCoreApplication::instance()->thread(); |
| 1130 | } |
| 1131 | |
| 1132 | struct WaitDepthCounter |
| 1133 | { |
| 1134 | WaitDepthCounter( int & depth, bool busy ) : |
| 1135 | m_depth( depth ), |
| 1136 | m_busy( busy ) |
| 1137 | { |
| 1138 | if( m_busy ) { ++m_depth; } |
| 1139 | } |
| 1140 | |
| 1141 | ~WaitDepthCounter() |
| 1142 | { |
| 1143 | if( m_busy ) { --m_depth; } |
| 1144 | } |
| 1145 | |
| 1146 | int & m_depth; |
| 1147 | bool m_busy; |
| 1148 | }; |
| 1149 | |
| 1150 | WaitDepthCounter wdc( waitDepthCounter(), _busy_waiting ); |
| 1151 | #endif |
| 1152 | while( !isInvalid() ) |
| 1153 | { |
| 1154 | #ifndef BUILD_REMOTE_PLUGIN_CLIENT |
| 1155 | if( _busy_waiting && !messagesLeft() ) |
| 1156 | { |
| 1157 | QCoreApplication::processEvents( |
| 1158 | QEventLoop::ExcludeUserInputEvents, 50 ); |
| 1159 | continue; |
| 1160 | } |
| 1161 | #endif |
| 1162 | message m = receiveMessage(); |
| 1163 | processMessage( m ); |
| 1164 | if( m.id == _wm.id ) |
| 1165 | { |
| 1166 | return m; |
| 1167 | } |
| 1168 | else if( m.id == IdUndefined ) |
| 1169 | { |
| 1170 | return m; |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | return message(); |
| 1175 | } |
| 1176 | |
| 1177 |
no test coverage detected