diff --git a/src/vizdoom/src/viz_message_queue.cpp b/src/vizdoom/src/viz_message_queue.cpp index 8cba35f4d..bf8907e34 100644 --- a/src/vizdoom/src/viz_message_queue.cpp +++ b/src/vizdoom/src/viz_message_queue.cpp @@ -68,12 +68,19 @@ void VIZ_MQSend(uint8_t code, const char * command){ } void VIZ_MQReceive(void *msg) { - size_t size; - unsigned int priority; + if(vizMQDoom) { + size_t size; + unsigned int priority; - if(vizMQDoom) vizMQDoom->receive(msg, sizeof(VIZMessage), size, priority); + try{ + vizMQDoom->receive(msg, sizeof(VIZMessage), size, priority); + } + catch(...){ // bip::interprocess_exception + VIZ_Error(VIZ_FUNC, "Failed to receive message."); + } - VIZ_DebugMsg(4, VIZ_FUNC, "Received msg: %d.", static_cast(msg)->code); + VIZ_DebugMsg(4, VIZ_FUNC, "Received msg: %d.", static_cast(msg)->code); + } } bool VIZ_MQTryReceive(void *msg){