summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@jollamobile.com>2014-01-08 17:06:46 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-17 06:21:19 +0100
commite584af651f5b7b2855a37cee7d94999ce3374b5c (patch)
tree2d34e9baf681fe42b6368909623006d5a8015a19 /tests/auto
parentc2502d3181a9ce4aab868629c3dd4813c686346f (diff)
downloadqtlocation-e584af651f5b7b2855a37cee7d94999ce3374b5c.tar.gz
Fix killing timer in different thread.
It was possible for another thread to attempt to stop the timer used by the tile fetcher. Change-Id: Ic44cf416bc7e6c987c4b5c9914a1c7d911dbbea5 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/geotestplugin/qgeotilefetcher_test.h25
1 files changed, 12 insertions, 13 deletions
diff --git a/tests/auto/geotestplugin/qgeotilefetcher_test.h b/tests/auto/geotestplugin/qgeotilefetcher_test.h
index 2f2754cf..9c939b9d 100644
--- a/tests/auto/geotestplugin/qgeotilefetcher_test.h
+++ b/tests/auto/geotestplugin/qgeotilefetcher_test.h
@@ -82,7 +82,6 @@ public:
: QGeoTileFetcher(engine, parent),
finishRequestImmediately_(false),
mappingReply_(0),
- timerId_(0),
errorCode_(QGeoTiledMapReply::NoError) {}
bool init()
@@ -125,7 +124,8 @@ public:
mappingReply_->callSetMapImageData(bytes);
mappingReply_->callSetMapImageFormat("png");
- mappingReply_->callSetFinished(true);
+
+ timer_.start(500, this);
return mappingReply_;
}
@@ -143,35 +143,34 @@ public:
public Q_SLOTS:
void requestAborted()
{
- if (timerId_) {
- killTimer(timerId_);
- timerId_ = 0;
- }
- errorString_ = "";
+ timer_.stop();
+ errorString_.clear();
errorCode_ = QGeoTiledMapReply::NoError;
}
protected:
void timerEvent(QTimerEvent *event)
{
- Q_ASSERT(timerId_ == event->timerId());
+ if (event->timerId() != timer_.timerId()) {
+ QGeoTileFetcher::timerEvent(event);
+ return;
+ }
+
Q_ASSERT(mappingReply_);
- killTimer(timerId_);
- timerId_ = 0;
+ timer_.stop();
if (errorCode_) {
mappingReply_->callSetError(errorCode_, errorString_);
emit tileError(mappingReply_->tileSpec(), errorString_);
- } else {
+ } else {
mappingReply_->callSetError(QGeoTiledMapReply::NoError, "no error");
mappingReply_->callSetFinished(true);
}
- // emit finished(mappingReply_); todo tileFinished
}
private:
bool finishRequestImmediately_;
TiledMapReplyTest* mappingReply_;
- int timerId_;
+ QBasicTimer timer_;
QGeoTiledMapReply::Error errorCode_;
QString errorString_;
QVariantMap parameters_;