OOps
This commit is contained in:
parent
ebb99beeff
commit
3a388aa43e
@ -16,6 +16,7 @@ void Worker::queue(WorkerContext *context) {
|
|||||||
_WorkerContext *c = new _WorkerContext;
|
_WorkerContext *c = new _WorkerContext;
|
||||||
c->image = context->pixmap.toImage();
|
c->image = context->pixmap.toImage();
|
||||||
c->consumer = context->consumer;
|
c->consumer = context->consumer;
|
||||||
|
c->targetFormat = context->targetFormat;
|
||||||
qqueue.enqueue(c);
|
qqueue.enqueue(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ Worker::Worker() : QObject() {
|
|||||||
|
|
||||||
Worker::~Worker() {
|
Worker::~Worker() {
|
||||||
end();
|
end();
|
||||||
|
thread()->wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::end() {
|
void Worker::end() {
|
||||||
@ -54,7 +56,7 @@ void Worker::process() {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
if (!qqueue.isEmpty()) {
|
if (!qqueue.isEmpty()) {
|
||||||
_WorkerContext *c = qqueue.dequeue();
|
_WorkerContext *c = qqueue.dequeue();
|
||||||
c->consumer(c->image.convertToFormat(context->targetFormat));
|
c->consumer(c->image.convertToFormat(c->targetFormat));
|
||||||
}
|
}
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // STL likes it's scopes
|
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // STL likes it's scopes
|
||||||
|
@ -17,6 +17,7 @@ struct WorkerContext {
|
|||||||
|
|
||||||
struct _WorkerContext {
|
struct _WorkerContext {
|
||||||
QImage image;
|
QImage image;
|
||||||
|
QImage::Format targetFormat;
|
||||||
std::function<void(QImage)> consumer;
|
std::function<void(QImage)> consumer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user