Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMarius Ungureanu <marius.ungureanu@xamarin.com>2019-07-16 18:42:33 +0300
committerGitHub <noreply@github.com>2019-07-16 18:42:33 +0300
commit98abbc0550bf84e6480d6541cd226bbf369ee421 (patch)
treebe12198a5237c8084172933c6332f82ffdc33b48 /main
parent560a020231b345761fadfa63f99ddd8a64d6c1ad (diff)
parenta239427cca1c634407c11a9ff9260bc8287ac140 (diff)
Merge pull request #8209 from mono/vsts944831
[Mac] Remove IdeInstanceConnection socket on Mac when running from bundle Fixes VSTS #944831 - [FATAL] System.UnauthorizedAccessException exception in System.IO.File.Delete() Fixes VSTS #938537 - [Watson] SIGABRT due to IdeInstanceConnection.StartListening
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs20
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeInstanceConnection.cs18
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs4
3 files changed, 36 insertions, 6 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs
index a6c2af0429..0a25ce6227 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs
@@ -1530,6 +1530,26 @@ namespace MonoDevelop.Components
#endif
}
+ internal static bool IsRunFromBundle ()
+ {
+ bool result = false;
+#if MAC
+ IntPtr mainBundle = GetMainBundle ();
+ var sel_bundleIdentifier = ObjCRuntime.Selector.GetHandle ("bundleIdentifier");
+
+ result = objc_msgSend_IntPtr (mainBundle, sel_bundleIdentifier) != IntPtr.Zero;
+
+ static IntPtr GetMainBundle ()
+ {
+ var class_runningApplication = ObjCRuntime.Class.GetHandle ("NSBundle");
+ var sel_mainBundle = ObjCRuntime.Selector.GetHandle ("mainBundle");
+
+ return objc_msgSend_IntPtr (class_runningApplication, sel_mainBundle);
+ }
+#endif
+ return result;
+ }
+
[DllImport ("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_get_current_event ();
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeInstanceConnection.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeInstanceConnection.cs
index 8e476b33c9..8e9ddcc394 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeInstanceConnection.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeInstanceConnection.cs
@@ -32,7 +32,6 @@ using System.Text;
using Mono.Unix;
using MonoDevelop.Core;
using MonoDevelop.Ide.Extensions;
-using MonoDevelop.Ide.Gui;
namespace MonoDevelop.Ide
{
@@ -41,13 +40,20 @@ namespace MonoDevelop.Ide
const int ipcBasePort = 40000;
string socket_filename;
- Socket listen_socket = null;
+ Socket listen_socket;
EndPoint ep;
public event EventHandler<FileEventArgs> FileOpenRequested;
- public void Initialize (bool ipcTcp)
+ public IdeInstanceConnection (bool ipcTcp)
{
+ // macOS has native support for opening files in an open instance
+ // via AppleEvents for applications distributed as bundles, so disable
+ // this support.
+ if (Platform.IsMac && Components.GtkWorkarounds.IsRunFromBundle ()) {
+ return;
+ }
+
if (ipcTcp) {
listen_socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
ep = new IPEndPoint (IPAddress.Loopback, ipcBasePort + HashSdbmBounded (Environment.UserName));
@@ -60,6 +66,9 @@ namespace MonoDevelop.Ide
public bool TryConnect (StartupInfo startupInfo)
{
+ if (listen_socket == null)
+ return false;
+
try {
StringBuilder builder = new StringBuilder ();
foreach (var file in startupInfo.RequestedFileList) {
@@ -78,6 +87,9 @@ namespace MonoDevelop.Ide
public void StartListening ()
{
+ if (listen_socket == null)
+ return;
+
// FIXME: we should probably track the last 'selected' one
// and do this more cleanly
try {
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs
index e4318f6f7b..8381108330 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs
@@ -32,7 +32,6 @@ using System;
using System.IO;
using System.Reflection;
using System.Threading;
-using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
@@ -193,8 +192,7 @@ namespace MonoDevelop.Ide
}
}
- instanceConnection = new IdeInstanceConnection ();
- instanceConnection.Initialize (options.IpcTcp);
+ instanceConnection = new IdeInstanceConnection (options.IpcTcp);
// If not opening a combine, connect to existing monodevelop and pass filename(s) and exit
if (!options.NewWindow && startupInfo.HasFiles && instanceConnection.TryConnect (startupInfo))