Change OS::initialize signature to return Error (fix segfault on x11)
This commit is contained in:
parent
99eb394a5f
commit
e315c94900
|
@ -121,7 +121,7 @@ protected:
|
|||
void add_logger(Logger *p_logger);
|
||||
|
||||
virtual void initialize_core() = 0;
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) = 0;
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) = 0;
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop) = 0;
|
||||
virtual void delete_main_loop() = 0;
|
||||
|
|
|
@ -55,7 +55,7 @@ protected:
|
|||
|
||||
virtual void initialize_core();
|
||||
virtual int unix_initialize_audio(int p_audio_driver);
|
||||
//virtual void initialize(int p_video_driver,int p_audio_driver);
|
||||
//virtual Error initialize(int p_video_driver,int p_audio_driver);
|
||||
|
||||
virtual void finalize_core();
|
||||
|
||||
|
|
|
@ -983,7 +983,10 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
|||
Thread::_main_thread_id = p_main_tid_override;
|
||||
}
|
||||
|
||||
OS::get_singleton()->initialize(video_mode, video_driver_idx, audio_driver_idx);
|
||||
Error err = OS::get_singleton()->initialize(video_mode, video_driver_idx, audio_driver_idx);
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
if (init_use_custom_pos) {
|
||||
OS::get_singleton()->set_window_position(init_custom_pos);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ void OS_Android::set_opengl_extensions(const char *p_gl_extensions) {
|
|||
gl_extensions = p_gl_extensions;
|
||||
}
|
||||
|
||||
void OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
use_gl2 = p_video_driver != 1;
|
||||
|
||||
|
@ -146,6 +146,8 @@ void OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
|
|||
input->set_fallback_mapping("Default Android Gamepad");
|
||||
|
||||
//power_manager = memnew(power_android);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void OS_Android::set_main_loop(MainLoop *p_main_loop) {
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
virtual const char *get_audio_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize_core();
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
virtual void delete_main_loop();
|
||||
|
|
|
@ -79,7 +79,7 @@ const char *OS_Haiku::get_video_driver_name(int p_driver) const {
|
|||
return "GLES3";
|
||||
}
|
||||
|
||||
void OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
main_loop = NULL;
|
||||
current_video_mode = p_desired;
|
||||
|
||||
|
@ -114,7 +114,7 @@ void OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_
|
|||
|
||||
visual_server = memnew(VisualServerRaster(rasterizer));
|
||||
|
||||
ERR_FAIL_COND(!visual_server);
|
||||
ERR_FAIL_COND(!visual_server, ERR_UNAVAILABLE);
|
||||
|
||||
// TODO: enable multithreaded VS
|
||||
/*
|
||||
|
@ -132,6 +132,8 @@ void OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_
|
|||
AudioDriverManager::initialize(p_audio_driver);
|
||||
|
||||
power_manager = memnew(PowerHaiku);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void OS_Haiku::finalize() {
|
||||
|
|
|
@ -66,7 +66,7 @@ protected:
|
|||
virtual int get_video_driver_count() const;
|
||||
virtual const char *get_video_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual void finalize();
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
|
|
|
@ -97,7 +97,7 @@ void OSIPhone::initialize_core() {
|
|||
set_data_dir(data_dir);
|
||||
};
|
||||
|
||||
void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
supported_orientations = 0;
|
||||
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_horizontal", true) ? 1 : 0) << LandscapeLeft);
|
||||
|
@ -144,6 +144,8 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_
|
|||
//icloud->connect();
|
||||
#endif
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("iOS", memnew(iOS)));
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
MainLoop *OSIPhone::get_main_loop() const {
|
||||
|
|
|
@ -87,7 +87,7 @@ private:
|
|||
virtual const char *get_video_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize_core();
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
virtual MainLoop *get_main_loop() const;
|
||||
|
|
|
@ -419,7 +419,7 @@ void send_notification(int notif) {
|
|||
}
|
||||
}
|
||||
|
||||
void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
print_line("Init OS");
|
||||
|
||||
|
@ -429,7 +429,7 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i
|
|||
attributes.antialias = false;
|
||||
attributes.majorVersion = 2;
|
||||
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context(NULL, &attributes);
|
||||
ERR_FAIL_COND(emscripten_webgl_make_context_current(ctx) != EMSCRIPTEN_RESULT_SUCCESS);
|
||||
ERR_FAIL_COND(emscripten_webgl_make_context_current(ctx) != EMSCRIPTEN_RESULT_SUCCESS, ERR_UNAVAILABLE);
|
||||
|
||||
video_mode = p_desired;
|
||||
// can't fulfil fullscreen request due to browser security
|
||||
|
@ -507,6 +507,8 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i
|
|||
#undef EM_CHECK
|
||||
|
||||
visual_server->init();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void OS_JavaScript::set_main_loop(MainLoop *p_main_loop) {
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
virtual const char *get_audio_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize_core();
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
virtual void delete_main_loop();
|
||||
|
|
|
@ -123,7 +123,7 @@ protected:
|
|||
virtual const char *get_video_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize_core();
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual void finalize();
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
|
|
|
@ -976,7 +976,7 @@ static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplay
|
|||
displays_arrangement_dirty = true;
|
||||
}
|
||||
|
||||
void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
/*** OSX INITIALIZATION ***/
|
||||
/*** OSX INITIALIZATION ***/
|
||||
|
@ -1013,7 +1013,7 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
|
|||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
|
||||
ERR_FAIL_COND(window_object == nil);
|
||||
ERR_FAIL_COND(window_object == nil, ERR_UNAVAILABLE);
|
||||
|
||||
window_view = [[GodotContentView alloc] init];
|
||||
|
||||
|
@ -1100,11 +1100,11 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
|
|||
#undef ADD_ATTR2
|
||||
|
||||
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
ERR_FAIL_COND(pixelFormat == nil);
|
||||
ERR_FAIL_COND(pixelFormat == nil, ERR_UNAVAILABLE);
|
||||
|
||||
context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
|
||||
|
||||
ERR_FAIL_COND(context == nil);
|
||||
ERR_FAIL_COND(context == nil, ERR_UNAVAILABLE);
|
||||
|
||||
[context setView:window_view];
|
||||
|
||||
|
@ -1148,6 +1148,8 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
|
|||
_ensure_user_data_dir();
|
||||
|
||||
restore_rect = Rect2(get_window_position(), get_window_size());
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void OS_OSX::finalize() {
|
||||
|
|
|
@ -47,7 +47,7 @@ const char *OS_Server::get_video_driver_name(int p_driver) const {
|
|||
return "Dummy";
|
||||
}
|
||||
|
||||
void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
args = OS::get_singleton()->get_cmdline_args();
|
||||
current_videomode = p_desired;
|
||||
|
@ -67,13 +67,15 @@ void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p
|
|||
spatial_sound_2d_server = memnew(SpatialSound2DServerSW);
|
||||
spatial_sound_2d_server->init();
|
||||
|
||||
ERR_FAIL_COND(!visual_server);
|
||||
ERR_FAIL_COND(!visual_server, ERR_UNAVAILABLE);
|
||||
|
||||
visual_server->init();
|
||||
|
||||
input = memnew(InputDefault);
|
||||
|
||||
_ensure_user_data_dir();
|
||||
|
||||
return OK;
|
||||
}
|
||||
void OS_Server::finalize() {
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ protected:
|
|||
virtual int get_video_driver_count() const;
|
||||
virtual const char *get_video_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual void finalize();
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
|
|
|
@ -194,7 +194,7 @@ void OSUWP::screen_size_changed() {
|
|||
gl_context->reset();
|
||||
};
|
||||
|
||||
void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
main_loop = NULL;
|
||||
outside = true;
|
||||
|
@ -297,6 +297,8 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud
|
|||
display_request->RequestActive();
|
||||
|
||||
set_keep_screen_on(GLOBAL_DEF("display/window/keep_screen_on", true));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void OSUWP::set_clipboard(const String &p_text) {
|
||||
|
|
|
@ -158,7 +158,7 @@ protected:
|
|||
virtual const char *get_audio_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize_core();
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
virtual void delete_main_loop();
|
||||
|
|
|
@ -929,7 +929,7 @@ typedef enum _SHC_PROCESS_DPI_AWARENESS {
|
|||
SHC_PROCESS_PER_MONITOR_DPI_AWARE = 2
|
||||
} SHC_PROCESS_DPI_AWARENESS;
|
||||
|
||||
void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
main_loop = NULL;
|
||||
outside = true;
|
||||
|
@ -975,7 +975,7 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
|||
|
||||
if (!RegisterClassExW(&wc)) {
|
||||
MessageBox(NULL, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
|
||||
return; // Return
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
pre_fs_valid = true;
|
||||
|
@ -1045,7 +1045,7 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
|||
RECT rect;
|
||||
if (!GetClientRect(hWnd, &rect)) {
|
||||
MessageBoxW(NULL, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
|
||||
return; // Return FALSE
|
||||
return ERR_UNAVAILABLE;
|
||||
};
|
||||
video_mode.width = rect.right;
|
||||
video_mode.height = rect.bottom;
|
||||
|
@ -1063,7 +1063,7 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
|||
NULL, NULL, hInstance, NULL);
|
||||
if (!hWnd) {
|
||||
MessageBoxW(NULL, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
|
||||
return; // Return FALSE
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1127,6 +1127,8 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
|||
SetForegroundWindow(hWnd); // Slightly Higher Priority
|
||||
SetFocus(hWnd); // Sets Keyboard Focus To
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void OS_Windows::set_clipboard(const String &p_text) {
|
||||
|
|
|
@ -148,7 +148,7 @@ protected:
|
|||
virtual const char *get_audio_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize_core();
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
virtual void delete_main_loop();
|
||||
|
|
|
@ -100,7 +100,7 @@ void OS_X11::initialize_core() {
|
|||
OS_Unix::initialize_core();
|
||||
}
|
||||
|
||||
void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
long im_event_mask = 0;
|
||||
last_button_state = 0;
|
||||
|
@ -123,21 +123,24 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
|
|||
/** XLIB INITIALIZATION **/
|
||||
x11_display = XOpenDisplay(NULL);
|
||||
|
||||
if (!x11_display) {
|
||||
ERR_PRINT("X11 Display is not available");
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
char *modifiers = NULL;
|
||||
Bool xkb_dar = False;
|
||||
if (x11_display) {
|
||||
XAutoRepeatOn(x11_display);
|
||||
xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL);
|
||||
XAutoRepeatOn(x11_display);
|
||||
xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL);
|
||||
|
||||
// Try to support IME if detectable auto-repeat is supported
|
||||
if (xkb_dar == True) {
|
||||
// Try to support IME if detectable auto-repeat is supported
|
||||
if (xkb_dar == True) {
|
||||
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
// Xutf8LookupString will be used later instead of XmbLookupString before
|
||||
// the multibyte sequences can be converted to unicode string.
|
||||
modifiers = XSetLocaleModifiers("");
|
||||
// Xutf8LookupString will be used later instead of XmbLookupString before
|
||||
// the multibyte sequences can be converted to unicode string.
|
||||
modifiers = XSetLocaleModifiers("");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (modifiers == NULL) {
|
||||
|
@ -331,8 +334,8 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
|
|||
|
||||
AudioDriverManager::initialize(p_audio_driver);
|
||||
|
||||
ERR_FAIL_COND(!visual_server);
|
||||
ERR_FAIL_COND(x11_window == 0);
|
||||
ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(x11_window == 0, ERR_UNAVAILABLE);
|
||||
|
||||
XSetWindowAttributes new_attr;
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ protected:
|
|||
virtual const char *get_audio_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize_core();
|
||||
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
virtual void finalize();
|
||||
|
||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||
|
|
Loading…
Reference in New Issue