workaround mono url open bug

- closes #4379
This commit is contained in:
Morilli 2025-06-28 20:34:33 +02:00
parent 4eec7acaab
commit d1fd6c30b9
12 changed files with 52 additions and 24 deletions

View File

@ -1,5 +1,7 @@
using System.Windows.Forms;
using BizHawk.Common;
namespace BizHawk.Client.DiscoHawk
{
public partial class About : Form
@ -12,7 +14,7 @@ namespace BizHawk.Client.DiscoHawk
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(e.LinkText);
Util.OpenUrlExternal(e.LinkText);
}
private void button1_Click(object sender, EventArgs e)

View File

@ -155,7 +155,7 @@ namespace BizHawk.Client.EmuHawk
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(FFmpegService.Url);
Util.OpenUrlExternal(FFmpegService.Url);
}
}
}

View File

@ -1,4 +1,3 @@
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
@ -22,7 +21,7 @@ namespace BizHawk.Client.EmuHawk
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
linkLabel1.LinkVisited = true;
Process.Start(VersionInfo.HomePage);
Util.OpenUrlExternal(VersionInfo.HomePage);
}
private void OK_Click(object sender, EventArgs e)
@ -51,12 +50,12 @@ namespace BizHawk.Client.EmuHawk
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
=> Process.Start((string) ((Control) sender).Tag);
=> Util.OpenUrlExternal((string) ((Control) sender).Tag);
private void btnCopyHash_Click(object sender, EventArgs e)
=> Clipboard.SetText(VersionInfo.GIT_HASH);
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
=> Process.Start(VersionInfo.BizHawkContributorsListURI);
=> Util.OpenUrlExternal(VersionInfo.BizHawkContributorsListURI);
}
}

View File

@ -1,4 +1,6 @@
using System.Windows.Forms;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
@ -33,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
private void CoreUrlLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
CoreUrlLink.LinkVisited = true;
System.Diagnostics.Process.Start(_url);
Util.OpenUrlExternal(_url);
}
}
}

View File

@ -1174,12 +1174,12 @@ namespace BizHawk.Client.EmuHawk
private void OnlineHelpMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://tasvideos.org/BizHawk");
Util.OpenUrlExternal("https://tasvideos.org/BizHawk");
}
private void ForumsMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://tasvideos.org/Forum/Subforum/64");
Util.OpenUrlExternal("https://tasvideos.org/Forum/Subforum/64");
}
private void FeaturesMenuItem_Click(object sender, EventArgs e)
@ -1502,12 +1502,7 @@ namespace BizHawk.Client.EmuHawk
if (result == true)
{
System.Threading.ThreadPool.QueueUserWorkItem(s =>
{
using (System.Diagnostics.Process.Start(VersionInfo.HomePage))
{
}
});
Util.OpenUrlExternal(VersionInfo.HomePage);
}
else if (result == false)
{

View File

@ -159,7 +159,7 @@ namespace BizHawk.Client.EmuHawk
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(_url);
Util.OpenUrlExternal(_url);
}
}
}

View File

@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Windows.Forms;
using BizHawk.Common;
namespace BizHawk.Client.EmuHawk
{
/// <summary>
@ -32,7 +33,7 @@ namespace BizHawk.Client.EmuHawk
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://retroachievements.org/createaccount.php");
Util.OpenUrlExternal("https://retroachievements.org/createaccount.php");
}
}
}

View File

@ -368,7 +368,7 @@ namespace BizHawk.Client.EmuHawk
private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("https://tasvideos.org/Bizhawk/DisplayConfig");
Util.OpenUrlExternal("https://tasvideos.org/Bizhawk/DisplayConfig");
}
private void Label13_Click(object sender, EventArgs e)

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@ -1302,7 +1301,7 @@ namespace BizHawk.Client.EmuHawk
private void HelpToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://tasvideos.org/Bizhawk/BasicBot");
Util.OpenUrlExternal("https://tasvideos.org/Bizhawk/BasicBot");
}
private void InvisibleEmulationCheckBox_CheckedChanged(object sender, EventArgs e)

View File

@ -10,6 +10,7 @@ using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.Properties;
using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Common;
using BizHawk.Common.CollectionExtensions;
using BizHawk.Common.PathExtensions;
using BizHawk.Common.StringExtensions;
@ -1185,7 +1186,7 @@ namespace BizHawk.Client.EmuHawk
private void OnlineDocsMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://tasvideos.org/BizHawk/LuaFunctions");
Util.OpenUrlExternal("https://tasvideos.org/BizHawk/LuaFunctions");
}
private void ScriptListContextMenu_Opening(object sender, CancelEventArgs e)

View File

@ -1337,12 +1337,12 @@ namespace BizHawk.Client.EmuHawk
private void TASEditorManualOnlineMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.fceux.com/web/help/taseditor/");
Util.OpenUrlExternal("http://www.fceux.com/web/help/taseditor/");
}
private void ForumThreadMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://tasvideos.org/Forum/Topics/13505");
Util.OpenUrlExternal("https://tasvideos.org/Forum/Topics/13505");
}
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
@ -303,5 +304,33 @@ namespace BizHawk.Common
bw.Write(data);
}
}
// Process.Start does not correctly handle urls in mono version pre-6.12.0.122,
// so we use an explicit function handling it instead
public static void OpenUrlExternal(string url)
{
if (OSTailoredCode.IsUnixHost)
{
string[] apps = OSTailoredCode.CurrentOS is OSTailoredCode.DistinctOS.macOS
? [ "open" ]
: [ "xdg-open", "gnome-open", "kfmclient" ];
foreach (string app in apps)
{
try
{
Process.Start(app, url);
}
catch (Win32Exception)
{
continue;
}
}
}
else
{
Process.Start(url);
}
}
}
}