aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-01-15 11:22:39 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-01-15 10:38:35 +0000
commit6fe75203a399b8cd0848ca9bda9d9aa4fdf3edd5 (patch)
tree7bef5e9d2f8ae8d97d879a0ca2a2e2c09f7cf768
parent8ddd93f1a7aba531f5a6027f72a4ba7a89492916 (diff)
QQmlProfilerService: Avoid type ambiguities
Use C++ cast operators, and always choose types of defined length when interacting with the packet protocol. Also, don't let the client overflow the flush interval setting. Change-Id: I2f4654d4e3e350a979a989784dc61fbc8b97df2a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
index c388c6e74a..0d69b2ab66 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
@@ -240,7 +240,7 @@ void QQmlProfilerServiceImpl::startProfiling(QJSEngine *engine, quint64 features
QQmlDebugPacket d;
- d << m_timer.nsecsElapsed() << (int)Event << (int)StartTrace;
+ d << m_timer.nsecsElapsed() << static_cast<qint32>(Event) << static_cast<qint32>(StartTrace);
bool startedAny = false;
if (engine != 0) {
const auto range = qAsConst(m_engineProfilers).equal_range(engine);
@@ -338,7 +338,8 @@ void QQmlProfilerServiceImpl::sendMessages()
QQmlDebugPacket traceEnd;
if (m_waitingForStop) {
- traceEnd << m_timer.nsecsElapsed() << (int)Event << (int)EndTrace;
+ traceEnd << m_timer.nsecsElapsed() << static_cast<qint32>(Event)
+ << static_cast<qint32>(EndTrace);
QSet<QJSEngine *> seen;
for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_startTimes)) {
@@ -373,7 +374,7 @@ void QQmlProfilerServiceImpl::sendMessages()
messages << traceEnd.data();
QQmlDebugPacket ds;
- ds << (qint64)-1 << (int)Complete;
+ ds << static_cast<qint64>(-1) << static_cast<qint32>(Complete);
messages << ds.data();
m_waitingForStop = false;
}
@@ -414,7 +415,7 @@ void QQmlProfilerServiceImpl::messageReceived(const QByteArray &message)
int engineId = -1;
quint64 features = std::numeric_limits<quint64>::max();
bool enabled;
- uint flushInterval = 0;
+ quint32 flushInterval = 0;
stream >> enabled;
if (!stream.atEnd())
stream >> engineId;
@@ -422,7 +423,9 @@ void QQmlProfilerServiceImpl::messageReceived(const QByteArray &message)
stream >> features;
if (!stream.atEnd()) {
stream >> flushInterval;
- m_flushTimer.setInterval(flushInterval);
+ m_flushTimer.setInterval(
+ static_cast<int>(qMin(flushInterval,
+ static_cast<quint32>(std::numeric_limits<int>::max()))));
auto timerStart = static_cast<void(QTimer::*)()>(&QTimer::start);
if (flushInterval > 0) {
connect(&m_flushTimer, &QTimer::timeout, this, &QQmlProfilerServiceImpl::flush);