diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-20 15:19:46 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-20 15:20:10 +0200 |
commit | 50a65604130f9c0aea46799231e88ac956ac018b (patch) | |
tree | 18313ba97554de907a855f9351816b9c226cae8a /Applications/PaintBrush | |
parent | c34fd10b5bcf1e692cd609b5b156abd70624f7b7 (diff) | |
download | serenity-50a65604130f9c0aea46799231e88ac956ac018b.zip |
LibCore: Convert CTimer to ObjectPtr
Diffstat (limited to 'Applications/PaintBrush')
-rw-r--r-- | Applications/PaintBrush/SprayTool.cpp | 13 | ||||
-rw-r--r-- | Applications/PaintBrush/SprayTool.h | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/Applications/PaintBrush/SprayTool.cpp b/Applications/PaintBrush/SprayTool.cpp index 0125897cce..1ebb3456b7 100644 --- a/Applications/PaintBrush/SprayTool.cpp +++ b/Applications/PaintBrush/SprayTool.cpp @@ -11,10 +11,11 @@ SprayTool::SprayTool() { - m_timer.on_timeout = [=]() { + m_timer = CTimer::create(); + m_timer->on_timeout = [&]() { paint_it(); }; - m_timer.set_interval(200); + m_timer->set_interval(200); } SprayTool::~SprayTool() @@ -54,22 +55,22 @@ void SprayTool::on_mousedown(GMouseEvent& event) m_color = m_widget->color_for(event); m_last_pos = event.position(); - m_timer.start(); + m_timer->start(); paint_it(); } void SprayTool::on_mousemove(GMouseEvent& event) { m_last_pos = event.position(); - if (m_timer.is_active()) { + if (m_timer->is_active()) { paint_it(); - m_timer.restart(m_timer.interval()); + m_timer->restart(m_timer->interval()); } } void SprayTool::on_mouseup(GMouseEvent&) { - m_timer.stop(); + m_timer->stop(); } void SprayTool::on_contextmenu(GContextMenuEvent& event) diff --git a/Applications/PaintBrush/SprayTool.h b/Applications/PaintBrush/SprayTool.h index 2260990555..679009a1da 100644 --- a/Applications/PaintBrush/SprayTool.h +++ b/Applications/PaintBrush/SprayTool.h @@ -19,7 +19,7 @@ public: private: virtual const char* class_name() const override { return "SprayTool"; } void paint_it(); - CTimer m_timer; + ObjectPtr<CTimer> m_timer; Point m_last_pos; Color m_color; OwnPtr<GMenu> m_context_menu; |