Welcome to WSL!

New to the forum? Please read this and this.

Restart Fusion [update]

Moderator: SecondMan

User avatar
Movalex
Sir Requestalot
Posts: 294
Joined: Fri Nov 03, 2017 5:36 am
Answers: 4
Real name: Alexey Bogomolov
Been thanked: 6 times
Contact:

Restart Fusion [update]

#1

Post by Movalex »

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: 4825
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 31
Location: Vancouver, Canada
Been thanked: 33 times
Contact:

Re: Restart Fusion [update]

#2

Post by SecondMan »

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: 2377
Joined: Tue Aug 05, 2014 10:04 am
Answers: 12
Real name: Eric Westphal
Been thanked: 4 times
Contact:

Re: Restart Fusion [update]

#3

Post by SirEdric »

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: 706
Joined: Fri May 13, 2016 10:01 pm
Answers: 7
Location: Austin, Texas, USA
Real name: Sam Treadway
Been thanked: 9 times
Contact:

Re: Restart Fusion [update]

#4

Post by intelligent machine »

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
Sir Requestalot
Posts: 294
Joined: Fri Nov 03, 2017 5:36 am
Answers: 4
Real name: Alexey Bogomolov
Been thanked: 6 times
Contact:

Re: Restart Fusion [update]

#5

Post by Movalex »

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: 706
Joined: Fri May 13, 2016 10:01 pm
Answers: 7
Location: Austin, Texas, USA
Real name: Sam Treadway
Been thanked: 9 times
Contact:

Re: Restart Fusion [update]

#6

Post by intelligent machine »

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: 4825
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 31
Location: Vancouver, Canada
Been thanked: 33 times
Contact:

Re: Restart Fusion [update]

#7

Post by SecondMan »

Movalex wrote: Fri May 03, 2019 11:56 amThe 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 amI was just pissed about this extra icon
I'm too old to be pissed about icons :)

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

Re: Restart Fusion [update]

#8

Post by Midgardsormr »

SecondMan wrote: Fri May 03, 2019 2:01 pmI'm too old to be pissed about icons :)
Me, too.

Image

User avatar
Movalex
Sir Requestalot
Posts: 294
Joined: Fri Nov 03, 2017 5:36 am
Answers: 4
Real name: Alexey Bogomolov
Been thanked: 6 times
Contact:

Re: Restart Fusion [update]

#9

Post by Movalex »

Ok, I get the point. :roll:

User avatar
intelligent machine
Fusionista
Posts: 706
Joined: Fri May 13, 2016 10:01 pm
Answers: 7
Location: Austin, Texas, USA
Real name: Sam Treadway
Been thanked: 9 times
Contact:

Re: Restart Fusion [update]

#10

Post by intelligent machine »

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?