Skip to content

Commit

Permalink
add the freeWindowsConsole function
Browse files Browse the repository at this point in the history
Signed-off-by: sudomgamal <[email protected]>
  • Loading branch information
sudomgamal committed Jan 7, 2025
1 parent ebac03d commit 212f832
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
43 changes: 20 additions & 23 deletions qdlt/qdltoptmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ void QDltOptManager::printUsage(const QString& helpText)
qDebug() << " dlt-viewer.exe -t -c output.txt input1.mf4 input2.mf4";
}

void QDltOptManager::freeWindowsConsole()
{
#if (WIN32 || WIN64)
HWND consoleWnd = GetConsoleWindow();
DWORD dwProcessId;
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
if (GetCurrentProcessId() == dwProcessId)
{
FreeConsole();
}
#endif
}

void QDltOptManager::parse(const QStringList& args)
{
m_parser.parse(args);
Expand Down Expand Up @@ -138,16 +151,8 @@ void QDltOptManager::parse(const QStringList& args)

if(closeConsole)
{
#if (WIN32 || WIN64)
HWND consoleWnd = GetConsoleWindow();
DWORD dwProcessId;
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
if (GetCurrentProcessId() == dwProcessId)
{
// user launched the application with a double click on a dlt/project file: we do not need console
FreeConsole();
}
#endif
// user launched the application with a double click on a dlt/project file: we do not need console
freeWindowsConsole();
return;
}
}
Expand Down Expand Up @@ -262,19 +267,11 @@ void QDltOptManager::parse(const QStringList& args)
* Unfortunateley Windows opens a console anyway.
* So we have to close it in this case
*/
#if (WIN32)
if (!commandline_mode)
{
HWND consoleWnd = GetConsoleWindow();
DWORD dwProcessId;
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
if (GetCurrentProcessId() == dwProcessId)
{
// user launched the application with a double click from explorer: we do not need console
FreeConsole();
}
}
#endif
if (!commandline_mode)
{
// user launched the application with a double click from explorer: we do not need console
freeWindowsConsole();
}
}

bool QDltOptManager::isProjectFile(){ return project;}
Expand Down
1 change: 1 addition & 0 deletions qdlt/qdltoptmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class QDLT_EXPORT QDltOptManager
void printUsage(const QString& helpText);
void printVersion(QString appname);
void parse(const QStringList& opt);
void freeWindowsConsole();

bool isProjectFile();
bool isTerminate();
Expand Down

0 comments on commit 212f832

Please sign in to comment.