From 02addf135d2c74a01930dadba985996c352a2ba6 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 5 Oct 2020 18:01:47 -0400 Subject: [PATCH] url: Another attempt at WinRT implementation. --- src/misc/winrt/SDL_sysurl.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/misc/winrt/SDL_sysurl.cpp b/src/misc/winrt/SDL_sysurl.cpp index a2c0fc633..f1314e998 100644 --- a/src/misc/winrt/SDL_sysurl.cpp +++ b/src/misc/winrt/SDL_sysurl.cpp @@ -21,22 +21,21 @@ #include +#include "../../core/windows/SDL_windows.h" #include "../SDL_sysurl.h" int SDL_SYS_OpenURL(const char *url) { - auto uri = ref new Windows::Foundation::Uri(url); - concurrency::task launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri)); - int retval = -1; - launchUriOperation.then([](bool success) { - if (success) { - retval = 0; - } else { - retval = SDL_SetError("URL failed to launch"); - } - }); - return retval; + WCHAR *wurl = WIN_UTF8ToString(url); + if (wurl == NULL) { + return SDL_OutOfMemory(); + } + + auto uri = ref new Windows::Foundation::Uri(wurl); + SDL_free(wurl); + launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri)); + return 0; } /* vi: set ts=4 sw=4 expandtab: */