1
0
Fork 0

crash: print warning messages for run/buildtime Qt version mismatch

This commit is contained in:
outfoxxed 2024-10-17 13:15:09 -07:00
parent 89d04f34a5
commit 4c2d7a7e41
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 57 additions and 6 deletions

View file

@ -67,6 +67,11 @@ It is not managed by us and should be looked over before use.
[AUR package]: https://aur.archlinux.org/packages/quickshell [AUR package]: https://aur.archlinux.org/packages/quickshell
> [!CAUTION]
> The AUR provides no way to force the quickshell package to rebuild when the Qt version changes.
> If you experience crashes after updating Qt, please try rebuilding Quickshell against the
> current Qt version before opening an issue.
## Fedora (COPR) ## Fedora (COPR)
Quickshell has a third party [Fedora COPR package] available under the same name. Quickshell has a third party [Fedora COPR package] available under the same name.
It is not managed by us and should be looked over before use. It is not managed by us and should be looked over before use.

View file

@ -4,6 +4,7 @@
#include <cerrno> #include <cerrno>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring>
#include <limits> #include <limits>
#include <string> #include <string>
#include <vector> #include <vector>
@ -176,6 +177,7 @@ struct CommandState {
} subcommand; } subcommand;
struct { struct {
bool checkCompat = false;
bool printVersion = false; bool printVersion = false;
bool killAll = false; bool killAll = false;
bool noDuplicate = false; bool noDuplicate = false;
@ -290,6 +292,8 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
addDebugOptions(&cli); addDebugOptions(&cli);
{ {
cli.add_option_group("")->add_flag("--private-check-compat", state.misc.checkCompat);
cli.add_flag("-V,--version", state.misc.printVersion) cli.add_flag("-V,--version", state.misc.printVersion)
->description("Print quickshell's version and exit."); ->description("Print quickshell's version and exit.");
@ -378,6 +382,18 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
CLI11_PARSE(cli, argc, argv); CLI11_PARSE(cli, argc, argv);
if (state.misc.checkCompat) {
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
QTextStream(stdout) << "\033[31mCOMPATIBILITY WARNING: Quickshell was built against Qt "
<< QT_VERSION_STR << " but the system has updated to Qt " << qVersion()
<< " without rebuilding the package. This is likely to cause crashes, so "
"you must rebuild the quickshell package.\n";
return 1;
}
return 0;
}
// Has to happen before extra threads are spawned. // Has to happen before extra threads are spawned.
if (state.misc.daemonize) { if (state.misc.daemonize) {
auto closepipes = std::array<int, 2>(); auto closepipes = std::array<int, 2>();
@ -451,6 +467,13 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
} else if (*state.subcommand.msg) { } else if (*state.subcommand.msg) {
return msgInstance(state); return msgInstance(state);
} else { } else {
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
qWarning() << "\033[31mQuickshell was built against Qt" << QT_VERSION_STR
<< "but the system has updated to Qt" << qVersion()
<< "without rebuilding the package. This is likely to cause crashes, so "
"the quickshell package must be rebuilt.\n";
}
return launchFromCommand(state, coreApplication); return launchFromCommand(state, coreApplication);
} }

View file

@ -1,8 +1,10 @@
#include "interface.hpp" #include "interface.hpp"
#include <cstring>
#include <utility> #include <utility>
#include <qapplication.h> #include <qapplication.h>
#include <qboxlayout.h> #include <qboxlayout.h>
#include <qconfig.h>
#include <qdesktopservices.h> #include <qdesktopservices.h>
#include <qfont.h> #include <qfont.h>
#include <qfontinfo.h> #include <qfontinfo.h>
@ -10,6 +12,7 @@
#include <qnamespace.h> #include <qnamespace.h>
#include <qobject.h> #include <qobject.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qtversion.h>
#include <qwidget.h> #include <qwidget.h>
#include "build.hpp" #include "build.hpp"
@ -37,20 +40,40 @@ CrashReporterGui::CrashReporterGui(QString reportFolder, int pid)
auto* mainLayout = new QVBoxLayout(this); auto* mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(new QLabel( auto qtVersionMatches = strcmp(qVersion(), QT_VERSION_STR) == 0;
"<u>Quickshell has crashed. Please submit a bug report to help us fix it.</u>", if (qtVersionMatches) {
this mainLayout->addWidget(new QLabel(
)); "<u>Quickshell has crashed. Please submit a bug report to help us fix it.</u>",
this
));
} else {
mainLayout->addWidget(
new QLabel("<u>Quickshell has crashed, likely due to a Qt version mismatch.</u>", this)
);
}
mainLayout->addSpacing(textHeight); mainLayout->addSpacing(textHeight);
mainLayout->addWidget(new QLabel("General information", this)); mainLayout->addWidget(new QLabel("General information", this));
mainLayout->addWidget(new ReportLabel("Git Revision:", GIT_REVISION, this)); mainLayout->addWidget(new ReportLabel("Git Revision:", GIT_REVISION, this));
mainLayout->addWidget(new QLabel(
QString::fromLatin1("Runtime Qt version: ") % qVersion() % ", Buildtime Qt version: "
% QT_VERSION_STR,
this
));
mainLayout->addWidget(new ReportLabel("Crashed process ID:", QString::number(pid), this)); mainLayout->addWidget(new ReportLabel("Crashed process ID:", QString::number(pid), this));
mainLayout->addWidget(new ReportLabel("Crash report folder:", this->reportFolder, this)); mainLayout->addWidget(new ReportLabel("Crash report folder:", this->reportFolder, this));
mainLayout->addSpacing(textHeight); mainLayout->addSpacing(textHeight);
mainLayout->addWidget(new QLabel("Please open a bug report for this issue via github or email.")); if (qtVersionMatches) {
mainLayout->addWidget(new QLabel("Please open a bug report for this issue via github or email.")
);
} else {
mainLayout->addWidget(new QLabel(
"Please rebuild Quickshell against the current Qt version.\n"
"If this does not solve the problem, please open a bug report via github or email."
));
}
mainLayout->addWidget(new ReportLabel( mainLayout->addWidget(new ReportLabel(
"Github:", "Github:",

View file

@ -4,6 +4,7 @@
#include <qapplication.h> #include <qapplication.h>
#include <qconfig.h> #include <qconfig.h>
#include <qcoreapplication.h>
#include <qdatastream.h> #include <qdatastream.h>
#include <qdir.h> #include <qdir.h>
#include <qfile.h> #include <qfile.h>
@ -12,7 +13,6 @@
#include <qtenvironmentvariables.h> #include <qtenvironmentvariables.h>
#include <qtextstream.h> #include <qtextstream.h>
#include <qtversion.h> #include <qtversion.h>
#include <qversiontagging.h>
#include <sys/sendfile.h> #include <sys/sendfile.h>
#include <sys/types.h> #include <sys/types.h>