Skip to content

Commit da28317

Browse files
committed
#3484 bookmarks: fix GCC build failure
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 47c58a0 commit da28317

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# QOwnNotes Changelog
22

3+
## 26.3.7
4+
5+
- Fixed an xUbuntu 20.04 / GCC build failure caused by duplicate `qstring_literal`
6+
symbols in `WebSocketServerService::httpResponse` by replacing
7+
`QStringLiteral` default arguments with overloads
8+
(for [#3484](https://github.com/pbek/QOwnNotes/issues/3484))
9+
310
## 26.3.6
411

512
- Added a local [Homepage](https://github.com/gethomepage/homepage)-compatible

src/services/websocketserverservice.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,21 +300,32 @@ QPair<QString, QHash<QString, QString>> WebSocketServerService::parseHttpRequest
300300
return {method, queryParams};
301301
}
302302

303+
QString WebSocketServerService::httpResponse(int statusCode, const QByteArray &body) {
304+
return httpResponse(statusCode, body, QLatin1String("OK"));
305+
}
306+
307+
QString WebSocketServerService::httpResponse(int statusCode, const QByteArray &body,
308+
const QString &statusText) {
309+
return httpResponse(statusCode, body, statusText,
310+
QLatin1String("application/json; charset=utf-8"));
311+
}
312+
303313
QString WebSocketServerService::httpResponse(int statusCode, const QByteArray &body,
304314
const QString &statusText,
305315
const QString &contentType) {
306-
return QStringLiteral(
307-
"HTTP/1.1 %1 %2\r\n"
308-
"Content-Type: %3\r\n"
309-
"Content-Length: %4\r\n"
310-
"Access-Control-Allow-Origin: *\r\n"
311-
"Access-Control-Allow-Methods: GET, OPTIONS\r\n"
312-
"Access-Control-Allow-Headers: Content-Type\r\n"
313-
"Cache-Control: no-store\r\n"
314-
"Connection: close\r\n"
315-
"\r\n%5")
316-
.arg(QString::number(statusCode), statusText, contentType, QString::number(body.size()),
317-
QString::fromUtf8(body));
316+
const QString responseTemplate = QString::fromLatin1(
317+
"HTTP/1.1 %1 %2\r\n"
318+
"Content-Type: %3\r\n"
319+
"Content-Length: %4\r\n"
320+
"Access-Control-Allow-Origin: *\r\n"
321+
"Access-Control-Allow-Methods: GET, OPTIONS\r\n"
322+
"Access-Control-Allow-Headers: Content-Type\r\n"
323+
"Cache-Control: no-store\r\n"
324+
"Connection: close\r\n"
325+
"\r\n%5");
326+
327+
return responseTemplate.arg(QString::number(statusCode), statusText, contentType,
328+
QString::number(body.size()), QString::fromUtf8(body));
318329
}
319330

320331
QVector<Bookmark> WebSocketServerService::getBookmarksForSuggestions() {

src/services/websocketserverservice.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,12 @@ class WebSocketServerService : public QObject {
9797
static QPair<QString, QHash<QString, QString>> parseHttpRequestLineAndQuery(
9898
const QString &request);
9999

100-
static QString httpResponse(
101-
int statusCode, const QByteArray &body, const QString &statusText = QStringLiteral("OK"),
102-
const QString &contentType = QStringLiteral("application/json; charset=utf-8"));
100+
static QString httpResponse(int statusCode, const QByteArray &body);
101+
102+
static QString httpResponse(int statusCode, const QByteArray &body, const QString &statusText);
103+
104+
static QString httpResponse(int statusCode, const QByteArray &body, const QString &statusText,
105+
const QString &contentType);
103106

104107
void startSuggestionHttpServer();
105108

0 commit comments

Comments
 (0)