Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Remove carbon #1012

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Remove carbon #1012

wants to merge 2 commits into from

Conversation

iainx
Copy link
Contributor

@iainx iainx commented Aug 26, 2015

Second pass at removing the use of Carbon for the ApplicationEvents, instead relying on the Cocoa application delegate methods instead.

Fixes the issue from the previous attempt that starting MonoDevelop from the command line or from inside itself would create a blank MonoDevelop solution in the build/bin directory due to Cocoa interpreting the MonoDevelop.exe from the command line mono-sgen MonoDevelop.exe as a filename

@Therzok
Copy link
Contributor

Therzok commented Aug 26, 2015

lgtm.

@iainx iainx closed this Aug 26, 2015
@iainx iainx reopened this Aug 26, 2015
@iainx iainx closed this Aug 26, 2015
@iainx iainx reopened this Aug 26, 2015
// Therefore we strip any .exe filenames here so we don't attempt to create a new solution based on
// that name.

IdeApp.OpenFiles (e.Filenames.Where (filename => !filename.EndsWith (".exe")).Select (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XS can open .exe files as a solution, so you can run and debug them. So exe files should not be filtered.

@iainx
Copy link
Contributor Author

iainx commented Aug 26, 2015

Ah, ok. I'll have a think how we can work around it then.

@iainx
Copy link
Contributor Author

iainx commented Sep 2, 2015

@slluis filtering .exe files in the OpenFiles event from the AppDelegate doesn't break loading .exe files from the Open File dialog. The only way a .exe file is passed to the OpenFiles delegate is when running from the command line as make run or running from inside of MD itself.

Would you prefer that I just filter out MonoDevelop.exe here instead of *.exe?

@iainx
Copy link
Contributor Author

iainx commented Sep 3, 2015

So this filters out /build/bin/MonoDevelop.exe but nothing else

@slluis
Copy link
Member

slluis commented Sep 4, 2015

Is this problem specific to starting MD using mono-sgen? doesn't this happen when running from an app bundle?

@alanmcgovern
Copy link
Member

There are a few ways MD can be started on macos:
make run-sgen in a local build which turns into a mono-sgen monodevelop.exe call
make run-boehm in a local build which turns into a mono-boehm monodevelop.exe call.
make run which builds the native launcher and turns into a ./monodevelop call (like an app bundle)
open MonoDevelop.app or double click the app bundle

If you need to filter exe's, maybe you could ignore any file which is the same as the entry executable ( Assembly.GetEntryAssembly () ). That should give you the behaviour you need without hardcoding specific names or always ignoring all .exe files. As long as the right thing happens in the above 4 cases then we should be OK

@alanmcgovern
Copy link
Member

Oh, i just remembered that debugging MD inside MD is a fifth way... :P Either way, that should work!

This patch removes the use of Carbon for ApplicationEvents in MacPlatform
@iainx iainx force-pushed the remove-carbon branch 2 times, most recently from 294bec9 to 24c743f Compare September 24, 2015 14:25
@iainx
Copy link
Contributor Author

iainx commented Sep 24, 2015

@alanmcgovern yup, using the entry assembly location works. This was only an issue for when we run MD via make run-sgen/boehm or from debugging inside MD itself. The other methods were not affected

@alanmcgovern
Copy link
Member

sweet :)

// that MonoDevelop.exe is the first filename to be passed when the app starts up
// Therefore we strip any filenames that match the assembly that we started from.
var entryAsm = Assembly.GetEntryAssembly ();
Console.WriteLine ("Current ass {0}", entryAsm.Location);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some forgotten debug code.

cough.

When Mono applications are run from the commandline or from within XS itself, the Cocoa system parses argv, stripping the executable name and any option arguments and passes the rest of the arguments to OpenFiles.

Unfortunately for mono applications (for example "mono-sgen MonoDevelop.exe") the executable name is interpreted as a filename and so OpenFiles receives it in the array.

We solve this by ignoring any filename that matches the Entry Assembly's location
@Therzok
Copy link
Contributor

Therzok commented May 5, 2016

Bump on this and #1065.

@Therzok
Copy link
Contributor

Therzok commented Jul 18, 2017

What are we missing here?

@@ -326,82 +327,77 @@ void PatchGtkTheme ()

void GlobalSetup ()
{
var appDelegate = (Xwt.Mac.AppDelegate)NSApplication.SharedApplication.Delegate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to cast it to Xwt.Mac.AppDelegate or can we cast it to a plain NSApplicationDelegate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Terminating, Unhidden, OpenUrl and OpenFilesRequest events are Xwt.Mac.AppDelegate events, not NSApplicationDelegate

Base automatically changed from master to main March 9, 2021 14:17
@akoeplinger akoeplinger changed the base branch from main to master March 15, 2021 17:02
Base automatically changed from master to main March 15, 2021 17:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants