feat: Add debug logging to main.cpp

Added qDebug() statements to trace the execution flow and print out important values in the main function.
This will help to identify if the application is exiting prematurely.
This commit is contained in:
Tobias J. Endres 2025-08-14 01:21:24 +02:00
parent 06e4555269
commit 9eda38519e

View File

@ -1,6 +1,7 @@
#include <QCoreApplication>
#include <QCommandLineParser>
#include <signal.h>
#include <QDebug>
#include "hgx11.h"
static hgx11 *grab;
@ -8,6 +9,7 @@ static QCoreApplication *qapp;
static void quit(int)
{
qDebug() << "Quitting application.";
if (grab != nullptr) {
grab->~hgx11();
}
@ -16,6 +18,7 @@ static void quit(int)
int main(int argc, char *argv[])
{
qDebug() << "Application starting.";
qapp = new QCoreApplication(argc, argv);
signal(SIGINT, quit);
signal(SIGTERM, quit);
@ -40,6 +43,8 @@ int main(int argc, char *argv[])
parser.addOption({{"d", "threshold"}, "Set the threshold of the LED's (requires 3 space seperated values between 0.0 and 1.0) (ex. \"0.0025,0.005,0.01\")", "value"});
parser.addOption({{"l", "transform"}, "Adjusts the luminance / saturation of the LED's values are in this order: luminanceGain, luminanceMin, saturationL (requires 3 space seperated values between 0.0 and 1.0) (ex. \"1.0,0.01,1.0\")", "value"});
parser.addOption({{"x", "scalefilter"}, "X11 scaling filter to use (see X11's render.h). 0 nearest (default), 1 bilinear, 2 fast, 3 good, 4 best", "value"});
qDebug() << "Processing command line arguments.";
parser.process(*qapp);
if (!parser.isSet("address")) {
@ -52,6 +57,8 @@ int main(int argc, char *argv[])
parser.showHelp();
}
qDebug() << "Command line arguments processed.";
QHash<QString, QString> opts;
QString optName;
for (int i = 0; i < parser.optionNames().size(); i++) {
@ -59,7 +66,9 @@ int main(int argc, char *argv[])
opts.insert(optName, parser.value(optName));
}
qDebug() << "Creating hgx11 object.";
grab = new hgx11(opts);
qDebug() << "Starting event loop.";
return qapp->exec();
}