From 1bae4983861d779458642dd08feaf946d876e18d Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Tue, 17 Jan 2017 13:37:20 +0200 Subject: [PATCH] properly fix compile issue by forward declaring QZXing in QZXingFilter. Had to make decoder variable as pointer in order to avoid the compiler requirement to known the exact size of the class...that had to be forward declared. Properly addresses issue #16 --- src/QZXingFilter.cpp | 27 +++++++++++++++++++-------- src/QZXingFilter.h | 14 +++++++++----- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/QZXingFilter.cpp b/src/QZXingFilter.cpp index 31ca5a9..0685d21 100644 --- a/src/QZXingFilter.cpp +++ b/src/QZXingFilter.cpp @@ -1,5 +1,6 @@ #include "QZXingFilter.h" +#include #include #include @@ -29,9 +30,9 @@ QZXingFilter::QZXingFilter(QObject *parent) , decoding(false) { /// Conecting signals to handlers that will send signals to QML - connect(&decoder, &QZXing::decodingStarted, + connect(decoder_p, &QZXing::decodingStarted, this, &QZXingFilter::handleDecodingStarted); - connect(&decoder, &QZXing::decodingFinished, + connect(decoder_p, &QZXing::decodingFinished, this, &QZXingFilter::handleDecodingFinished); } @@ -40,6 +41,16 @@ QZXingFilter::~QZXingFilter() } +bool QZXingFilter::isDecoding() +{ + return decoding; +} + +QZXing *QZXingFilter::getDecoder() +{ + return decoder_p; +} + void QZXingFilter::handleDecodingStarted() { decoding = true; @@ -50,7 +61,7 @@ void QZXingFilter::handleDecodingStarted() void QZXingFilter::handleDecodingFinished(bool succeeded) { decoding = false; - emit decodingFinished(succeeded, decoder.getProcessTimeOfLastDecoding()); + emit decodingFinished(succeeded, decoder_p->getProcessTimeOfLastDecoding()); emit isDecodingChanged(); } @@ -248,22 +259,22 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame // const QString path = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + "/qrtest/test_" + QString::number(i % 100) + ".png"; // qDebug() << "saving image" << i << "at:" << path << image.save(path); - QString tag = filter->decoder.decodeImage(image, image.width(), image.height()); + QString tag = filter->decoder_p->decodeImage(image, image.width(), image.height()); - const bool tryHarder = filter->decoder.getTryHarder(); + const bool tryHarder = filter->decoder_p->getTryHarder(); /// The frames we get from the camera may be reflected horizontally or vertically /// As the decoder can't handle reflected frames, we swap them in all possible frames, changing the swap mode each frame. /// TODO: Maybe there is a better way to know this orientation beforehand? Or should we try decoding all of them? if (tag.isEmpty() && tryHarder) { image = image.mirrored(true, false); - tag = filter->decoder.decodeImage(image, image.width(), image.height()); + tag = filter->decoder_p->decodeImage(image, image.width(), image.height()); } if (tag.isEmpty() && tryHarder) { image = image.mirrored(false, true); - tag = filter->decoder.decodeImage(image, image.width(), image.height()); + tag = filter->decoder_p->decodeImage(image, image.width(), image.height()); } if (tag.isEmpty() && tryHarder) { image = image.mirrored(true, true); - tag = filter->decoder.decodeImage(image, image.width(), image.height()); + tag = filter->decoder_p->decodeImage(image, image.width(), image.height()); } } diff --git a/src/QZXingFilter.h b/src/QZXingFilter.h index 798ad25..57e87df 100644 --- a/src/QZXingFilter.h +++ b/src/QZXingFilter.h @@ -3,7 +3,9 @@ #include #include -#include + +//forward declaration +class QZXing; /// /// References: @@ -59,7 +61,7 @@ class QZXingFilter : public QAbstractVideoFilter Q_OBJECT Q_PROPERTY(bool decoding READ isDecoding NOTIFY isDecodingChanged) - Q_PROPERTY(QZXing* decoder READ getDecoder) + Q_PROPERTY(QZXing* decoder_p READ getDecoder) Q_PROPERTY(QRectF captureRect MEMBER captureRect NOTIFY captureRectChanged) signals: @@ -73,7 +75,7 @@ class QZXingFilter : public QAbstractVideoFilter void handleDecodingFinished(bool succeeded); private: /// Attributes - QZXing decoder; + QZXing* decoder_p; bool decoding; QRectF captureRect; @@ -84,8 +86,10 @@ class QZXingFilter : public QAbstractVideoFilter explicit QZXingFilter(QObject *parent = 0); virtual ~QZXingFilter(); - bool isDecoding() {return decoding; } - QZXing* getDecoder() { return &decoder; } + bool isDecoding(); + QZXing* getDecoder(); +// bool isDecoding() {return decoding; } +// QZXing* getDecoder() { return &decoder; } QVideoFilterRunnable * createFilterRunnable(); };