Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qt
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2013-07-05 16:44:03 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:58:12 +0300
commitd39d7542f3a45ada3907506a6880053634e35274 (patch)
tree620ea9ef74d4927aa56712027715ba28147c69ee /qt
parent19d314d1fa1d61e651ebe78af25eaae0a064ba2b (diff)
- Do non-blocking Cancel in ScheduledTask. Blocking Cancel "causes" deadlock and freezing of main thread.
- Fix memory leak.
Diffstat (limited to 'qt')
-rw-r--r--qt/draw_widget.cpp18
-rw-r--r--qt/draw_widget.hpp2
2 files changed, 14 insertions, 6 deletions
diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp
index 1cbe7a941f..42c1260f2c 100644
--- a/qt/draw_widget.cpp
+++ b/qt/draw_widget.cpp
@@ -100,9 +100,12 @@ namespace qt
void DrawWidget::PrepareShutdown()
{
KillPressTask();
+
ASSERT(isValid(), ());
makeCurrent();
+
m_framework->PrepareToShutdown();
+
m_videoTimer.reset();
}
@@ -332,18 +335,23 @@ namespace qt
void DrawWidget::StartPressTask(m2::PointD const & pt, unsigned ms)
{
- KillPressTask();
-
- m_scheduledTasks.reset(new ScheduledTask(bind(&DrawWidget::OnPressTaskEvent, this, pt, ms), ms));
+ if (KillPressTask())
+ m_scheduledTasks.reset(new ScheduledTask(bind(&DrawWidget::OnPressTaskEvent, this, pt, ms), ms));
}
- void DrawWidget::KillPressTask()
+ bool DrawWidget::KillPressTask()
{
if (m_scheduledTasks)
{
- m_scheduledTasks->Cancel();
+ if (!m_scheduledTasks->Cancel())
+ {
+ // The task is already running - skip new task.
+ return false;
+ }
+
m_scheduledTasks.reset();
}
+ return true;
}
void DrawWidget::OnPressTaskEvent(m2::PointD const & pt, unsigned ms)
diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp
index 760274c948..ec3f1f3266 100644
--- a/qt/draw_widget.hpp
+++ b/qt/draw_widget.hpp
@@ -111,7 +111,7 @@ namespace qt
protected:
void StartPressTask(m2::PointD const & pt, unsigned ms);
- void KillPressTask();
+ bool KillPressTask();
void OnPressTaskEvent(m2::PointD const & pt, unsigned ms);
protected: