From 3dd881e3af4acb0043c47b43123f938f9b472ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 12 Mar 2006 22:35:36 +0000 Subject: [PATCH] * Fixed memory leak in StressTest and BWindow: they both did not delete the message they passed to a BMessageRunner object. * Added note about the ownership of the message to the BMessageRunner documentation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16751 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/MessageRunner.cpp | 12 ++++++++---- src/kits/interface/Window.cpp | 3 ++- src/tests/servers/app/stress_test/main.cpp | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/kits/app/MessageRunner.cpp b/src/kits/app/MessageRunner.cpp index c15ca87526..1c289ca226 100644 --- a/src/kits/app/MessageRunner.cpp +++ b/src/kits/app/MessageRunner.cpp @@ -23,7 +23,8 @@ using namespace BPrivate; The target for replies to the delivered message(s) is \c be_app_messenger. The success of the initialization can (and should) be asked for via - InitCheck(). + InitCheck(). This object will not take ownership of the \a message, you + may freely change or delete it after creation. \note As soon as the last message has been sent, the message runner becomes unusable. InitCheck() will still return \c B_OK, but @@ -50,7 +51,8 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage *message, replies to the delivered message(s). The success of the initialization can (and should) be asked for via - InitCheck(). + InitCheck(). This object will not take ownership of the \a message, you + may freely change or delete it after creation. \note As soon as the last message has been sent, the message runner becomes unusable. InitCheck() will still return \c B_OK, but @@ -77,7 +79,8 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage *message, The target for replies to the delivered message(s) is \c be_app_messenger. The success of the initialization can (and should) be asked for via - InitCheck(). + InitCheck(). This object will not take ownership of the \a message, you + may freely change or delete it after creation. \note As soon as the last message has been sent, the message runner becomes unusable. InitCheck() will still return \c B_OK, but @@ -111,7 +114,8 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage *message, replies to the delivered message(s). The success of the initialization can (and should) be asked for via - InitCheck(). + InitCheck(). This object will not take ownership of the \a message, you + may freely change or delete it after creation. \note As soon as the last message has been sent, the message runner becomes unusable. InitCheck() will still return \c B_OK, but diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 796d5f953c..37a17a1425 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1340,8 +1340,9 @@ BWindow::SetPulseRate(bigtime_t rate) if (rate > 0) { if (fPulseRunner == NULL) { + BMessage message(B_PULSE); fPulseRunner = new BMessageRunner(BMessenger(this), - new BMessage(B_PULSE), rate); + &message, rate); } else { fPulseRunner->SetInterval(rate); } diff --git a/src/tests/servers/app/stress_test/main.cpp b/src/tests/servers/app/stress_test/main.cpp index 1fc1c8e13e..aa292f8f5c 100644 --- a/src/tests/servers/app/stress_test/main.cpp +++ b/src/tests/servers/app/stress_test/main.cpp @@ -102,7 +102,8 @@ TestWindow::TestWindow(BRect frame) Show(); BMessenger self(this); - fPulse = new BMessageRunner(self, new BMessage(B_QUIT_REQUESTED), 10000000, 1); + BMessage message(B_QUIT_REQUESTED); + fPulse = new BMessageRunner(self, &message, 10000000, 1); }