Page 8 of 15

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 4:07 pm
by Gale Andrews
Thanks for your work on this, Ed.

So no-one has actually compiled this "reset CPP2/reset.cpp"? Ed, if you would like me to compile it please give step-by-step - including where to add it into the Audacity solution if that is needed.

I tried adding the file into the "src" folder in my Audacity tree, then in VS2013, File --> New --> Project --> Visual C++ --> Win32 Application, set the new project to be located in "src", then in Solution Explorer, added "reset.cpp" to the "Source Files" folder.

I also experimented with and without checking the box "Empty Project" in the above dialogue to create the new project. I always come up against

Code: Select all

Error  C1083: Cannot open include file: 'wx/wxprec.h': No such file or directory	c:audacity_commsrcreset.cpp	line 10
and then the same on the other Widgets includes.

In that reset.cpp, what does this do:

Code: Select all

if defined(__WXMAC__)
      // This removes (for instance) "Audacity.app/Contents/MacOSX"
      exePath.RemoveLastDir();
      exePath.RemoveLastDir();
      exePath.RemoveLastDir();
#endif
Obviously we don't want to delete the Audacity executable (and I think you mean "Audacity.app/Contents/MacOS").

Also for Mac, it has the audacity-lock-<user name> file in the current Audacity temp directory. If on Windows we don't use a file to prevent running multiple instances of Audacity, how is it done?

I don't know what would happen if this was run from the Mac DMG installer, without trying it. It would have to be compiled first (see my questions above).

I agree the sledgehammer is the first target before resetting individual prefs, and actually I think the external sledgehammer the most important. It's easy to tell users to quit or force quit Audacity if need be.

I think the external app should allow to reset only audacity.cfg if we have the luxury of a dialogue for this, even if also deleting pluginregistry.cfg should be default. For example, having a bad device connected could be the cause of the failure to start in which case there is no need to delete pluginregistry.cfg. Either way, deleting audacity.cfg on its own offers rescan of effects.

If we only get the external app "approved" I definitely think deletion of pluginsregistry.cfg should be optional.

Yes I agree we should only delete .cfg files of the current user.


Gale

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 4:23 pm
by Gale Andrews
steve wrote:If resetting preferences in 2.0.7 does not fix the problem in 2.0.7, then the problem is probably nothing to do with preferences.
Quite possibly but the case that I was thinking of was resetting.cfg then going back to 2.0.6 and running that (playing safe and trying the app version that - it appears to them - used to work.
steve wrote:If we want an external application for resetting preferences for Audacity 2.x, then it could have an option to select which version of Audacity to reset preferences for. That provides some forward compatibility because if future versions require a different method for resetting, then that new method can be added to the "Reset" application.
Fair point, but it seems a lot of real estate for that, and perhaps more confusing than it would be worth.

The only real problem I see with "NewPrefsInitialized=1" is if the code changed in future so that something bad happened if Audacity got a .cfg file with "NewPrefsInitialized=1" in it and no longer just deleted that line.

I don't see why we should ever remove handling that line, given how widely "NewPrefsInitialized=1" was publicised - there is always a chance Audacity will encounter such a .cfg file when a user upgrades.

Anyway, I'm done arguing about this - it is an edge case but I think it definitely merited discussion.


Gale

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 4:36 pm
by Gale Andrews
waxcylinder wrote:
Gale Andrews wrote:Do people often want to default more than one pane of preferences? If not, a reset pane could be more effort to use, especially if you have to look at the actual pane first to see what you're resetting.
I'm guessing yes - otherwise why would we be thinking about the "sledgehammer"
I meant, do people want to default just one pane of preferences, as opposed to all of them? If they do, perhaps they want to pick and choose in the pane, and I think we agree that is overkill.

Anyway, I think a Defaults button would be useful on some panes - we already have it in Keyboard Prefs. Would we really want a "Defaults" button in Libraries Preferences?


Gale

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 5:40 pm
by Edgar
Gale Andrews wrote:please give step-by-step - including where to add it into the Audacity solution if that is needed.
Edgar wrote:External sledgehammer:
https://www.dropbox.com/s/h2thp8qg5oziu ... s.zip?dl=0
This zip file contains an entire Window's solution with source code and icon resources. I also have the icon as a 32x32 XPM if we need it.
I have not created a makefile for Linux or Mac. The Windows solution is for MS VS 2013 and is built with wxWidgets 2.8.

All this does is delete both of the Audacity configuration files: audacity.cfg & pluginregistry.cfg with a "are you sure" dialog. With the exception of centering the application and moving the button down 10 pixels and to the right 10 pixels down, all other sizes and placements use the wxWidgets defaults.
Unzip this and place the resulting folder (by default it will be called "ResetAudacityPreferences") somewhere (probably best not in your local SVN HEAD folder). To make a little bit easier on builders, I included both of the MSVS2013-built wxWidgets DLLs which are needed (in both Unicode debug & release).

In a previous post of this thread you will find resetCPP2.zip as an attachment, unzip it and use this new CPP file instead of the one in the source folder which was created by unzipping ResetAudacityPreferences.zip (copy & replace the new version of reset.cpp over the old version).

Use Microsoft Visual Studio 2013* to open the solution: "Reset Audacity Preferences.sln". Build either or both of the Debug & Release configurations and run the resulting executable.

*Don't forget, last week Microsoft made the full professional version of Visual Studio 2013 available to download for free for everyone. It has a number of features not available in the Express version and there are also a number of bug fixes.

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 5:54 pm
by Edgar
Gale Andrews wrote: In that reset.cpp, what does this do:

Code: Select all

if defined(__WXMAC__)
      // This removes (for instance) "Audacity.app/Contents/MacOSX"
      exePath.RemoveLastDir();
      exePath.RemoveLastDir();
      exePath.RemoveLastDir();
#endif
Obviously we don't want to delete the Audacity executable (and I think you mean "Audacity.app/Contents/MacOS").
The three functions:

Code: Select all

wxString GetExecutablePath()
wxString MkDir(const wxString &Str)
wxString DataDir()
are copied verbatim from the Audacity source code where they are used to determine the location of the configuration files on a platform-specific basis. I do not know who wrote the comment but it is certainly confusing if not misleading.

The statement:
exePath.RemoveLastDir();
is not removing the directory; what it is doing is modifying a string so if you have a string* called "exePath" which has a value of:

Code: Select all

D:primarysecondarytertiary
after the statement it would have a value of:

Code: Select all

D:primarysecondary
thus, the last directory has been removed from the string.

* Actually it is a wxFileName:
wxFileName exePath(GetExecutablePath());
which is just a fancy String which knows how to treat itself as a fully qualified path plus filename plus extension.

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 6:03 pm
by Edgar
Gale Andrews wrote: Also for Mac, it has the audacity-lock-<user name> file in the current Audacity temp directory. If on Windows we don't use a file to prevent running multiple instances of Audacity, how is it done?

I don't know what would happen if this was run from the Mac DMG installer, without trying it. It would have to be compiled first (see my questions above).
Since, in respect to the audacity-lock-<user name> file, Mac operates just like Linux, my code should work just fine on either OS.

WxWidgets 2.8 has a tool to see if an application is running but (as of 2.8 - I'm not sure about 3.x) is not implemented for Linux nor Mac.

I have absolutely no information about the Mac DMG installer (strange as it may seem, I have never even seen a Mac running). From the discussions on -devel I understand that there are hoops one must jump through if one wants to write software for Mac; they would be the same hoops for this application as they are for Audacity. This application would have no functional relationship to Audacity - it is a standalone application which can be installed and run regardless of whether or not Audacity is installed (of course, it will display an error message if it fails to find Audacity's configuration files).

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 6:49 pm
by Edgar
The attached zip archive contains new reset.cpp & reset.h files. In this version there are three buttons: "reset both", "reset audacity.cfg" & "reset pluginregistry.cfg". Each operates as advertised so make a copy of your current configuration files before testing.

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 8:02 pm
by Edgar
The attached archive contains both new .CPP & .H files. Replace the old ones with these new ones. With the exception of review for wording & GUI layout I think this is ready-to-use production code. WARNING: everything is functional - this will delete both configuration files and the lock file.

The implementation of deleting the lock file might need some discussion. Currently, I delete it when the user chooses the "both" button but not when the user chooses either of the single file removal buttons. The other obvious implementations would be to give it its own button (keeping it as part of the "both" button, or not) or to also "just do it" (it is benign if the lock file does not exist) for all three of the existing buttons. I would lean toward giving it its own button as it is the least destructive to the user's environment and if, by itself, it does the job, would seem to be the best-minimal solution.

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 10:29 pm
by Gale Andrews
I tried the two patches for the internal "Reset" (single and multiple buttons in Prefs).

In the "single button" patch, the "Reset" button should have an ellipsis as it is opening a dialogue requiring user input.

The "Very drastic action" title of the message will need changing to "Reset audacity.cfg" or similar I think. I confirmed reset with a track open and a recording taking place in another project window. Audacity did the right thing, offering to save the contents.

In the "multiple buttons" patch, I think "Defaults" is good enough for the text for the button in the Devices pane that just resets those prefs. However if I open Preferences, uncheck some of the boxes in Warnings Prefs then reset Devices Prefs, the Warnings boxes are rechecked.

I don't like the "Message" that says "reset all" with an OK button when you reset Devices Prefs. There is no way to cancel that reset (which I think is correct as per Keyboard Prefs) so that message is just confusing.

The "Devices-only" reset also did not work very well. To my surprise (only tested on Windows) you can actually use the existing Devices Preferences controls to change settings and OK while playing or recording. This updates Device Toolbar even while it's greyed out then the new settings take effect when you next play or record. A) Your Devices reset doesn't have that immediate effect, so Devices Prefs and Device Toolbar are out of sync. B) Then when I File > Close without correcting the desync (OK'ing in Preferences would do that), the Device Toolbar visible dropdown entries become blank. So I then have to use the dropdown menus in Device Toolbar to reselect the choices. Neither A) or B) are really acceptable IMO.

In the "Manage" section, buttons have no ellipsis. The button to "Reset pluginregistry.cfg" does not delete the file and shows no dialog (if it was intended to). If a delete is done (as opposed to reset), buttons and dialogues should say "Delete" I think. The button that resets both .cfgs does delete pluginregistry.cfg.


Gale

Re: reset Preferences CFG file

Posted: Sun Nov 23, 2014 11:30 pm
by Edgar
Gale Andrews wrote:I tried the two patches for the internal "Reset" (single and multiple buttons in Prefs).

In the "single button" patch, the "Reset" button should have an ellipsis as it is opening a dialogue requiring user input.

The "Very drastic action" title of the message will need changing to "Reset audacity.cfg" or similar I think. I confirmed reset with a track open and a recording taking place in another project window. Audacity did the right thing, offering to save the contents.

In the "multiple buttons" patch, I think[…]
So, since the multiple buttons patch is off the table (at least for the foreseeable future), and the single button patch works as desired - only needing minor wording polish (which you are completely capable of accomplishing)…might I suggest getting it in the nightly so that it may be tested?

Aside - since you now build on all three platforms, did you do so and, if so, can I assume no functional problems occurred?