app_server pointer/ownership cleanup: trivial changes
Split apart the work done in https://review.haiku-os.org/c/haiku/+/2695 in smaller, easier to review parts. This commit contains self-contained/local changes that are unlikely to cause problems. Change-Id: Idae27ca440791423e3d090bcfe33f4cc83bbea3d Reviewed-on: https://review.haiku-os.org/c/haiku/+/3174 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
4af3fbf906
commit
6fd2274306
@ -14,6 +14,7 @@
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <LaunchRoster.h>
|
||||
#include <PortLink.h>
|
||||
|
||||
@ -174,20 +175,19 @@ Desktop*
|
||||
AppServer::_CreateDesktop(uid_t userID, const char* targetScreen)
|
||||
{
|
||||
BAutolock locker(fDesktopLock);
|
||||
Desktop* desktop = NULL;
|
||||
ObjectDeleter<Desktop> desktop;
|
||||
try {
|
||||
desktop = new Desktop(userID, targetScreen);
|
||||
desktop.SetTo(new Desktop(userID, targetScreen));
|
||||
|
||||
status_t status = desktop->Init();
|
||||
if (status == B_OK)
|
||||
status = desktop->Run();
|
||||
if (status == B_OK && !fDesktops.AddItem(desktop))
|
||||
if (status == B_OK && !fDesktops.AddItem(desktop.Get()))
|
||||
status = B_NO_MEMORY;
|
||||
|
||||
if (status != B_OK) {
|
||||
syslog(LOG_ERR, "Cannot initialize Desktop object: %s\n",
|
||||
strerror(status));
|
||||
delete desktop;
|
||||
return NULL;
|
||||
}
|
||||
} catch (...) {
|
||||
@ -195,7 +195,7 @@ AppServer::_CreateDesktop(uid_t userID, const char* targetScreen)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return desktop;
|
||||
return desktop.Detach();
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,12 +132,11 @@ CursorSet::AddCursor(BCursorID which, uint8 *data)
|
||||
if (data == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BBitmap *bitmap = _CursorDataToBitmap(data);
|
||||
ObjectDeleter<BBitmap> bitmap(_CursorDataToBitmap(data));
|
||||
BPoint hotspot(data[2], data[3]);
|
||||
|
||||
status_t result = AddCursor(which, bitmap, hotspot);
|
||||
status_t result = AddCursor(which, bitmap.Get(), hotspot);
|
||||
|
||||
delete bitmap;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <shared_cursor_area.h>
|
||||
|
||||
#include <AppMisc.h>
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
@ -262,12 +263,12 @@ InputServerStream::_MessageFromPort(BMessage** _message, bigtime_t timeout)
|
||||
|
||||
// we have the message, now let's unflatten it
|
||||
|
||||
BMessage* message = new BMessage(code);
|
||||
if (message == NULL)
|
||||
ObjectDeleter<BMessage> message(new BMessage(code));
|
||||
if (message.Get() == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
if (buffer == NULL) {
|
||||
*_message = message;
|
||||
*_message = message.Detach();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -278,11 +279,10 @@ InputServerStream::_MessageFromPort(BMessage** _message, bigtime_t timeout)
|
||||
printf("Unflatten event failed: %s, port message code was: %" B_PRId32
|
||||
" - %c%c%c%c\n", strerror(status), code, (int8)(code >> 24),
|
||||
(int8)(code >> 16), (int8)(code >> 8), (int8)code);
|
||||
delete message;
|
||||
return status;
|
||||
}
|
||||
|
||||
*_message = message;
|
||||
*_message = message.Detach();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user