Restart Fusion [update]

Moderator: SecondMan

User avatar
Movalex
Fusioneer
Posts: 113
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 27 times
Contact:

Restart Fusion [update]

#1

Post by Movalex » Thu Mar 21, 2019 9:40 am

Hi!
Restart Fusion produces additional Fusion icon in macOS's Dock.
Using killall instead of fusion:Quit() performs correct restart.

So this part:
  1. -- Create the Fusion launching command
  2. if platform == "Windows" then
  3.     command = "start \"\" " .. "\"" .. fusionApp .. "\" 2>&1 &"
  4. elseif platform == "Mac" then
  5.     command = "\"" .. fusionApp .. "\" 2>&1 &"
  6.     -- command = "open \"" .. fusionApp .. "\" 2>&1 &"
  7. else
  8.     command = "\"" .. fusionApp .. "\" 2>&1 &"
  9. end
  10.  
  11. obj:Comp():Print("[Launch Command] " .. tostring(command) .. "\n")
  12.  
  13. -- Start up a new instance of Fusion
  14. os.execute(command)
  15.  
  16. -- Quit the current Fusion session
  17. fusion:Quit()
is replaced with this:
  1. -- Create the Fusion launching command
  2. if platform == "Windows" then
  3.     command = "start \"\" " .. "\"" .. fusionApp .. "\" 2>&1 &"
  4.     -- Start up a new instance of Fusion
  5.     os.execute(command)
  6.     -- Quit the current Fusion session
  7.     fusion:Quit()
  8.  
  9. elseif platform == "Mac" then
  10.     command = "killall Fusion && ".."\"" .. fusionApp .."\" 2>&1"
  11.     os.execute(command)
  12. else
  13.     command = "\"" .. fusionApp .. "\" 2>&1 &"
  14.     -- Start up a new instance of Fusion
  15.     os.execute(command)
  16.     -- Quit the current Fusion session
  17.     fusion:Quit()
  18. end

Diffs: https://gitlab.com/WeSuckLess/Reactor/m ... 55ec9c29d1
You do not have the required permissions to view the files attached to this post.

User avatar
SecondMan
Site Admin
Posts: 3478
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 5
Location: Vancouver, Canada
Been thanked: 92 times
Contact:

Re: Restart Fusion [update]

#2

Post by SecondMan » Fri May 03, 2019 10:31 am

Hi @Movalex - thanks for the submission!

The script as it is now in Reactor starts another Fusion session, waits a moment, then uses the native Fusion quit command to cleanly exit and save all settings. This is the correct way to restart an application. The double icon is a reflection of that process, i.e. the MacOS dock shows an icon for any running process. If the process is quit then any unpinned icon closes. The icon is not permanent or persistent beyond the session.

By using killall() instead, you cause an unexpected crash of Fusion to kill the process instantly. Apart from considerations you'd have to make regarding preferences saving, multiple tabs of unsaved comp document saving, etc, this would also stop all concurrent running copies of any process called Fusion. So if the user had Fu 8, Fu 9 and Fu 16 open and ran your code in Fu 9 all of them would be stopped indiscriminately. This is not the intention of the restart script.

So I won't be merging this adjustment. But if you have a need to have a "crash Fusion" script, feel free to cook your own atom for that, of course :)


User avatar
SirEdric
Fusionator
Posts: 1873
Joined: Tue Aug 05, 2014 10:04 am
Answers: 2
Real name: Eric Westphal
Been thanked: 112 times
Contact:

Re: Restart Fusion [update]

#3

Post by SirEdric » Fri May 03, 2019 10:50 am

Holding Ctrl-Shift-Alt-ESC for 10 seconds used to create a forced Fusion crash (incl. log) back in ye olden days.....


User avatar
intelligent machine
Fusionista
Posts: 406
Joined: Fri May 13, 2016 10:01 pm
Answers: 2
Location: Austin, Texas, USA
Been thanked: 29 times
Contact:

Re: Restart Fusion [update]

#4

Post by intelligent machine » Fri May 03, 2019 11:43 am

The most convenient way would be to temporarily launch a separate session handler app outside of the Fusion process that is passed parameters via script. Then it would take over shutting down the current session cleanly, waiting until this task is complete (all allocated memory is freed / temp stuff destroyed, unsaved docs are saved, etc.....polling for the PID instead of app name) and then starting a new session in its place before quitting itself.


User avatar
Movalex
Fusioneer
Posts: 113
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 27 times
Contact:

Re: Restart Fusion [update]

#5

Post by Movalex » Fri May 03, 2019 11:56 am

If I recall correctly, the Restart script was created for the development purposes, so if you need to quickly see how your new fuse or new shortcut behaves, you just Alt+Q and restart the bummer. The script in current state does not ask if any unsaved work is there, it just quits (I've lost some unfortunate comps this way, but who cares :). Probably it saves preferences and stuff, but it is not what it is created for. I was just pissed about this extra icon, hence the change. But it should not be used in any production work, of course.

intelligent machine wrote:
Fri May 03, 2019 11:43 am

The most convenient way would be to temporarily launch a separate session handler app outside of the Fusion process that is passed parameters via script. Then it would take over shutting down the current session cleanly, waiting until this task is complete (all allocated memory is freed / temp stuff destroyed, unsaved docs are saved, etc.....polling for the PID instead of app name) and then starting a new session in its place before quitting itself.

Totally agree, this should be done


User avatar
intelligent machine
Fusionista
Posts: 406
Joined: Fri May 13, 2016 10:01 pm
Answers: 2
Location: Austin, Texas, USA
Been thanked: 29 times
Contact:

Re: Restart Fusion [update]

#6

Post by intelligent machine » Fri May 03, 2019 12:04 pm

Well I used "Keyboard Maestro" to automate things just like this outside of the app. It becomes that 'handler' (but works for any app I choose).

A simple script in Keyboard Maestro would look like this and be assigned in a group targeting only the Fusion application:
Image


User avatar
SecondMan
Site Admin
Posts: 3478
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 5
Location: Vancouver, Canada
Been thanked: 92 times
Contact:

Re: Restart Fusion [update]

#7

Post by SecondMan » Fri May 03, 2019 2:01 pm

Movalex wrote:
Fri May 03, 2019 11:56 am

The script in current state does not ask if any unsaved work is there, it just quits

Yes, but it quits the current session only. Any other instances of Fusion that may or may not contain unsaved data are left alone, as intended. Whether that's used for development or other purposes is irrelevant, surely?

Movalex wrote:
Fri May 03, 2019 11:56 am

I was just pissed about this extra icon

I'm too old to be pissed about icons :)


User avatar
Midgardsormr
Fusionator
Posts: 1103
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 2
Location: Los Angeles, CA, USA
Been thanked: 75 times
Contact:

Re: Restart Fusion [update]

#8

Post by Midgardsormr » Fri May 03, 2019 3:53 pm

SecondMan wrote:
Fri May 03, 2019 2:01 pm

I'm too old to be pissed about icons :)

Me, too.

Image


User avatar
Movalex
Fusioneer
Posts: 113
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 27 times
Contact:

Re: Restart Fusion [update]

#9

Post by Movalex » Fri May 03, 2019 8:23 pm

Ok, I get the point. :roll:


User avatar
intelligent machine
Fusionista
Posts: 406
Joined: Fri May 13, 2016 10:01 pm
Answers: 2
Location: Austin, Texas, USA
Been thanked: 29 times
Contact:

Re: Restart Fusion [update]

#10

Post by intelligent machine » Fri May 03, 2019 8:29 pm

I understand your frustration though. It would be especially annoying if your Fusion Icon was saved on the left side of the dock and the new instances appear on the far right side of the dock....don't know how old you guys are but I'm 40 and icons piss me off....guess I'm young at heart?