Page 1 of 1

Restart Fusion [update]

Posted: Thu Mar 21, 2019 9:40 am
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

Re: Restart Fusion [update]

Posted: Fri May 03, 2019 10:31 am
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 :)


Re: Restart Fusion [update]

Posted: Fri May 03, 2019 10:50 am
by SirEdric

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


Re: Restart Fusion [update]

Posted: Fri May 03, 2019 11:43 am
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.


Re: Restart Fusion [update]

Posted: Fri May 03, 2019 11:56 am
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


Re: Restart Fusion [update]

Posted: Fri May 03, 2019 12:04 pm
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


Re: Restart Fusion [update]

Posted: Fri May 03, 2019 2:01 pm
by SecondMan
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 :)


Re: Restart Fusion [update]

Posted: Fri May 03, 2019 3:53 pm
by Midgardsormr
SecondMan wrote:
Fri May 03, 2019 2:01 pm

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

Me, too.

Image


Re: Restart Fusion [update]

Posted: Fri May 03, 2019 8:23 pm
by Movalex

Ok, I get the point. :roll:


Re: Restart Fusion [update]

Posted: Fri May 03, 2019 8:29 pm
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?