user report_info() instead of qDebug in main() functions

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-25 20:33:30 +01:00 committed by bstoeger
parent 4af2ec88bd
commit 2c2ad1e5c9
3 changed files with 20 additions and 23 deletions

View file

@ -4,7 +4,6 @@
#include <QString>
#include <QCommandLineParser>
#include <QApplication>
#include <QDebug>
#include "core/qt-gui.h"
#include "core/qthelper.h"
@ -43,12 +42,12 @@ int main(int argc, char **argv)
QString output = parser.value(outputDirectoryOption);
if (source.isEmpty() || output.isEmpty()) {
qDebug() << "need --source and --output";
report_info("need --source and --output");
exit(1);
}
int ret = parse_file(qPrintable(source), &divelog);
if (ret) {
fprintf(stderr, "parse_file returned %d\n", ret);
report_info("parse_file returned %d", ret);
exit(1);
}

View file

@ -123,11 +123,11 @@ int main(int argc, char **argv)
void validateGL()
{
QString quickBackend = qgetenv("QT_QUICK_BACKEND");
std::string quickBackend = qgetenv("QT_QUICK_BACKEND").toStdString();
/* on macOS with Qt6 (maybe others), things only work with the software backend */
#if defined(Q_OS_MACOS) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (quickBackend.isEmpty()) {
quickBackend = QStringLiteral("software");
if (quickBackend.empty()) {
quickBackend = "software";
qputenv("QT_QUICK_BACKEND", "software");
}
#endif
@ -135,12 +135,11 @@ void validateGL()
* only validate OpenGL; for everything else print out and return.
* https://doc.qt.io/qt-5/qtquick-visualcanvas-adaptations.html
*/
if (!quickBackend.isEmpty()) {
if (!quickBackend.empty()) {
if (verbose) {
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX
"'QT_QUICK_BACKEND' is set to '%1'. "
"Skipping validation.")
.arg(quickBackend);
report_info(VALIDATE_GL_PREFIX
"'QT_QUICK_BACKEND' is set to '%s'. "
"Skipping validation.", quickBackend.c_str());
}
return;
}
@ -158,7 +157,7 @@ void validateGL()
goto exit;
}
if (verbose)
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "created OpenGLContext.");
report_info(VALIDATE_GL_PREFIX "created OpenGLContext.");
ctx.makeCurrent(&surface);
func = ctx.functions();
if (!func) {
@ -166,18 +165,18 @@ void validateGL()
goto exit;
}
if (verbose)
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "obtained QOpenGLFunctions.");
report_info(VALIDATE_GL_PREFIX "obtained QOpenGLFunctions.");
// detect version for legacy profiles
verChar = (const char *)func->glGetString(GL_VERSION);
if (verChar) {
// detect GLES, show a warning and return early as we don't handle it's versioning
if (strstr(verChar, " ES ") != NULL) {
qWarning() << QStringLiteral(VALIDATE_GL_PREFIX
"WARNING: Detected OpenGL ES!\n"
"Attempting to run with the available profile!\n"
"If this fails try manually setting the environment variable\n"
"'QT_QUICK_BACKEND' with the value of 'software'\n"
"before running Subsurface!\n");
report_error(VALIDATE_GL_PREFIX
"WARNING: Detected OpenGL ES!\n"
"Attempting to run with the available profile!\n"
"If this fails try manually setting the environment variable\n"
"'QT_QUICK_BACKEND' with the value of 'software'\n"
"before running Subsurface!\n");
return;
}
int min, maj;
@ -196,7 +195,7 @@ void validateGL()
goto exit;
}
if (verbose)
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "detected OpenGL version %1.%2.").arg(verMajor).arg(verMinor);
report_info(VALIDATE_GL_PREFIX "detected OpenGL version %d.%d.", verMajor, verMinor);
if (verMajor * 10 + verMinor < 21) { // set 2.1 as the minimal version
glError = "OpenGL 2.1 or later is required";
goto exit;
@ -206,7 +205,7 @@ exit:
ctx.makeCurrent(NULL);
surface.destroy();
if (glError) {
qWarning() << QStringLiteral(VALIDATE_GL_PREFIX "WARNING: %1. Using a software renderer!").arg(glError);
report_error(VALIDATE_GL_PREFIX "WARNING: %s. Using a software renderer!", glError);
QQuickWindow::setSceneGraphBackend("software");
}
}

View file

@ -33,7 +33,6 @@
int main(int argc, char **argv)
{
int i;
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
@ -45,7 +44,7 @@ int main(int argc, char **argv)
subsurface_console_init();
for (i = 1; i < arguments.length(); i++) {
for (int i = 1; i < arguments.length(); i++) {
QString a = arguments.at(i);
if (!a.isEmpty() && a.at(0) == '-') {
parse_argument(qPrintable(a));