Skip to content

Crash after click on "Attribution" label on Linux (Mapsui Avalonia) #2463

@isergvb

Description

@isergvb

Mapsui Version
4.1.2

Mapsui Platform
Avalonia

Device
Linux

Describe the bug
App crashed after click on "Attribution" label.

System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'open' with working directory
..
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Mapsui.UI.Avalonia.MapControl.OpenBrowser(String url)
at Mapsui.UI.Avalonia.MapControl.HandleWidgetPointerUp(MPoint position, MPoint startPosition, Boolean leftButton, Int32 clickCount, Boolean shift)
at Mapsui.UI.Avalonia.MapControl.MapControl_PointerReleased(Object sender, PointerReleasedEventArgs e)
..

problem in method MapControl.cs:254

    public void OpenBrowser(string url)
    {
      using (Process.Start(new ProcessStartInfo()
      {
        FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? url : "open",
        Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"-e {url}" : "",
        CreateNoWindow = true,
        UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
      })) { }
    }

"open" - not exists in regular Linux distibs,
behaviors like a Windows is fix the problem

    public void OpenBrowser(string url)
    {
       using (Process.Start(new ProcessStartInfo()
       {
           FileName = !RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? url : "open",
           Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"-e {url}" : "",
           CreateNoWindow = true,
           UseShellExecute = !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
       })) { }
    }

To Reproduce
Click on "Attribution" label.

Expected behavior
No crash )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions