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 <[email protected]>
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
|
#include <AutoDeleter.h>
|
||||||
#include <LaunchRoster.h>
|
#include <LaunchRoster.h>
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
|
|
||||||
@@ -174,20 +175,19 @@ Desktop*
|
|||||||
AppServer::_CreateDesktop(uid_t userID, const char* targetScreen)
|
AppServer::_CreateDesktop(uid_t userID, const char* targetScreen)
|
||||||
{
|
{
|
||||||
BAutolock locker(fDesktopLock);
|
BAutolock locker(fDesktopLock);
|
||||||
Desktop* desktop = NULL;
|
ObjectDeleter<Desktop> desktop;
|
||||||
try {
|
try {
|
||||||
desktop = new Desktop(userID, targetScreen);
|
desktop.SetTo(new Desktop(userID, targetScreen));
|
||||||
|
|
||||||
status_t status = desktop->Init();
|
status_t status = desktop->Init();
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
status = desktop->Run();
|
status = desktop->Run();
|
||||||
if (status == B_OK && !fDesktops.AddItem(desktop))
|
if (status == B_OK && !fDesktops.AddItem(desktop.Get()))
|
||||||
status = B_NO_MEMORY;
|
status = B_NO_MEMORY;
|
||||||
|
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
syslog(LOG_ERR, "Cannot initialize Desktop object: %s\n",
|
syslog(LOG_ERR, "Cannot initialize Desktop object: %s\n",
|
||||||
strerror(status));
|
strerror(status));
|
||||||
delete desktop;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@@ -195,7 +195,7 @@ AppServer::_CreateDesktop(uid_t userID, const char* targetScreen)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return desktop;
|
return desktop.Detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -132,12 +132,11 @@ CursorSet::AddCursor(BCursorID which, uint8 *data)
|
|||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
BBitmap *bitmap = _CursorDataToBitmap(data);
|
ObjectDeleter<BBitmap> bitmap(_CursorDataToBitmap(data));
|
||||||
BPoint hotspot(data[2], data[3]);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <shared_cursor_area.h>
|
#include <shared_cursor_area.h>
|
||||||
|
|
||||||
#include <AppMisc.h>
|
#include <AppMisc.h>
|
||||||
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -262,12 +263,12 @@ InputServerStream::_MessageFromPort(BMessage** _message, bigtime_t timeout)
|
|||||||
|
|
||||||
// we have the message, now let's unflatten it
|
// we have the message, now let's unflatten it
|
||||||
|
|
||||||
BMessage* message = new BMessage(code);
|
ObjectDeleter<BMessage> message(new BMessage(code));
|
||||||
if (message == NULL)
|
if (message.Get() == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
*_message = message;
|
*_message = message.Detach();
|
||||||
return B_OK;
|
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
|
printf("Unflatten event failed: %s, port message code was: %" B_PRId32
|
||||||
" - %c%c%c%c\n", strerror(status), code, (int8)(code >> 24),
|
" - %c%c%c%c\n", strerror(status), code, (int8)(code >> 24),
|
||||||
(int8)(code >> 16), (int8)(code >> 8), (int8)code);
|
(int8)(code >> 16), (int8)(code >> 8), (int8)code);
|
||||||
delete message;
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
*_message = message;
|
*_message = message.Detach();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user