summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-10-10 10:35:40 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-11 16:49:24 +0200
commit686b36a13ca3984879adbe712e86c20c9b4214e3 (patch)
treea0fab8260ea448483dfbbd914375277c0aab7fe6
parenta575626bd20223f7a906162dcfb74963291a1330 (diff)
Fix unit test error in qndefrecord.
The typenameformat signal was not always emitted due to insufficient logic associated with first time initialization of QQmlNdefRecord. This error only happened when the compiler didn't initialize QNdefRecordPrivate::typeNameFormat to 0. Change-Id: Ieba0a1d7c940c40980ff455ca5c1665c298c0527 Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/nfc/qndefrecord_p.h7
-rw-r--r--src/nfc/qqmlndefrecord.cpp19
2 files changed, 12 insertions, 14 deletions
diff --git a/src/nfc/qndefrecord_p.h b/src/nfc/qndefrecord_p.h
index d55c1724..0dfe583a 100644
--- a/src/nfc/qndefrecord_p.h
+++ b/src/nfc/qndefrecord_p.h
@@ -53,8 +53,11 @@ QT_BEGIN_NAMESPACE
class QNdefRecordPrivate : public QSharedData
{
public:
- //bool messageBegin : 1;
- //bool messageEnd : 1;
+ QNdefRecordPrivate() : QSharedData()
+ {
+ typeNameFormat = 0; //TypeNameFormat::Empty
+ }
+
unsigned int typeNameFormat : 3;
QByteArray type;
diff --git a/src/nfc/qqmlndefrecord.cpp b/src/nfc/qqmlndefrecord.cpp
index fd154d74..8a3f24d7 100644
--- a/src/nfc/qqmlndefrecord.cpp
+++ b/src/nfc/qqmlndefrecord.cpp
@@ -294,22 +294,17 @@ void QQmlNdefRecord::setType(const QString &newtype)
}
/*!
- Sets the type name format of the NDEF record to \a typeNameFormat.
+ Sets the type name format of the NDEF record to \a newTypeNameFormat.
*/
-void QQmlNdefRecord::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat typeNameFormat)
+void QQmlNdefRecord::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat newTypeNameFormat)
{
- Q_D(QQmlNdefRecord);
- bool emitChanged = true;
- if (static_cast<QQmlNdefRecord::TypeNameFormat>(d->record.typeNameFormat()) == typeNameFormat) {
- emitChanged = false;
- }
+ if (newTypeNameFormat == typeNameFormat())
+ return;
- //We always have to set the tnf, otherwise we run into problems when tnf is empty. Then
- //the QNdefRecordPrivate is not created
- d->record.setTypeNameFormat(static_cast<QNdefRecord::TypeNameFormat>(typeNameFormat));
+ Q_D(QQmlNdefRecord);
+ d->record.setTypeNameFormat(static_cast<QNdefRecord::TypeNameFormat>(newTypeNameFormat));
- if (emitChanged)
- Q_EMIT(typeNameFormatChanged());
+ emit typeNameFormatChanged();
}
/*!