From 13a1e96f92e51c26dd9f4e5a7444e4b0d8edd3b2 Mon Sep 17 00:00:00 2001 From: David Surovell Date: Sat, 28 Jan 2006 18:06:09 +0000 Subject: [PATCH] improved LaunchDefaultBrowser on FreeBSD systems by using the BROWSER env var when no HTML file MIME mapping is found git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37199 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/utilscmn.cpp | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index e259d39066..fdda0694d9 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -621,9 +621,10 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags) SInt32 endSel; err = ICStart(&inst, 'STKA'); // put your app creator code here - if (err == noErr) { + if (err == noErr) + { #if !TARGET_CARBON - err = ICFindConfigFile(inst, 0, nil); + err = ICFindConfigFile(inst, 0, NULL); #endif if (err == noErr) { @@ -644,31 +645,34 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags) } #elif wxUSE_MIMETYPE // Non-windows way - wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension (_T("html")); + bool ok = false; + wxString cmd; + + wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("html")); if ( ft ) { wxString mt; ft->GetMimeType(&mt); - wxString cmd; - bool ok = ft->GetOpenCommand(&cmd, wxFileType::MessageParameters(url)); + ok = ft->GetOpenCommand(&cmd, wxFileType::MessageParameters(url)); delete ft; - - if ( !ok || cmd.empty() ) - { - // fallback to checking for the BROWSER environment variable - cmd = wxGetenv(wxT("BROWSER")); - if ( !cmd.empty() ) - cmd << _T(' ') << url; - } - - if ( !cmd.empty() && wxExecute(cmd) ) - return true; } - else // no file type for html extension + + if ( !ok || cmd.empty() ) { - wxLogError(_T("No default application configured for HTML files.")); + // fallback to checking for the BROWSER environment variable + cmd = wxGetenv(wxT("BROWSER")); + if ( !cmd.empty() ) + cmd << _T(' ') << url; } + + ok = ( !cmd.empty() && wxExecute(cmd) ); + if (ok) + return ok; + + // no file type for HTML extension + wxLogError(_T("No default application configured for HTML files.")); + #endif // !wxUSE_MIMETYPE && !__WXMSW__ wxLogSysError(_T("Failed to open URL \"%s\" in default browser."), -- 2.45.2