change init method for more robust

This commit is contained in:
idea4good 2019-10-09 19:19:44 +08:00
parent bfb670255d
commit 33d4ed1965
2 changed files with 4 additions and 3 deletions

View File

@ -9,8 +9,9 @@
#include "../widgets_include/gesture.h" #include "../widgets_include/gesture.h"
#include "../widgets_include/slide_group.h" #include "../widgets_include/slide_group.h"
c_slide_group::c_slide_group() : m_gesture(this) c_slide_group::c_slide_group()
{ {
m_gesture = new c_gesture(this);
for(int i = 0; i < MAX_PAGES; i++) for(int i = 0; i < MAX_PAGES; i++)
{ {
m_slides[i] = 0; m_slides[i] = 0;
@ -159,7 +160,7 @@ bool c_slide_group::on_touch(int x, int y, TOUCH_ACTION action)
x -= m_wnd_rect.m_left; x -= m_wnd_rect.m_left;
y -= m_wnd_rect.m_top; y -= m_wnd_rect.m_top;
if (m_gesture.handle_swipe(x, y, action)) if (m_gesture->handle_swipe(x, y, action))
{ {
if (m_slides[m_active_slide_index]) if (m_slides[m_active_slide_index])
{ {

View File

@ -23,7 +23,7 @@ protected:
virtual c_wnd* clone(){return new c_slide_group();} virtual c_wnd* clone(){return new c_slide_group();}
c_wnd* m_slides[MAX_PAGES]; c_wnd* m_slides[MAX_PAGES];
int m_active_slide_index; int m_active_slide_index;
c_gesture m_gesture; c_gesture* m_gesture;
}; };
#endif #endif