diff --git a/src/platform/ios.mm b/src/platform/ios.mm index f0c5bdb0..4006f285 100644 --- a/src/platform/ios.mm +++ b/src/platform/ios.mm @@ -768,6 +768,7 @@ void iosSetSafeAreaConstraints(SDLTerminal * term) { window_info.info.uikit.window.rootViewController = rootvc; sdlView = oldvc.view; viewController = vc; + [viewController retain]; // Remove the updateKeyboard method in the old view controller, as it glitches out the screen when opening/closing the keyboard method_setImplementation(class_getInstanceMethod([oldvc class], @selector(updateKeyboard)), [ViewController instanceMethodForSelector:@selector(updateKeyboard)]); // Set fullscreen mode, but only on devices without a notch @@ -781,18 +782,18 @@ void iosSetSafeAreaConstraints(SDLTerminal * term) { } void updateCloseButton() { - if (computers->empty()) return; + if (computers->empty() || !viewController) return; viewController.closeButton.enabled = computers->size() > 1 || (*renderTarget) != computers->front()->term; viewController.nextButton.enabled = renderTargets.size() > 1; viewController.previousButton.enabled = renderTargets.size() > 1; } void iOS_SetWindowTitle(SDL_Window * win, const char * title) { - viewController.navigationItem.title = [NSString stringWithCString:title encoding:NSASCIIStringEncoding]; + if (viewController) viewController.navigationItem.title = [NSString stringWithCString:title encoding:NSASCIIStringEncoding]; } void mobileResetModifiers() { - [viewController resetModifiers]; + if (viewController) [viewController resetModifiers]; } void handler(int sig) { @@ -907,7 +908,9 @@ static int mobile_restorePurchases(lua_State *L) { };*/ int mobile_luaopen(lua_State *L) { - luaL_register(L, "mobile", mobile_reg); + luaL_newlib(L, mobile_reg); + lua_pushvalue(L, -1); + lua_setglobal(L, "mobile"); /*lua_pushstring(L, "ios"); lua_newtable(L); for (luaL_Reg* r = ios_reg; r->name && r->func; r++) { diff --git a/src/util.hpp b/src/util.hpp index d16d5cd8..aca0ae08 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -40,7 +40,7 @@ template<> class std::hash: public std::hash {}; // for old compilers (see C++ LWG 3657) // NOTE: No idea if this MSVC check is correct - if you have issues, just update to the latest VS2022. -#if (defined(__GLIBCXX__) && __GLIBCXX__ < 20220426) || (defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 17000) || (defined(_MSC_FULL_VER) && _MSC_FULL_VER < 193200000) +#if (defined(__GLIBCXX__) && __GLIBCXX__ < 20220426) || (defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 170000) || (defined(_MSC_FULL_VER) && _MSC_FULL_VER < 193200000) template<> struct std::hash {size_t operator()(const path_t& path) const noexcept {return fs::hash_value(path);}}; #endif