Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt 6 compatibility #47762

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ public:
if(file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream stream( &file );
stream << "#define VERSION \\"" << version << "\\"" << endl;
stream << "#define LIBDIR \\"" << libdir << "/pushpin\\"" << endl;
stream << "#define CONFIGDIR \\"" << configdir << "/pushpin\\"" << endl;
stream << "#define VERSION \\"" << version << "\\"" << Qt::endl;
stream << "#define LIBDIR \\"" << libdir << "/pushpin\\"" << Qt::endl;
stream << "#define CONFIGDIR \\"" << configdir << "/pushpin\\"" << Qt::endl;
}

conf->addDefine("HAVE_CONFIG");
Expand Down Expand Up @@ -737,10 +737,15 @@ QStringList qc_pathlist()
QStringList list;
QString path = qc_getenv("PATH");
if (!path.isEmpty()) {
#if QT_VERSION >= 0x060000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does that qt version is coming from?
0x060000 in decimal is 393216

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qt::SplitBehavior flags = Qt::SkipEmptyParts;
#else
QString::SplitBehavior flags = QString::SkipEmptyParts;
#endif
#ifdef Q_OS_WIN
list = path.split(';', QString::SkipEmptyParts);
list = path.split(';', flags);
#else
list = path.split(':', QString::SkipEmptyParts);
list = path.split(':', flags);
#endif
}
#ifdef Q_OS_WIN
Expand Down
6 changes: 3 additions & 3 deletions qcm/conf.qcm
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public:
if(file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream stream( &file );
stream << "#define VERSION \"" << version << "\"" << endl;
stream << "#define LIBDIR \"" << libdir << "/pushpin\"" << endl;
stream << "#define CONFIGDIR \"" << configdir << "/pushpin\"" << endl;
stream << "#define VERSION \"" << version << "\"" << Qt::endl;
stream << "#define LIBDIR \"" << libdir << "/pushpin\"" << Qt::endl;
stream << "#define CONFIGDIR \"" << configdir << "/pushpin\"" << Qt::endl;
}

conf->addDefine("HAVE_CONFIG");
Expand Down
1 change: 0 additions & 1 deletion src/corelib/statsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "log.h"
#include "tnetstring.h"
#include "httpheaders.h"
#include "packet/statspacket.h"
#include "simplehttpserver.h"
#include "zutil.h"

Expand Down
3 changes: 1 addition & 2 deletions src/corelib/statsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
#define STATSMANAGER_H

#include <QObject>
#include "packet/statspacket.h"
#include "stats.h"

class QHostAddress;

class StatsPacket;

class StatsManager : public QObject
{
Q_OBJECT
Expand Down
1 change: 0 additions & 1 deletion src/corelib/zutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "zutil.h"

#include <QStringList>
#include <QFile>
#include "qzmqsocket.h"

Expand Down
4 changes: 2 additions & 2 deletions src/corelib/zutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#ifndef ZUTIL_H
#define ZUTIL_H

class QString;
class QStringList;
#include <QString>
#include <QStringList>

namespace QZmq {

Expand Down
6 changes: 5 additions & 1 deletion src/handler/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,10 @@ class AcceptWorker : public Deferred
// take over responsibility for request
ZhttpRequest *httpReq = zhttpIn->createRequestFromState(ss);

QSet<QString> implicitChannelsSet;
foreach(const QString &channel, implicitChannels)
implicitChannelsSet += channel;

HttpSession::AcceptData adata;
adata.requestData = origRequestData;
adata.logicalPeerAddress = rs.logicalPeerAddress;
Expand All @@ -1090,7 +1094,7 @@ class AcceptWorker : public Deferred
adata.route = route;
adata.statsRoute = statsRoute;
adata.channelPrefix = channelPrefix;
adata.implicitChannels = implicitChannels.toSet();
adata.implicitChannels = implicitChannelsSet;
adata.sid = sid;
adata.responseSent = responseSent;
adata.trusted = trusted;
Expand Down
4 changes: 2 additions & 2 deletions src/proxy/proxyutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static QByteArray make_token(const QByteArray &iss, const Jwt::EncodingKey &key)
{
QVariantMap claim;
claim["iss"] = QString::fromUtf8(iss);
claim["exp"] = QDateTime::currentDateTimeUtc().toTime_t() + 3600;
claim["exp"] = QDateTime::currentDateTimeUtc().toSecsSinceEpoch() + 3600;
return Jwt::encode(claim, key);
}

Expand All @@ -46,7 +46,7 @@ static bool validate_token(const QByteArray &token, const Jwt::DecodingKey &key)
QVariantMap claim = claimObj.toMap();

int exp = claim.value("exp").toInt();
if(exp <= 0 || (int)QDateTime::currentDateTimeUtc().toTime_t() >= exp)
if(exp <= 0 || (int)QDateTime::currentDateTimeUtc().toSecsSinceEpoch() >= exp)
return false;

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/routesfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class LineParser
else
{
Token token(Token::Error);
token.value = "unexpected escape character: " + str_[at];
token.value = QString("unexpected escape character: ") + str_[at];
return token;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/proxy/testhttprequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public slots:
response.reason = StatusReasons::getReason(response.code);
response.headers += HttpHeader("Content-Type", "text/plain");
response.headers += HttpHeader("Grip-Hold", "response");
response.headers += HttpHeader("Grip-Channel", QStringList(channels.toList()).join(", ").toUtf8());
response.headers += HttpHeader("Grip-Channel", QStringList(channels.values()).join(", ").toUtf8());
responseBody += QByteArray("nothing for now\n");
}
else if(path == "/stream")
Expand All @@ -119,7 +119,7 @@ public slots:
response.reason = StatusReasons::getReason(response.code);
response.headers += HttpHeader("Content-Type", "text/plain");
response.headers += HttpHeader("Grip-Hold", "stream");
response.headers += HttpHeader("Grip-Channel", QStringList(channels.toList()).join(", ").toUtf8());
response.headers += HttpHeader("Grip-Channel", QStringList(channels.values()).join(", ").toUtf8());
responseBody += QByteArray("[stream opened]\n");
}
else
Expand Down
14 changes: 10 additions & 4 deletions src/runner/mongrel2service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,25 @@ QString Mongrel2Service::formatLogLine(const QString &line) const
{
return filterLogLine(LOG_LEVEL_WARNING, "Can't parse mongrel2 log: " + line);
}
if(line.midRef(at + 1, end - at - 1) == "DEBUG")

#if QT_VERSION >= 0x060000
QStringView s = QStringView(line).mid(at + 1, end - at - 1);
#else
QStringRef s = line.midRef(at + 1, end - at - 1);
#endif
if(s.compare(QLatin1String("DEBUG")) == 0)
{
level = LOG_LEVEL_DEBUG;
}
else if(line.midRef(at + 1, end - at - 1) == "INFO")
else if(s.compare(QLatin1String("INFO")) == 0)
{
level = LOG_LEVEL_INFO;
}
else if(line.midRef(at + 1, end - at - 1) == "ERROR")
else if(s.compare(QLatin1String("ERROR")) == 0)
{
level = LOG_LEVEL_ERROR;
}
else if(line.midRef(at + 1, end - at - 1) == "WARN")
else if(s.compare(QLatin1String("WARN")) == 0)
{
level = LOG_LEVEL_WARNING;
}
Expand Down
24 changes: 17 additions & 7 deletions src/runner/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@

#define STOP_TIMEOUT 4000

static void setupChild()
{
signal(SIGINT, SIG_IGN);

// subprocesses hopefully respect SIG_IGN, but are not required
// to. in case subprocess might reinstate a SIGINT handler,
// detach from process group to ensure ctrl-c in a shell
// doesn't cause SIGINT to be sent directly to subprocesses
setpgid(0, 0);
}

class ServiceProcess : public QProcess
{
Q_OBJECT
Expand All @@ -40,19 +51,18 @@ class ServiceProcess : public QProcess
ServiceProcess(QObject *parent = 0) :
QProcess(parent)
{
#if QT_VERSION >= 0x060000
setChildProcessModifier(setupChild);
#endif
}

#if QT_VERSION < 0x060000
// reimplemented
virtual void setupChildProcess()
{
signal(SIGINT, SIG_IGN);

// subprocesses hopefully respect SIG_IGN, but are not required
// to. in case subprocess might reinstate a SIGINT handler,
// detach from process group to ensure ctrl-c in a shell
// doesn't cause SIGINT to be sent directly to subprocesses
setpgid(0, 0);
setupChild();
}
#endif
};

class Service::Private : public QObject
Expand Down
Loading