From 686b36a13ca3984879adbe712e86c20c9b4214e3 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 10 Oct 2013 10:35:40 +0200 Subject: 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 Reviewed-by: Alex Blasche --- src/nfc/qndefrecord_p.h | 7 +++++-- src/nfc/qqmlndefrecord.cpp | 19 +++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'src/nfc') 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(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(typeNameFormat)); + Q_D(QQmlNdefRecord); + d->record.setTypeNameFormat(static_cast(newTypeNameFormat)); - if (emitChanged) - Q_EMIT(typeNameFormatChanged()); + emit typeNameFormatChanged(); } /*! -- cgit v1.2.3