reset Preferences CFG file

This read-only archive contains discussions from the Adding Feature forum.
New feature request may be posted to the Adding Feature forum.
Technical support is available via the Help forum.
Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: reset Preferences CFG file

Post by Edgar » Wed Dec 31, 2014 10:33 pm

For those playing along at home…

Code: Select all

void PrefsDialog::OnReset(wxCommandEvent & WXUNUSED(pEvent)) {
   wxMessageDialog dialog(this, _("Do you want to reset Preferences to factory defaults the next time you start Audacity?"),
      _("Confirm Reset Preferences"), wxYES_NO | wxNO_DEFAULT | wxICON_EXCLAMATION);
   int result = dialog.ShowModal();
   if (result == wxID_YES) {
      wxString executablesDirectory(wxGetApp().argv[0]);
      wxFileName executableFileName(executablesDirectory);
      wxString executablesFolder(executableFileName.GetPath());
      executablesFolder.Append(executableFileName.GetPathSeparator());
      executablesFolder.Append(wxT("resetPrefs.txt"));
      wxFileName resetFile(executablesFolder);
      if (!resetFile.FileExists()) {
         wxTextFile textFile(resetFile.GetFullPath());
         if (!textFile.Create()) {
            wxString message(_("Could not create  %s"), resetFile.GetFullPath().c_str());
            wxMessageBox(message);
         }
      }
   }
}
This is functional code which can replace the "do nothing" function in testReset.patch (look at the very bottom of srcprefsPrefsDialog.cpp for this function). Make a copy of your current audacity.cfg file before playing with this stuff.

edit: wxWidgets 3 compatibility
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: reset Preferences CFG file

Post by Gale Andrews » Thu Jan 01, 2015 10:55 am

Edgar wrote:Patch attached…
This patch does not actually cause anything to happen it just puts up a dialog displaying the full path to the Audacity application.
@Gale - could you try this patch on Mac & Linux and verify that the resulting fully qualified path (ignoring the trailing Audacity.exe) is the exact path in which the Audacity.exe executable resides? If the Mac version is not quite right can the correct folder path the calculated using this information?
@Steve - could you try it on Linux?
Tried it with your real code on Win 7 - seems OK.

Tried on Mac and Linux with the do nothing function. On Mac it finds the Audacity executable in its folder inside the Audacity application folder, so "Audacity.App/Contents/MacOS/Audacity" (which is the path to the embedded app and is not a folder). It wants to replace "/MacOS/Audacity" in that path with "Resources" so that it writes to the folder "Audacity.App/Contents/Resources".

On Linux the path just says "audacity". I installed your patched app, so in that case the path should be "/usr/local/bin".


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: reset Preferences CFG file

Post by Edgar » Thu Jan 01, 2015 4:40 pm

Gale Andrews wrote:On Mac it finds the Audacity executable in its folder inside the Audacity application folder, so "Audacity.App/Contents/MacOS/Audacity" (which is the path to the embedded app and is not a folder). It wants to replace "/MacOS/Audacity" in that path with "Resources" so that it writes to the folder "Audacity.App/Contents/Resources".

On Linux the path just says "audacity". I installed your patched app, so in that case the path should be "/usr/local/bin".
Is it the case that for Mac OS (when Audacity is installed normally - i.e. not built by a developer) that displayed string will always be:
"Audacity.App/Contents/MacOS/Audacity"
so the resulting target will be:
"Audacity.App/Contents/Resources/resetPrefs.txt"
and if so does manually placing the file there cause Audacity to reset the next time it starts?

On Linux are you saying that the resulting target would be:
"/usr/local/bin/resetPrefs.txt"
and that there is no reference to a Audacity-specific containing folder? If so, I might argue that (in general) the reset file's name might be changed to:
"resetAudacityPrefs.txt"
if it is not too late.
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: reset Preferences CFG file

Post by Gale Andrews » Thu Jan 01, 2015 6:57 pm

Edgar wrote:
Gale Andrews wrote:On Mac it finds the Audacity executable in its folder inside the Audacity application folder, so "Audacity.App/Contents/MacOS/Audacity" (which is the path to the embedded app and is not a folder). It wants to replace "/MacOS/Audacity" in that path with "Resources" so that it writes to the folder "Audacity.App/Contents/Resources".

On Linux the path just says "audacity". I installed your patched app, so in that case the path should be "/usr/local/bin".
Is it the case that for Mac OS (when Audacity is installed normally - i.e. not built by a developer) that displayed string will always be:
"Audacity.App/Contents/MacOS/Audacity"
so the resulting target will be:
"Audacity.App/Contents/Resources/resetPrefs.txt"
The displayed string now is always "<path to the folder containing the Audacity build or installation">/Audacity.App/Contents/MacOS/Audacity". That is reliable for build or normal installation.

So the target is the relative one of "Audacity.App/Contents/Resources/resetPrefs.txt". Written absolutely, it is "<path to the folder containing the Audacity build or installation">/Audacity.App/Contents/Resources/resetPrefs.txt.
Edgar wrote:Does manually placing the file there cause Audacity to reset the next time it starts?
Yes, reliably so.
Edgar wrote:On Linux are you saying that the resulting target would be:
"/usr/local/bin/resetPrefs.txt"
and that there is no reference to a Audacity-specific containing folder?
Audacity seems to look in the "share" folder for the installed version of Audacity (which is the same location the Manual is looked for on Linux if a user installs it).

A self-compiled (and installed) build will look in /usr/local/share/audacity for resetPrefs.txt. A build installed by a normal user with a package manager will look in /usr/share/audacity. Audacity will error that it can't write or remove resetPrefs.txt because those locations require root permission, so that is a problem. And it's a problem that a builder who does not install Audacity cannot use resetPrefs.txt.

There are two hidden files in the user's home folder called ".audacity-files" and ".audacity-data" that user has permission to write to. I think if this was to work on Linux we'd have to modify audacity to write to either of those folders.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: reset Preferences CFG file

Post by Edgar » Thu Jan 01, 2015 10:02 pm

Gale Andrews wrote: So the target is the relative one of "Audacity.App/Contents/Resources/resetPrefs.txt". Written absolutely, it is "<path to the folder containing the Audacity build or installation">/Audacity.App/Contents/Resources/resetPrefs.txt.
Edgar wrote:On Linux are you saying that the resulting target would be:
"/usr/local/bin/resetPrefs.txt"
and that there is no reference to a Audacity-specific containing folder?
Audacity will error that it can't write or remove resetPrefs.txt
The only solution I can see is to change where "resetPrefs.txt" is placed - it needs to be in a place whose path can be calculated and where we are absolutely certain an application has write permission. The only folder I can think of which safely satisfies these requirements is the same folder in which audacity.cfg is located. I think we are at a roadblock here.
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: reset Preferences CFG file

Post by Gale Andrews » Fri Jan 02, 2015 3:01 pm

Edgar wrote:
Gale Andrews wrote: So the target is the relative one of "Audacity.App/Contents/Resources/resetPrefs.txt". Written absolutely, it is "<path to the folder containing the Audacity build or installation">/Audacity.App/Contents/Resources/resetPrefs.txt.
Edgar wrote:On Linux are you saying that the resulting target would be:
"/usr/local/bin/resetPrefs.txt"
and that there is no reference to a Audacity-specific containing folder?
Audacity will error that it can't write or remove resetPrefs.txt
The only solution I can see is to change where "resetPrefs.txt" is placed - it needs to be in a place whose path can be calculated and where we are absolutely certain an application has write permission. The only folder I can think of which safely satisfies these requirements is the same folder in which audacity.cfg is located. I think we are at a roadblock here.
OK I made that comment in http://bugzilla.audacityteam.org/show_b ... id=363#c10.

Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

waxcylinder
Forum Staff
Posts: 14684
Joined: Tue Jul 31, 2007 11:03 am
Operating System: Windows 10

Re: reset Preferences CFG file

Post by waxcylinder » Wed Mar 04, 2015 10:18 am

BUMP

do I just need this to the "In-Depth Feature Discussions Archive" section?
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * FAQ * * * * * Tutorials * * * * * Audacity Manual * * * * *

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: reset Preferences CFG file

Post by Gale Andrews » Thu Mar 05, 2015 1:57 pm

waxcylinder wrote:BUMP

do I just need this to the "In-Depth Feature Discussions Archive" section?
Yes, I've archived it. AFAIK there are no "votes" here that have not already been counted. The Proposal http://wiki.audacityteam.org/wiki/Propo ... _cfg_Reset already links to this topic.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

Locked