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

View file

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

View file

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