* Delete longClickMessageRunner in destructor to avoid potential memory leak.
* Delete longClickMessageRunner after its message arrived, to shorten its lifetime. * Moved creation and deletion of longClickMessageRunner into methods. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27288 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3f524cfc8d
commit
361a3434b4
@ -114,6 +114,7 @@ TTimeView::TTimeView(BMessage *data)
|
||||
|
||||
TTimeView::~TTimeView()
|
||||
{
|
||||
StopLongClickNotifier();
|
||||
}
|
||||
|
||||
|
||||
@ -237,6 +238,7 @@ TTimeView::MessageReceived(BMessage* message)
|
||||
|
||||
case kMsgLongClick:
|
||||
{
|
||||
StopLongClickNotifier();
|
||||
BPoint where;
|
||||
message->FindPoint("where", &where);
|
||||
ShowCalendar(where);
|
||||
@ -298,6 +300,31 @@ TTimeView::ShowCalendar(BPoint where)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::StartLongClickNotifier(BPoint where)
|
||||
{
|
||||
StopLongClickNotifier();
|
||||
|
||||
BMessage longClickMessage(kMsgLongClick);
|
||||
longClickMessage.AddPoint("where", where);
|
||||
|
||||
bigtime_t longClickThreshold;
|
||||
get_click_speed(&longClickThreshold);
|
||||
// use the doubleClickSpeed as a threshold
|
||||
|
||||
fLongClickMessageRunner = new BMessageRunner(BMessenger(this),
|
||||
&longClickMessage, longClickThreshold, 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::StopLongClickNotifier()
|
||||
{
|
||||
delete fLongClickMessageRunner;
|
||||
fLongClickMessageRunner = NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::GetCurrentTime()
|
||||
{
|
||||
@ -376,16 +403,7 @@ TTimeView::MouseDown(BPoint point)
|
||||
ShowClockOptions(ConvertToScreen(point));
|
||||
return;
|
||||
} else if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
||||
BMessage longClickMessage(kMsgLongClick);
|
||||
longClickMessage.AddPoint("where", point);
|
||||
|
||||
bigtime_t longClickThreshold;
|
||||
get_click_speed(&longClickThreshold);
|
||||
// use the doubleClickSpeed as a threshold
|
||||
|
||||
delete fLongClickMessageRunner;
|
||||
fLongClickMessageRunner = new BMessageRunner(BMessenger(this),
|
||||
&longClickMessage, longClickThreshold, 1);
|
||||
StartLongClickNotifier(point);
|
||||
}
|
||||
|
||||
// flip to/from showing date or time
|
||||
@ -404,8 +422,7 @@ TTimeView::MouseDown(BPoint point)
|
||||
void
|
||||
TTimeView::MouseUp(BPoint point)
|
||||
{
|
||||
delete fLongClickMessageRunner;
|
||||
fLongClickMessageRunner = NULL;
|
||||
StopLongClickNotifier();
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,6 +83,8 @@ class TTimeView : public BView {
|
||||
bool ShowingEuroDate() {return fEuroDate; }
|
||||
void ShowEuroDate(bool);
|
||||
void ShowCalendar(BPoint where);
|
||||
void StartLongClickNotifier(BPoint where);
|
||||
void StopLongClickNotifier();
|
||||
|
||||
bool Orientation() const;
|
||||
void SetOrientation(bool o);
|
||||
|
Loading…
Reference in New Issue
Block a user