Skip to content

Commit 4c2d7a7

Browse files
committed
crash: print warning messages for run/buildtime Qt version mismatch
1 parent 89d04f3 commit 4c2d7a7

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ It is not managed by us and should be looked over before use.
6767

6868
[AUR package]: https://aur.archlinux.org/packages/quickshell
6969

70+
> [!CAUTION]
71+
> The AUR provides no way to force the quickshell package to rebuild when the Qt version changes.
72+
> If you experience crashes after updating Qt, please try rebuilding Quickshell against the
73+
> current Qt version before opening an issue.
74+
7075
## Fedora (COPR)
7176
Quickshell has a third party [Fedora COPR package] available under the same name.
7277
It is not managed by us and should be looked over before use.

src/core/main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <cerrno>
55
#include <cstdio>
66
#include <cstdlib>
7+
#include <cstring>
78
#include <limits>
89
#include <string>
910
#include <vector>
@@ -176,6 +177,7 @@ struct CommandState {
176177
} subcommand;
177178

178179
struct {
180+
bool checkCompat = false;
179181
bool printVersion = false;
180182
bool killAll = false;
181183
bool noDuplicate = false;
@@ -290,6 +292,8 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
290292
addDebugOptions(&cli);
291293

292294
{
295+
cli.add_option_group("")->add_flag("--private-check-compat", state.misc.checkCompat);
296+
293297
cli.add_flag("-V,--version", state.misc.printVersion)
294298
->description("Print quickshell's version and exit.");
295299

@@ -378,6 +382,18 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
378382

379383
CLI11_PARSE(cli, argc, argv);
380384

385+
if (state.misc.checkCompat) {
386+
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
387+
QTextStream(stdout) << "\033[31mCOMPATIBILITY WARNING: Quickshell was built against Qt "
388+
<< QT_VERSION_STR << " but the system has updated to Qt " << qVersion()
389+
<< " without rebuilding the package. This is likely to cause crashes, so "
390+
"you must rebuild the quickshell package.\n";
391+
return 1;
392+
}
393+
394+
return 0;
395+
}
396+
381397
// Has to happen before extra threads are spawned.
382398
if (state.misc.daemonize) {
383399
auto closepipes = std::array<int, 2>();
@@ -451,6 +467,13 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
451467
} else if (*state.subcommand.msg) {
452468
return msgInstance(state);
453469
} else {
470+
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
471+
qWarning() << "\033[31mQuickshell was built against Qt" << QT_VERSION_STR
472+
<< "but the system has updated to Qt" << qVersion()
473+
<< "without rebuilding the package. This is likely to cause crashes, so "
474+
"the quickshell package must be rebuilt.\n";
475+
}
476+
454477
return launchFromCommand(state, coreApplication);
455478
}
456479

src/crash/interface.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
#include "interface.hpp"
2+
#include <cstring>
23
#include <utility>
34

45
#include <qapplication.h>
56
#include <qboxlayout.h>
7+
#include <qconfig.h>
68
#include <qdesktopservices.h>
79
#include <qfont.h>
810
#include <qfontinfo.h>
911
#include <qlabel.h>
1012
#include <qnamespace.h>
1113
#include <qobject.h>
1214
#include <qpushbutton.h>
15+
#include <qtversion.h>
1316
#include <qwidget.h>
1417

1518
#include "build.hpp"
@@ -37,20 +40,40 @@ CrashReporterGui::CrashReporterGui(QString reportFolder, int pid)
3740

3841
auto* mainLayout = new QVBoxLayout(this);
3942

40-
mainLayout->addWidget(new QLabel(
41-
"<u>Quickshell has crashed. Please submit a bug report to help us fix it.</u>",
42-
this
43-
));
43+
auto qtVersionMatches = strcmp(qVersion(), QT_VERSION_STR) == 0;
44+
if (qtVersionMatches) {
45+
mainLayout->addWidget(new QLabel(
46+
"<u>Quickshell has crashed. Please submit a bug report to help us fix it.</u>",
47+
this
48+
));
49+
} else {
50+
mainLayout->addWidget(
51+
new QLabel("<u>Quickshell has crashed, likely due to a Qt version mismatch.</u>", this)
52+
);
53+
}
4454

4555
mainLayout->addSpacing(textHeight);
4656

4757
mainLayout->addWidget(new QLabel("General information", this));
4858
mainLayout->addWidget(new ReportLabel("Git Revision:", GIT_REVISION, this));
59+
mainLayout->addWidget(new QLabel(
60+
QString::fromLatin1("Runtime Qt version: ") % qVersion() % ", Buildtime Qt version: "
61+
% QT_VERSION_STR,
62+
this
63+
));
4964
mainLayout->addWidget(new ReportLabel("Crashed process ID:", QString::number(pid), this));
5065
mainLayout->addWidget(new ReportLabel("Crash report folder:", this->reportFolder, this));
5166
mainLayout->addSpacing(textHeight);
5267

53-
mainLayout->addWidget(new QLabel("Please open a bug report for this issue via github or email."));
68+
if (qtVersionMatches) {
69+
mainLayout->addWidget(new QLabel("Please open a bug report for this issue via github or email.")
70+
);
71+
} else {
72+
mainLayout->addWidget(new QLabel(
73+
"Please rebuild Quickshell against the current Qt version.\n"
74+
"If this does not solve the problem, please open a bug report via github or email."
75+
));
76+
}
5477

5578
mainLayout->addWidget(new ReportLabel(
5679
"Github:",

src/crash/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <qapplication.h>
66
#include <qconfig.h>
7+
#include <qcoreapplication.h>
78
#include <qdatastream.h>
89
#include <qdir.h>
910
#include <qfile.h>
@@ -12,7 +13,6 @@
1213
#include <qtenvironmentvariables.h>
1314
#include <qtextstream.h>
1415
#include <qtversion.h>
15-
#include <qversiontagging.h>
1616
#include <sys/sendfile.h>
1717
#include <sys/types.h>
1818

0 commit comments

Comments
 (0)