diff options
author | vng <viktor.govako@gmail.com> | 2013-07-05 16:44:03 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:58:12 +0300 |
commit | d39d7542f3a45ada3907506a6880053634e35274 (patch) | |
tree | 620ea9ef74d4927aa56712027715ba28147c69ee /qt/draw_widget.cpp | |
parent | 19d314d1fa1d61e651ebe78af25eaae0a064ba2b (diff) |
- Do non-blocking Cancel in ScheduledTask. Blocking Cancel "causes" deadlock and freezing of main thread.
- Fix memory leak.
Diffstat (limited to 'qt/draw_widget.cpp')
-rw-r--r-- | qt/draw_widget.cpp | 18 |
1 files changed, 13 insertions, 5 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) |