HaikuDepot: Fix leak of ProcessCoordinators.
This function is supposed to take ownership of the coordinator item, but it didn't do that in all cases. Use a BReference(..., true) to do that.
This commit is contained in:
@@ -1419,12 +1419,12 @@ MainWindow::_HandleUserUsageConditionsNotLatest(
|
|||||||
void
|
void
|
||||||
MainWindow::_AddProcessCoordinator(ProcessCoordinator* item)
|
MainWindow::_AddProcessCoordinator(ProcessCoordinator* item)
|
||||||
{
|
{
|
||||||
|
BReference<ProcessCoordinator> itemRef(item, true);
|
||||||
AutoLocker<BLocker> lock(&fCoordinatorLock);
|
AutoLocker<BLocker> lock(&fCoordinatorLock);
|
||||||
|
|
||||||
if (fShouldCloseWhenNoProcessesToCoordinate) {
|
if (fShouldCloseWhenNoProcessesToCoordinate) {
|
||||||
HDINFO("system shutting down --> new process coordinator [%s] rejected",
|
HDINFO("system shutting down --> new process coordinator [%s] rejected",
|
||||||
item->Name().String());
|
item->Name().String());
|
||||||
delete item;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1435,10 +1435,9 @@ MainWindow::_AddProcessCoordinator(ProcessCoordinator* item)
|
|||||||
debugger("unable to acquire the process coordinator sem");
|
debugger("unable to acquire the process coordinator sem");
|
||||||
HDINFO("adding and starting a process coordinator [%s]",
|
HDINFO("adding and starting a process coordinator [%s]",
|
||||||
item->Name().String());
|
item->Name().String());
|
||||||
fCoordinator = BReference<ProcessCoordinator>(item);
|
fCoordinator = itemRef;
|
||||||
fCoordinator->Start();
|
fCoordinator->Start();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
HDINFO("adding process coordinator [%s] to the queue",
|
HDINFO("adding process coordinator [%s] to the queue",
|
||||||
item->Name().String());
|
item->Name().String());
|
||||||
fCoordinatorQueue.push(item);
|
fCoordinatorQueue.push(item);
|
||||||
|
|||||||
Reference in New Issue
Block a user