* 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:
@@ -114,6 +114,7 @@ TTimeView::TTimeView(BMessage *data)
|
|||||||
|
|
||||||
TTimeView::~TTimeView()
|
TTimeView::~TTimeView()
|
||||||
{
|
{
|
||||||
|
StopLongClickNotifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -237,6 +238,7 @@ TTimeView::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case kMsgLongClick:
|
case kMsgLongClick:
|
||||||
{
|
{
|
||||||
|
StopLongClickNotifier();
|
||||||
BPoint where;
|
BPoint where;
|
||||||
message->FindPoint("where", &where);
|
message->FindPoint("where", &where);
|
||||||
ShowCalendar(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
|
void
|
||||||
TTimeView::GetCurrentTime()
|
TTimeView::GetCurrentTime()
|
||||||
{
|
{
|
||||||
@@ -376,16 +403,7 @@ TTimeView::MouseDown(BPoint point)
|
|||||||
ShowClockOptions(ConvertToScreen(point));
|
ShowClockOptions(ConvertToScreen(point));
|
||||||
return;
|
return;
|
||||||
} else if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
} else if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
||||||
BMessage longClickMessage(kMsgLongClick);
|
StartLongClickNotifier(point);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// flip to/from showing date or time
|
// flip to/from showing date or time
|
||||||
@@ -404,8 +422,7 @@ TTimeView::MouseDown(BPoint point)
|
|||||||
void
|
void
|
||||||
TTimeView::MouseUp(BPoint point)
|
TTimeView::MouseUp(BPoint point)
|
||||||
{
|
{
|
||||||
delete fLongClickMessageRunner;
|
StopLongClickNotifier();
|
||||||
fLongClickMessageRunner = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ class TTimeView : public BView {
|
|||||||
bool ShowingEuroDate() {return fEuroDate; }
|
bool ShowingEuroDate() {return fEuroDate; }
|
||||||
void ShowEuroDate(bool);
|
void ShowEuroDate(bool);
|
||||||
void ShowCalendar(BPoint where);
|
void ShowCalendar(BPoint where);
|
||||||
|
void StartLongClickNotifier(BPoint where);
|
||||||
|
void StopLongClickNotifier();
|
||||||
|
|
||||||
bool Orientation() const;
|
bool Orientation() const;
|
||||||
void SetOrientation(bool o);
|
void SetOrientation(bool o);
|
||||||
|
|||||||
Reference in New Issue
Block a user