Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions deflect/ImageSegmenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,25 @@ bool ImageSegmenter::_generateJpeg(const ImageWrapper& image,
// Note: Qt insists that sending (by calling handler()) should happen
// exclusively from the QThread where the socket lives. Sending from the
// worker threads triggers a qWarning.
bool result = true;
for (size_t i = 0; i < segments.size(); ++i)
if (!handler(_sendQueue.dequeue()))
result = false;
return result;
size_t i = 0;
try
{
bool result = true;
for (; i < segments.size(); ++i)
if (!handler(_sendQueue.dequeue()))
result = false;
return result;
}
catch (...)
{
// Wait for remaining threaded operations to finish, without calling the
// handler. Otherwise the remaining threads may wait forever leading to
// a deadlock in QApplication destructor.
++i;
for (; i < segments.size(); ++i)
_sendQueue.dequeue();
std::rethrow_exception(std::current_exception());
}
#else
static bool first = true;
if (first)
Expand Down