mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +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/Entry.h>
|
||||||
#include <storage/File.h>
|
#include <storage/File.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "SDL_BApp.h" /* SDL_BApp class definition */
|
#include "SDL_BApp.h" /* SDL_BApp class definition */
|
||||||
#include "SDL_BeApp.h"
|
#include "SDL_BeApp.h"
|
||||||
@@ -51,8 +52,9 @@ const char *signature = "application/x-SDL-executable";
|
|||||||
|
|
||||||
static int StartBeApp(void *unused)
|
static int StartBeApp(void *unused)
|
||||||
{
|
{
|
||||||
BApplication *App;
|
std::unique_ptr<BApplication> App;
|
||||||
|
|
||||||
|
(void)unused;
|
||||||
// dig resources for correct signature
|
// dig resources for correct signature
|
||||||
image_info info;
|
image_info info;
|
||||||
int32 cookie = 0;
|
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();
|
App->Run();
|
||||||
delete App;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,6 +45,7 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
enum
|
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:
|
// 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."
|
// "You need a valid BApplication object before interacting with the app_server."
|
||||||
// "2 BApplication objects were created. Only one is allowed."
|
// "2 BApplication objects were created. Only one is allowed."
|
||||||
BApplication *application = NULL;
|
std::unique_ptr<BApplication> application;
|
||||||
if (be_app == NULL) {
|
if (be_app == NULL) {
|
||||||
application = new(std::nothrow) BApplication(signature);
|
application = std::unique_ptr<BApplication>(new(std::nothrow) BApplication(signature));
|
||||||
if (application == NULL) {
|
if (application == NULL) {
|
||||||
return SDL_SetError("Cannot create the BApplication object. Lack of memory?");
|
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;
|
delete messageBox;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (application != NULL) {
|
|
||||||
delete application;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize button by real pushed value then.
|
// Initialize button by real pushed value then.
|
||||||
*buttonid = pushedButton;
|
*buttonid = pushedButton;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user