diff --git a/src/common/MediaFactory.hxx b/src/common/MediaFactory.hxx index 851efc087..54d82cdbd 100644 --- a/src/common/MediaFactory.hxx +++ b/src/common/MediaFactory.hxx @@ -181,6 +181,15 @@ class MediaFactory #endif } + static bool openURL(const string& url) + { + #if defined(SDL_SUPPORT) + return SDLOpenURL(url); + #else + return false; + #endif + } + private: // Following constructors and assignment operators not supported MediaFactory() = delete; diff --git a/src/common/SDL_lib.hxx b/src/common/SDL_lib.hxx index edc92375a..90be6ebce 100644 --- a/src/common/SDL_lib.hxx +++ b/src/common/SDL_lib.hxx @@ -54,4 +54,13 @@ static inline string SDLVersion() return buf.str(); } +static inline bool SDLOpenURL(const string& url) +{ +#if SDL_VERSION_ATLEAST(2,0,14) + return SDL_OpenURL(url.c_str()) == 0; +#else + return false; +#endif +} + #endif // SDL_LIB_HXX diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 90ee3dafe..9e4aac8bf 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -36,6 +36,7 @@ #include "Vec.hxx" #include "TIA.hxx" +#include "MediaFactory.hxx" /* * TODO list @@ -183,13 +184,8 @@ const string Dialog::getHelpURL() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::openHelp() { - if(hasHelp()) - { - if(SDL_OpenURL(getHelpURL().c_str())) - { - cerr << "error opening URL " << getHelpURL() << endl; - } - } + if(hasHelp() && !MediaFactory::openURL(getHelpURL())) + cerr << "error opening URL " << getHelpURL() << endl; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -