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 #ifdef Q_OS_WIN
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool FloatingDockContainer::nativeEvent(const QByteArray &eventType, void *message, long *result) 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); QWidget::nativeEvent(eventType, message, result);
MSG *msg = static_cast<MSG *>(message); 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 * 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; bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
# else
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#endif
#endif #endif
public: public:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -435,6 +435,31 @@ QDebug &operator<<(QDebug &stream, const EasingCurve &curve)
return stream; 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) QDataStream &operator<<(QDataStream &stream, const EasingCurve &curve)
{ {
// Ignore the active flag. // Ignore the active flag.

View File

@@ -81,48 +81,4 @@ public:
} // End namespace TimelineUtils. } // 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 } // namespace QmlDesigner

View File

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

View File

@@ -371,7 +371,13 @@ bool startDefaultDebugger(QString *errorMessage)
if (debug) if (debug)
qDebug() << "Default" << defaultDebugger; qDebug() << "Default" << defaultDebugger;
QProcess p; 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); p.start(defaultDebugger, QIODevice::NotOpen);
#endif
if (!p.waitForStarted()) { if (!p.waitForStarted()) {
*errorMessage = QString::fromLatin1("Unable to start %1!").arg(defaultDebugger); *errorMessage = QString::fromLatin1("Unable to start %1!").arg(defaultDebugger);
return false; return false;