Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memleaks in help/version #7423

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 52 additions & 54 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,57 @@ int main( int argc, char * * argv )
{
using namespace lmms;

bool coreOnly = false;
bool fullscreen = true;
bool exitAfterImport = false;
bool allowRoot = false;
bool renderLoop = false;
bool renderTracks = false;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile;

// first of two command-line parsing stages
for (int i = 1; i < argc; ++i)
{
QString arg = argv[i];

if (arg == "--help" || arg == "-h")
{
printHelp();
return EXIT_SUCCESS;
}
else if (arg == "--version" || arg == "-v")
{
printVersion(argv[0]);
return EXIT_SUCCESS;
}
else if (arg == "render" || arg == "--render" || arg == "-r" )
{
coreOnly = true;
}
else if (arg == "rendertracks" || arg == "--rendertracks")
{
coreOnly = true;
renderTracks = true;
}
else if (arg == "--allowroot")
{
allowRoot = true;
}
else if (arg == "--geometry" || arg == "-geometry")
{
if (arg == "--geometry")
{
// Delete the first "-" so Qt recognize the option
strcpy(argv[i], "-geometry");
}
// option -geometry is filtered by Qt later,
// so we need to check its presence now to
// determine, if the application should run in
// fullscreen mode (default, no -geometry given).
fullscreen = false;
}
}

#ifdef LMMS_DEBUG_FPE
// Enable exceptions for certain floating point results
// FE_UNDERFLOW is disabled for the time being
Expand Down Expand Up @@ -314,49 +365,6 @@ int main( int argc, char * * argv )

disable_denormals();

bool coreOnly = false;
bool fullscreen = true;
bool exitAfterImport = false;
bool allowRoot = false;
bool renderLoop = false;
bool renderTracks = false;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile;

// first of two command-line parsing stages
for( int i = 1; i < argc; ++i )
{
QString arg = argv[i];

if( arg == "--help" || arg == "-h" ||
arg == "--version" || arg == "-v" ||
arg == "render" || arg == "--render" || arg == "-r" )
{
coreOnly = true;
}
else if( arg == "rendertracks" || arg == "--rendertracks" )
{
coreOnly = true;
renderTracks = true;
}
else if( arg == "--allowroot" )
{
allowRoot = true;
}
else if( arg == "--geometry" || arg == "-geometry")
{
if( arg == "--geometry" )
{
// Delete the first "-" so Qt recognize the option
strcpy(argv[i], "-geometry");
}
// option -geometry is filtered by Qt later,
// so we need to check its presence now to
// determine, if the application should run in
// fullscreen mode (default, no -geometry given).
fullscreen = false;
}
}

#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BUILD_HAIKU)
if ( ( getuid() == 0 || geteuid() == 0 ) && !allowRoot )
{
Expand All @@ -382,17 +390,7 @@ int main( int argc, char * * argv )
{
QString arg = argv[i];

if( arg == "--version" || arg == "-v" )
{
printVersion( argv[0] );
return EXIT_SUCCESS;
}
else if( arg == "--help" || arg == "-h" )
{
printHelp();
return EXIT_SUCCESS;
}
else if( arg == "upgrade" || arg == "--upgrade" || arg == "-u")
if (arg == "upgrade" || arg == "--upgrade" || arg == "-u")
{
++i;

Expand Down
Loading