The way Maya itself handles this is to only save settings when you close Maya. I save settings from a lot of my tools using QSettings when they are closed and it generally works well. The most significant caveat is that you need to make doubly sure you handle exceptions when saving settings, because you don't want to prevent other cleanup from being run. It also has the disadvantage that if you have two sessions open, and you make a lot of changes to your settings in one, but close that one first, the second session can overwrite all the changes you saved from the first session.
On Saturday, 25 August 2018 09:27:40 UTC+10, kiteh wrote: > > Is there a way to check if the current maya session is 'new'? > > I have a tool created using PyQt, in which it stores the widgets inputs > using QSettings (asked this question previously). The settings and all > works out great, however I realized that if I launched a new maya session, > followed by relaunching my tool, the 'stored' settings is/ are being loaded. > > And hence, I would wanted to see if I can implemented in a way such that: > > - if user clicks on 'new scene' or open/ load a new file in the > current maya session > if my tool is relaunched, it will prompt a popup > and > ask if User wants to load the 'old' settings or use default settings? > - if user launch a new maya session > open/ load a new file > launch > my tool, it should load in the default settings. > > Will this be too complicated to do so? I am hoping to implement in the > first point if possible. > > Many thanks in advance! > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8457214a-cd5b-4e62-b4e5-244b67510b98%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
