* cleaned up fPulseRunner stuff, I have no idea why fPulseEnabled was

useful... so I removed it
* fixed memory leak with SetPulseRate(0), fPulseRunner is now
  properly freed in the Window destructor
* fTitle is now freed as well
* fix some potential leaks in BView destructor as well

I wrote a stress test app, which I'm soon going to commit as well...
it shows that not all memory leaks are fixed by this patch, I could
use some help with this...



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16713 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-03-11 19:32:53 +00:00
parent 4316cb15fa
commit ecf9f94800
3 changed files with 20 additions and 27 deletions
+2 -2
View File
@@ -318,7 +318,7 @@ private:
BButton *fDefaultButton; BButton *fDefaultButton;
BList fShortcuts; BList fShortcuts;
int32 fTopViewToken; int32 fTopViewToken;
bool fPulseEnabled; bool _unused2; // was fPulseEnabled
bool fViewsNeedPulse; // not yet used bool fViewsNeedPulse; // not yet used
bool fIsFilePanel; bool fIsFilePanel;
bool fMaskActivated; bool fMaskActivated;
@@ -326,7 +326,7 @@ private:
bool fWaitingForMenu; bool fWaitingForMenu;
bool fMinimized; bool fMinimized;
bool fNoQuitShortcut; bool fNoQuitShortcut;
bool _unused2; bool _unused3;
sem_id fMenuSem; sem_id fMenuSem;
float fMaxZoomHeight; float fMaxZoomHeight;
float fMaxZoomWidth; float fMaxZoomWidth;
+4 -5
View File
@@ -565,6 +565,7 @@ BView::~BView()
SetName(NULL); SetName(NULL);
removeCommArray();
delete fState; delete fState;
} }
@@ -809,7 +810,7 @@ BView::SetFlags(uint32 flags)
if (fOwner) { if (fOwner) {
if (flags & B_PULSE_NEEDED) { if (flags & B_PULSE_NEEDED) {
check_lock_no_pick(); check_lock_no_pick();
if (!fOwner->fPulseEnabled) if (fOwner->fPulseRunner == NULL)
fOwner->SetPulseRate(500000); fOwner->SetPulseRate(500000);
} }
@@ -2996,9 +2997,7 @@ BView::EndLineArray()
_FlushIfNotInTransaction(); _FlushIfNotInTransaction();
delete [] comm->array; removeCommArray();
delete comm;
comm = NULL;
} }
@@ -4120,7 +4119,7 @@ BView::_Attach()
if (fOwner) { if (fOwner) {
if (fFlags & B_PULSE_NEEDED) { if (fFlags & B_PULSE_NEEDED) {
check_lock_no_pick(); check_lock_no_pick();
if (!fOwner->fPulseEnabled) if (fOwner->fPulseRunner == NULL)
fOwner->SetPulseRate(500000); fOwner->SetPulseRate(500000);
} }
} }
+14 -20
View File
@@ -326,6 +326,7 @@ BWindow::~BWindow()
} }
// TODO: release other dynamically-allocated objects // TODO: release other dynamically-allocated objects
free(fTitle);
// Deleting this semaphore will tell open menus to quit. // Deleting this semaphore will tell open menus to quit.
if (fMenuSem > 0) if (fMenuSem > 0)
@@ -960,7 +961,7 @@ FrameMoved(origin);
} }
case B_PULSE: case B_PULSE:
if (target == this && fPulseEnabled) { if (target == this && fPulseRunner) {
fTopView->_Pulse(); fTopView->_Pulse();
fLink->Flush(); fLink->Flush();
} else } else
@@ -1332,28 +1333,23 @@ void
BWindow::SetPulseRate(bigtime_t rate) BWindow::SetPulseRate(bigtime_t rate)
{ {
// TODO: What about locking?!? // TODO: What about locking?!?
if (rate < 0) if (rate < 0 || rate == fPulseRate)
return; return;
// ToDo: isn't fPulseRunner enough? Why fPulseEnabled? fPulseRate = rate;
if (fPulseRate == 0 && !fPulseEnabled) {
fPulseRunner = new BMessageRunner(BMessenger(this),
new BMessage(B_PULSE), rate);
fPulseRate = rate;
fPulseEnabled = true;
return;
}
if (rate == 0 && fPulseEnabled) { if (rate > 0) {
if (fPulseRunner == NULL) {
fPulseRunner = new BMessageRunner(BMessenger(this),
new BMessage(B_PULSE), rate);
} else {
fPulseRunner->SetInterval(rate);
}
} else {
// rate == 0
delete fPulseRunner; delete fPulseRunner;
fPulseRunner = NULL; fPulseRunner = NULL;
fPulseRate = rate;
fPulseEnabled = false;
return;
} }
fPulseRunner->SetInterval(rate);
} }
@@ -2199,7 +2195,6 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
AddShortcut('V', B_COMMAND_KEY, new BMessage(B_PASTE), NULL); AddShortcut('V', B_COMMAND_KEY, new BMessage(B_PASTE), NULL);
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), NULL); AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), NULL);
fPulseEnabled = false;
fPulseRate = 0; fPulseRate = 0;
fPulseRunner = NULL; fPulseRunner = NULL;
@@ -2234,6 +2229,7 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
port_id receivePort = create_port(B_LOOPER_PORT_DEFAULT_CAPACITY, "w<app_server"); port_id receivePort = create_port(B_LOOPER_PORT_DEFAULT_CAPACITY, "w<app_server");
if (receivePort < B_OK) { if (receivePort < B_OK) {
// TODO: huh?
debugger("Could not create BWindow's receive port, used for interacting with the app_server!"); debugger("Could not create BWindow's receive port, used for interacting with the app_server!");
delete this; delete this;
return; return;
@@ -3137,7 +3133,6 @@ BWindow::PrintToStream() const
*/ */
printf("\ printf("\
topViewToken = %ld\ topViewToken = %ld\
pluseEnabled = %s\
isFilePanel = %s\ isFilePanel = %s\
MaskActivated = %s\ MaskActivated = %s\
pulseRate = %lld\ pulseRate = %lld\
@@ -3156,7 +3151,6 @@ BWindow::PrintToStream() const
lastViewToken = %ld\ lastViewToken = %ld\
pulseRunner = %s\n", pulseRunner = %s\n",
fTopViewToken, fTopViewToken,
fPulseEnabled==true?"Yes":"No",
fIsFilePanel==true?"Yes":"No", fIsFilePanel==true?"Yes":"No",
fMaskActivated==true?"Yes":"No", fMaskActivated==true?"Yes":"No",
fPulseRate, fPulseRate,