From d0dc209c450a0bc07bbd369771b70f5468b2036e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 29 Dec 2019 17:13:30 +0200 Subject: [PATCH] error: implicit conversion changes signedness: 'quint32' (aka 'unsigned int') to 'int'. --HG-- branch : develop --- src/libs/ifc/xml/vdomdocument.cpp | 29 +++++++++++++++++++++++++++++ src/libs/ifc/xml/vdomdocument.h | 1 + src/libs/vformat/vwatermark.cpp | 6 +++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 22dd8cf27..aa02dd3bf 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -377,6 +377,35 @@ quint32 VDomDocument::GetParametrUInt(const QDomElement &domElement, const QStri return id; } +//--------------------------------------------------------------------------------------------------------------------- +int VDomDocument::GetParametrInt(const QDomElement &domElement, const QString &name, const QString &defValue) +{ + Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "name of parametr is empty"); + Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); //-V591 + + bool ok = false; + QString parametr; + int value = 0; + + try + { + parametr = GetParametrString(domElement, name, defValue); + value = parametr.toInt(&ok); + if (ok == false) + { + throw VExceptionConversionError(QObject::tr("Can't convert toInt parameter"), name); + } + } + catch (const VExceptionEmptyParameter &e) + { + VExceptionConversionError excep(QObject::tr("Can't convert toInt parameter"), name); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + + return value; +} + //--------------------------------------------------------------------------------------------------------------------- bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString &name, const QString &defValue) { diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 9a8cab0b7..3ec22a924 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -106,6 +106,7 @@ public: bool removeCondition) const; static quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue); + static int GetParametrInt(const QDomElement& domElement, const QString &name, const QString &defValue); static bool GetParametrBool(const QDomElement& domElement, const QString &name, const QString &defValue); static NodeUsage GetParametrUsage(const QDomElement& domElement, const QString &name); diff --git a/src/libs/vformat/vwatermark.cpp b/src/libs/vformat/vwatermark.cpp index 05a6ed50e..5d58ffa26 100644 --- a/src/libs/vformat/vwatermark.cpp +++ b/src/libs/vformat/vwatermark.cpp @@ -92,13 +92,13 @@ VWatermarkData VWatermark::GetWatermark() const if (not root.isNull() && root.isElement()) { const QDomElement rootElement = root.toElement(); - data.opacity = GetParametrUInt(rootElement, AttrOpacity, QChar('2')); + data.opacity = GetParametrInt(rootElement, AttrOpacity, QChar('2')); QDomElement text = rootElement.firstChildElement(TagText); if (not text.isNull()) { data.text = GetParametrEmptyString(text, AttrText); - data.textRotation = GetParametrUInt(text, AttrRotation, QChar('0')); + data.textRotation = GetParametrInt(text, AttrRotation, QChar('0')); data.font.fromString(GetParametrEmptyString(text, AttrFont)); } @@ -106,7 +106,7 @@ VWatermarkData VWatermark::GetWatermark() const if (not image.isNull()) { data.path = GetParametrEmptyString(image, AttrPath); - data.imageRotation = GetParametrUInt(image, AttrRotation, QChar('0')); + data.imageRotation = GetParametrInt(image, AttrRotation, QChar('0')); data.grayscale = GetParametrBool(image, AttrGrayscale, falseStr); } }