Fix more compilation issues with Qt6

Various Windows related issues and issues with additional QML designer
components.
Don't use very generic template definitions if the type has to provide
not so generic base functionality (in this case providing a stream
operator for QDataStream).

Task-number: QTCREATORBUG-24098
Change-Id: Id0729c249d1b81e4e939fdaeb2e02b8a64e7e8f9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2020-11-02 11:19:12 +01:00
parent 241b45005a
commit 8527cbedcc
12 changed files with 70 additions and 69 deletions

View File

@@ -620,7 +620,11 @@ static const char* windowsMessageString(int messageId)
}
#ifdef Q_OS_WIN
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool FloatingDockContainer::nativeEvent(const QByteArray &eventType, void *message, long *result)
# else
bool FloatingDockContainer::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
# endif
{
QWidget::nativeEvent(eventType, message, result);
MSG *msg = static_cast<MSG *>(message);

View File

@@ -196,7 +196,11 @@ protected: // reimplements QWidget
/**
* Native event filter for handling WM_MOVING messages on Windows
*/
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
# else
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#endif
#endif
public:

View File

@@ -41,6 +41,7 @@
#include <QRegularExpression>
#include <QSettings>
#include <QTemporaryFile>
#include <QTextCodec>
#include <QTimer>
#include <QWinEventNotifier>
@@ -416,10 +417,8 @@ bool ConsoleProcess::start()
d->m_tempFile = nullptr;
return false;
}
QTextStream out(d->m_tempFile);
out.setCodec("UTF-16LE");
out.setGenerateByteOrderMark(false);
QString outString;
QTextStream out(&outString);
// Add PATH and SystemRoot environment variables in case they are missing
const QStringList fixedEnvironment = [env] {
QStringList envStrings = env;
@@ -441,14 +440,17 @@ bool ConsoleProcess::start()
for (const QString &var : fixedEnvironment)
out << var << QChar(0);
out << QChar(0);
out.flush();
if (out.status() != QTextStream::Ok) {
const QTextCodec *textCodec = QTextCodec::codecForName("UTF-16LE");
QTC_CHECK(textCodec);
const QByteArray outBytes = textCodec ? textCodec->fromUnicode(outString) : QByteArray();
if (!textCodec || d->m_tempFile->write(outBytes) < 0) {
stubServerShutdown();
emitError(QProcess::FailedToStart, msgCannotWriteTempFile());
delete d->m_tempFile;
d->m_tempFile = nullptr;
return false;
}
d->m_tempFile->flush();
}
STARTUPINFO si;

View File

@@ -786,7 +786,7 @@ void QtcProcess::terminate()
{
#ifdef Q_OS_WIN
if (m_useCtrlCStub)
EnumWindows(sendShutDownMessageToAllWindowsOfProcess_enumWnd, pid()->dwProcessId);
EnumWindows(sendShutDownMessageToAllWindowsOfProcess_enumWnd, processId());
else
#endif
QProcess::terminate();
@@ -796,7 +796,7 @@ void QtcProcess::interrupt()
{
#ifdef Q_OS_WIN
QTC_ASSERT(m_useCtrlCStub, return);
EnumWindows(sendInterruptMessageToAllWindowsOfProcess_enumWnd, pid()->dwProcessId);
EnumWindows(sendInterruptMessageToAllWindowsOfProcess_enumWnd, processId());
#endif
}

View File

@@ -30,6 +30,7 @@
#include "cppfileiterationorder.h"
#include <QHash>
#include <QSet>
#include <QStringList>
#include <set>

View File

@@ -145,10 +145,12 @@ GDB 32bit | Api | Api | NA | Win32
? QCoreApplication::applicationDirPath() + "/win32interrupt.exe"
: QCoreApplication::applicationDirPath() + "/win64interrupt.exe";
if (!QFile::exists(executable)) {
*errorMessage = QString::fromLatin1("%1 does not exist. If you have built %2 "
*errorMessage = QString::fromLatin1(
"%1 does not exist. If you have built %2 "
"on your own, checkout "
"https://code.qt.io/cgit/qt-creator/binary-artifacts.git/.").
arg(QDir::toNativeSeparators(executable), Core::Constants::IDE_DISPLAY_NAME);
"https://code.qt.io/cgit/qt-creator/binary-artifacts.git/.")
.arg(QDir::toNativeSeparators(executable),
QString(Core::Constants::IDE_DISPLAY_NAME));
break;
}
switch (QProcess::execute(executable, QStringList(QString::number(pID)))) {

View File

@@ -181,11 +181,12 @@ GDB 32bit | Api | Api | N/A | Win32
? QLatin1String("/win32interrupt.exe")
: QLatin1String("/win64interrupt.exe");
if (!QFile::exists(executable)) {
appendMsgCannotInterrupt(pid, tr( "%1 does not exist. If you built %2 "
appendMsgCannotInterrupt(pid,
tr("%1 does not exist. If you built %2 "
"yourself, check out https://code.qt.io/cgit/"
"qt-creator/binary-artifacts.git/.").
arg(QDir::toNativeSeparators(executable),
Core::Constants::IDE_DISPLAY_NAME));
"qt-creator/binary-artifacts.git/.")
.arg(QDir::toNativeSeparators(executable),
QString(Core::Constants::IDE_DISPLAY_NAME)));
}
switch (QProcess::execute(executable, QStringList(QString::number(pid)))) {
case -2:

View File

@@ -265,11 +265,11 @@ void ItemLibraryAssetImporter::parseQuick3DAsset(const QString &file, const QVar
if (!currentChar.isLetter() && !currentChar.isDigit())
currentChar = QLatin1Char('_');
}
QCharRef firstChar = assetName[0];
const QChar firstChar = assetName[0];
if (firstChar.isDigit())
firstChar = QLatin1Char('_');
assetName[0] = QLatin1Char('_');
if (firstChar.isLower())
firstChar = firstChar.toUpper();
assetName[0] = firstChar.toUpper();
}
QString targetDirPath = targetDir.filePath(assetName);
@@ -378,9 +378,9 @@ void ItemLibraryAssetImporter::parseQuick3DAsset(const QString &file, const QVar
QFile file(outDir.path() + '/' + fi.baseName() + ".hints");
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << "visibleInNavigator: true" << endl;
out << "canBeDroppedInFormEditor: false" << endl;
out << "canBeDroppedInView3D: true" << endl;
out << "visibleInNavigator: true" << Qt::endl;
out << "canBeDroppedInFormEditor: false" << Qt::endl;
out << "canBeDroppedInView3D: true" << Qt::endl;
file.close();
}
QString outIconSource = QString::fromUtf8(content);

View File

@@ -435,6 +435,31 @@ QDebug &operator<<(QDebug &stream, const EasingCurve &curve)
return stream;
}
QDataStream &operator<<(QDataStream &stream, const std::vector<int> &vec)
{
stream << static_cast<quint64>(vec.size());
for (const auto &elem : vec)
stream << elem;
return stream;
}
QDataStream &operator>>(QDataStream &stream, std::vector<int> &vec)
{
quint64 s;
stream >> s;
vec.clear();
vec.reserve(s);
int val;
for (quint64 i = 0; i < s; ++i) {
stream >> val;
vec.push_back(val);
}
return stream;
}
QDataStream &operator<<(QDataStream &stream, const EasingCurve &curve)
{
// Ignore the active flag.

View File

@@ -81,48 +81,4 @@ public:
} // End namespace TimelineUtils.
template<typename T>
inline std::istream &operator>>(std::istream &stream, std::vector<T> &vec)
{
quint64 s;
stream >> s;
vec.clear();
vec.reserve(s);
T val;
for (quint64 i = 0; i < s; ++i) {
stream >> val;
vec.push_back(val);
}
return stream;
}
template<typename T>
inline QDataStream &operator<<(QDataStream &stream, const std::vector<T> &vec)
{
stream << static_cast<quint64>(vec.size());
for (const auto &elem : vec)
stream << elem;
return stream;
}
template<typename T>
inline QDataStream &operator>>(QDataStream &stream, std::vector<T> &vec)
{
quint64 s;
stream >> s;
vec.clear();
vec.reserve(s);
T val;
for (quint64 i = 0; i < s; ++i) {
stream >> val;
vec.push_back(val);
}
return stream;
}
} // namespace QmlDesigner

View File

@@ -121,7 +121,7 @@ extend_qtc_executable(qml2puppet
find_package(Qt5 5.15.0 COMPONENTS Quick3D QUIET)
extend_qtc_executable(qml2puppet
CONDITION TARGET Qt5::Quick3D
FEATURE_INFO "Qt Quick 3D"
FEATURE_INFO "Qt Quick 3D support"
DEPENDS Qt5::Quick3D Qt5::Quick3DPrivate
DEFINES QUICK3D_MODULE

View File

@@ -371,7 +371,13 @@ bool startDefaultDebugger(QString *errorMessage)
if (debug)
qDebug() << "Default" << defaultDebugger;
QProcess p;
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList arguments = QProcess::splitCommand(defaultDebugger);
const QString executable = arguments.takeFirst();
p.start(executable, arguments, QIODevice::NotOpen);
#else
p.start(defaultDebugger, QIODevice::NotOpen);
#endif
if (!p.waitForStarted()) {
*errorMessage = QString::fromLatin1("Unable to start %1!").arg(defaultDebugger);
return false;