Skip to content

Commit f1b7ab3

Browse files
authored
Merge pull request #37 from hasselmm/bugfix/various-bugfixes
Various bugfixes
2 parents f0e6faa + 1ff8827 commit f1b7ab3

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

http/httpparser.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <QBuffer>
1212
#include <QDateTime>
1313
#include <QLoggingCategory>
14+
#include <QTimeZone>
1415

1516
namespace qnc::http {
1617

@@ -170,14 +171,14 @@ QDateTime parseDateTime(const QString &text)
170171
const auto locale = QLocale::c(); // for language neutral (that is English) weekdays
171172

172173
if (auto dt = locale.toDateTime(text, s_rfc1123DateFormat); dt.isValid()) {
173-
dt.setTimeSpec(Qt::UTC);
174+
dt.setTimeZone(QTimeZone::utc());
174175
return dt;
175176
} else if (auto dt = locale.toDateTime(text, s_rfc850DateFormat); dt.isValid()) {
176-
dt.setTimeSpec(Qt::UTC);
177+
dt.setTimeZone(QTimeZone::utc());
177178
return dt;
178179
} else if (auto dt = locale.toDateTime(QString{text}.replace(" "_L1, " "_L1),
179180
s_ascTimeDateFormat); dt.isValid()) {
180-
dt.setTimeSpec(Qt::UTC);
181+
dt.setTimeZone(QTimeZone::utc());
181182
return dt;
182183
}
183184

tests/auto/tst_xmlparser.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ private slots:
331331
QTest::newRow("double:valid") << makeConversionTest<double> (u"4.56", 4.56);
332332
QTest::newRow("longdouble:valid") << makeConversionTest<long double> (u"7.89", 7.89);
333333
QTest::newRow("QString:valid") << makeConversionTest<QString> (u"Hello world", u"Hello world"_s);
334-
QTest::newRow("QStringView:valid") << makeConversionTest<QStringView>(u"Hello world", u"Hello world");
335334
QTest::newRow("QUrl:valid") << makeConversionTest<QUrl> (u"hello:world", "hello:world"_url);
336335
}
337336

xml/xmlparser.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,8 @@ std::optional<QString> convert(QStringView text)
9393
return text.toString();
9494
}
9595

96-
template <>
97-
std::optional<QStringView> convert(QStringView text)
98-
{
99-
return text;
100-
}
96+
template <> // QStringView is a temporary view, not a storage type
97+
std::optional<QStringView> convert(QStringView text) = delete;
10198

10299
template <>
103100
std::optional<QUrl> convert(QStringView text)
@@ -179,7 +176,6 @@ template void ParserBase::parseValue(QStringView, const std::function<void(float
179176
template void ParserBase::parseValue(QStringView, const std::function<void(double)> &);
180177
template void ParserBase::parseValue(QStringView, const std::function<void(long double)> &);
181178
template void ParserBase::parseValue(QStringView, const std::function<void(QString)> &);
182-
template void ParserBase::parseValue(QStringView, const std::function<void(QStringView)> &);
183179
template void ParserBase::parseValue(QStringView, const std::function<void(QUrl)> &);
184180

185181
QString ParserBase::stateName(const QMetaEnum &metaEnum, int value)

xml/xmlparser.h

+9
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,17 @@ class ParserBase : public QObject
221221
static void emplaceBack(Context &context, typename detail::ValueType<list>::value_type &&value)
222222
{
223223
using Object = typename detail::ObjectType<list>;
224+
225+
QT_WARNING_PUSH
226+
QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
227+
224228
#if QT_VERSION_MAJOR >= 6
225229
(currentObject<Object>(context).*list).emplaceBack(std::move(value));
226230
#else // QT_VERSION_MAJOR < 6
227231
(currentObject<Object>(context).*list).append(std::move(value));
228232
#endif // QT_VERSION_MAJOR < 6
233+
234+
QT_WARNING_POP
229235
}
230236

231237
static QString stateName(const QMetaEnum &metaEnum, int value);
@@ -307,6 +313,9 @@ class ParserBase : public QObject
307313
QXmlStreamReader *const m_xml;
308314
};
309315

316+
template <> // QStringView is not a storage type, it's a temporary view
317+
void ParserBase::parseValue(QStringView text, const std::function<void(QStringView)> &store) = delete;
318+
310319
template <typename StateEnum>
311320
class Parser : public ParserBase
312321
{

0 commit comments

Comments
 (0)