mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 07:10:06 +02:00
Fix command line options
Fixes -v / --verbose. Fixes file paths (Windows and Linux). Relative file paths would (before this fix) be wrong unless the command was launched from the same directory as Audacity's working directory (Windows and Linux only)
This commit is contained in:
parent
bc60de2ffa
commit
4c76e598d5
@ -623,7 +623,7 @@ public:
|
|||||||
// Add the filename to the queue. It will be opened by
|
// Add the filename to the queue. It will be opened by
|
||||||
// the OnTimer() event when it is safe to do so.
|
// the OnTimer() event when it is safe to do so.
|
||||||
ofqueue.Add(data);
|
ofqueue.Add(data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1457,7 +1457,7 @@ bool AudacityApp::OnInit()
|
|||||||
|
|
||||||
if (parser->Found(wxT("v")))
|
if (parser->Found(wxT("v")))
|
||||||
{
|
{
|
||||||
wxFprintf(stderr, wxT("Audacity v%s\n"), AUDACITY_VERSION_STRING);
|
wxPrintf("Audacity v%s\n", AUDACITY_VERSION_STRING);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1513,7 +1513,7 @@ bool AudacityApp::OnInit()
|
|||||||
wndRect.GetTopLeft(),
|
wndRect.GetTopLeft(),
|
||||||
wxDefaultSize,
|
wxDefaultSize,
|
||||||
wxSTAY_ON_TOP);
|
wxSTAY_ON_TOP);
|
||||||
|
|
||||||
// Unfortunately with the Windows 10 Creators update, the splash screen
|
// Unfortunately with the Windows 10 Creators update, the splash screen
|
||||||
// now appears before setting its position.
|
// now appears before setting its position.
|
||||||
// On a dual monitor screen it will appear on one screen and then
|
// On a dual monitor screen it will appear on one screen and then
|
||||||
@ -1638,7 +1638,7 @@ bool AudacityApp::OnInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// As of wx3, there's no need to process the filename arguments as they
|
// As of wx3, there's no need to process the filename arguments as they
|
||||||
// will be sent view the MacOpenFile() method.
|
// will be sent via the MacOpenFile() method.
|
||||||
#if !defined(__WXMAC__)
|
#if !defined(__WXMAC__)
|
||||||
for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
|
for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
|
||||||
{
|
{
|
||||||
@ -1853,7 +1853,7 @@ bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir)
|
|||||||
}
|
}
|
||||||
else if ( checker->IsAnotherRunning() ) {
|
else if ( checker->IsAnotherRunning() ) {
|
||||||
// Parse the command line to ensure correct syntax, but
|
// Parse the command line to ensure correct syntax, but
|
||||||
// ignore options and only use the filenames, if any.
|
// ignore options other than -v, and only use the filenames, if any.
|
||||||
auto parser = ParseCommandLine();
|
auto parser = ParseCommandLine();
|
||||||
if (!parser)
|
if (!parser)
|
||||||
{
|
{
|
||||||
@ -1861,6 +1861,22 @@ bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parser->Found(wxT("v")))
|
||||||
|
{
|
||||||
|
wxPrintf("Audacity v%s\n", AUDACITY_VERSION_STRING);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Windows and Linux require absolute file names as command may
|
||||||
|
// not come from current working directory.
|
||||||
|
wxArrayString filenames;
|
||||||
|
for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
|
||||||
|
{
|
||||||
|
wxFileName filename(parser->GetParam(i));
|
||||||
|
if (filename.MakeAbsolute())
|
||||||
|
filenames.Add(filename.GetLongPath());
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
// On Windows, we attempt to make a connection
|
// On Windows, we attempt to make a connection
|
||||||
// to an already active Audacity. If successful, we send
|
// to an already active Audacity. If successful, we send
|
||||||
@ -1876,14 +1892,13 @@ bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir)
|
|||||||
if (conn)
|
if (conn)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
if (parser->GetParamCount() > 0)
|
if (filenames.GetCount() > 0)
|
||||||
{
|
{
|
||||||
// Send each parameter to existing Audacity
|
for (size_t i = 0, cnt = filenames.GetCount(); i < cnt; i++)
|
||||||
for (size_t j = 0, cnt = parser->GetParamCount(); j < cnt; j++)
|
|
||||||
{
|
{
|
||||||
ok = conn->Execute(parser->GetParam(j));
|
ok = conn->Execute(filenames[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Send an empty string to force existing Audacity to front
|
// Send an empty string to force existing Audacity to front
|
||||||
@ -1918,12 +1933,11 @@ bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir)
|
|||||||
sock->Connect(addr, true);
|
sock->Connect(addr, true);
|
||||||
if (sock->IsConnected())
|
if (sock->IsConnected())
|
||||||
{
|
{
|
||||||
if (parser->GetParamCount() > 0)
|
if (filenames.GetCount() > 0)
|
||||||
{
|
{
|
||||||
for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
|
for (size_t i = 0, cnt = filenames.GetCount(); i < cnt; i++)
|
||||||
{
|
{
|
||||||
// Send the filename
|
const wxString param = filenames[i];
|
||||||
wxString param = parser->GetParam(i);
|
|
||||||
sock->WriteMsg((const wxChar *) param, (param.Len() + 1) * sizeof(wxChar));
|
sock->WriteMsg((const wxChar *) param, (param.Len() + 1) * sizeof(wxChar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user