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:
authortherzok <marius.ungureanu@xamarin.com>2019-07-16 16:39:56 +0300
committertherzok <marius.ungureanu@xamarin.com>2019-07-16 16:41:54 +0300
commitea6f9578adcdf9c8e2a2a6a1173f25610e87d722 (patch)
treee2f12710e832d2fc09a30c9f40503afb9b3f16bb /main
parent139bdca5adec8f471638ef48418e6bf872888987 (diff)
[Mac] Remove IdeInstanceConnection socket on Mac when running from bundle
Fixes VSTS #944831 - [FATAL] System.UnauthorizedAccessException exception in System.IO.File.Delete()
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs21
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeInstanceConnection.cs15
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs4
3 files changed, 34 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..406d70041b 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs
@@ -1530,6 +1530,27 @@ 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;
+ Console.WriteLine (result);
+
+ 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..a0b651f537 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,17 @@ 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)
{
+ 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 +63,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 +84,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))