mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
Haiku modernizing a bit the C++ code with C++11 heuristics
with BApplication
This commit is contained in:

committed by
Sam Lantinga

parent
2897de9efc
commit
d73f2d76a0
@@ -30,6 +30,7 @@
|
||||
#include <storage/Entry.h>
|
||||
#include <storage/File.h>
|
||||
#include <unistd.h>
|
||||
#include <memory>
|
||||
|
||||
#include "SDL_BApp.h" /* SDL_BApp class definition */
|
||||
#include "SDL_BeApp.h"
|
||||
@@ -51,8 +52,9 @@ const char *signature = "application/x-SDL-executable";
|
||||
|
||||
static int StartBeApp(void *unused)
|
||||
{
|
||||
BApplication *App;
|
||||
std::unique_ptr<BApplication> App;
|
||||
|
||||
(void)unused;
|
||||
// dig resources for correct signature
|
||||
image_info info;
|
||||
int32 cookie = 0;
|
||||
@@ -69,10 +71,9 @@ static int StartBeApp(void *unused)
|
||||
}
|
||||
}
|
||||
|
||||
App = new SDL_BApp(signature);
|
||||
App = std::unique_ptr<BApplication>(new SDL_BApp(signature));
|
||||
|
||||
App->Run();
|
||||
delete App;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include <new>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -355,9 +356,9 @@ HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
// because it is possible to create a MessageBox from another thread. This fixes the following errors:
|
||||
// "You need a valid BApplication object before interacting with the app_server."
|
||||
// "2 BApplication objects were created. Only one is allowed."
|
||||
BApplication *application = NULL;
|
||||
std::unique_ptr<BApplication> application;
|
||||
if (be_app == NULL) {
|
||||
application = new(std::nothrow) BApplication(signature);
|
||||
application = std::unique_ptr<BApplication>(new(std::nothrow) BApplication(signature));
|
||||
if (application == NULL) {
|
||||
return SDL_SetError("Cannot create the BApplication object. Lack of memory?");
|
||||
}
|
||||
@@ -381,10 +382,6 @@ HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
delete messageBox;
|
||||
}
|
||||
*/
|
||||
if (application != NULL) {
|
||||
delete application;
|
||||
}
|
||||
|
||||
// Initialize button by real pushed value then.
|
||||
*buttonid = pushedButton;
|
||||
|
||||
|
Reference in New Issue
Block a user