forked from qt-creator/qt-creator
Fix some deprecation warnings
warning C4996: 'QString::fromUcs4': Use char32_t* overload. warning C4996: 'QString::fromUtf16': Use char16_t* overload. id.cpp(133): warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied navigationtreeview.cpp(47): warning C4996: 'QAbstractItemView::itemDelegate': Use itemDelegateForIndex instead transientscroll.cpp(428): warning C4996: 'QHoverEvent::pos': Use position() qmldebugconnectionmanager.cpp(194): warning C4996: 'QScopedPointer<QmlDebug::QmlDebugConnection,QScopedPointerDeleter<T>>::take': Use std::unique_ptr instead, and call release(). qmljsdocument.cpp(373): warning C4996: 'QCryptographicHash::addData': Use the QByteArrayView overload instead Change-Id: I4827cc105b0a6af94ff2a5f72edab99997b5ae98 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
c507666fda
commit
8fbca39c97
@@ -67,7 +67,7 @@ void QmlDebugConnectionManager::connectToTcpServer()
|
||||
QTC_ASSERT(!isConnected(), return);
|
||||
|
||||
if (++(m_numRetries) < m_maximumRetries) {
|
||||
if (m_connection.isNull()) {
|
||||
if (!m_connection) {
|
||||
// If the previous connection failed, recreate it.
|
||||
createConnection();
|
||||
m_connection->connectToHost(m_server.host(), port16(m_server));
|
||||
@@ -90,7 +90,7 @@ void QmlDebugConnectionManager::connectToTcpServer()
|
||||
});
|
||||
m_connectionTimer.start(m_retryInterval);
|
||||
|
||||
if (m_connection.isNull()) {
|
||||
if (!m_connection) {
|
||||
createConnection();
|
||||
QTC_ASSERT(m_connection, emit connectionFailed(); return);
|
||||
m_connection->connectToHost(m_server.host(), port16(m_server));
|
||||
@@ -116,7 +116,7 @@ void QmlDebugConnectionManager::startLocalServer()
|
||||
});
|
||||
m_connectionTimer.start(m_retryInterval);
|
||||
|
||||
if (m_connection.isNull()) {
|
||||
if (!m_connection) {
|
||||
// Otherwise, reuse the same one
|
||||
createConnection();
|
||||
QTC_ASSERT(m_connection, emit connectionFailed(); return);
|
||||
@@ -143,12 +143,12 @@ void QmlDebugConnectionManager::logState(const QString &message)
|
||||
|
||||
QmlDebugConnection *QmlDebugConnectionManager::connection() const
|
||||
{
|
||||
return m_connection.data();
|
||||
return m_connection.get();
|
||||
}
|
||||
|
||||
void QmlDebugConnectionManager::createConnection()
|
||||
{
|
||||
QTC_ASSERT(m_connection.isNull(), destroyConnection());
|
||||
QTC_ASSERT(!m_connection, destroyConnection());
|
||||
|
||||
m_connection.reset(new QmlDebug::QmlDebugConnection);
|
||||
|
||||
@@ -159,16 +159,16 @@ void QmlDebugConnectionManager::createConnection()
|
||||
void QmlDebugConnectionManager::connectConnectionSignals()
|
||||
{
|
||||
QTC_ASSERT(m_connection, return);
|
||||
QObject::connect(m_connection.data(), &QmlDebug::QmlDebugConnection::connected,
|
||||
QObject::connect(m_connection.get(), &QmlDebug::QmlDebugConnection::connected,
|
||||
this, &QmlDebugConnectionManager::qmlDebugConnectionOpened);
|
||||
QObject::connect(m_connection.data(), &QmlDebug::QmlDebugConnection::disconnected,
|
||||
QObject::connect(m_connection.get(), &QmlDebug::QmlDebugConnection::disconnected,
|
||||
this, &QmlDebugConnectionManager::qmlDebugConnectionClosed);
|
||||
QObject::connect(m_connection.data(), &QmlDebug::QmlDebugConnection::connectionFailed,
|
||||
QObject::connect(m_connection.get(), &QmlDebug::QmlDebugConnection::connectionFailed,
|
||||
this, &QmlDebugConnectionManager::qmlDebugConnectionFailed);
|
||||
|
||||
QObject::connect(m_connection.data(), &QmlDebug::QmlDebugConnection::logStateChange,
|
||||
QObject::connect(m_connection.get(), &QmlDebug::QmlDebugConnection::logStateChange,
|
||||
this, &QmlDebugConnectionManager::logState);
|
||||
QObject::connect(m_connection.data(), &QmlDebug::QmlDebugConnection::logError,
|
||||
QObject::connect(m_connection.get(), &QmlDebug::QmlDebugConnection::logError,
|
||||
this, &QmlDebugConnectionManager::logState);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ void QmlDebugConnectionManager::destroyConnection()
|
||||
// Don't receive any more signals from the connection or the client
|
||||
disconnectConnectionSignals();
|
||||
destroyClients();
|
||||
m_connection.take()->deleteLater();
|
||||
m_connection.release()->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,9 +6,9 @@
|
||||
#include <qmldebug/qmldebug_global.h>
|
||||
#include <qmldebug/qmldebugclient.h>
|
||||
|
||||
#include <QPointer>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <memory>
|
||||
|
||||
namespace QmlDebug {
|
||||
|
||||
@@ -49,7 +49,7 @@ private:
|
||||
void connectToTcpServer();
|
||||
void startLocalServer();
|
||||
|
||||
QScopedPointer<QmlDebug::QmlDebugConnection> m_connection;
|
||||
std::unique_ptr<QmlDebug::QmlDebugConnection> m_connection;
|
||||
QTimer m_connectionTimer;
|
||||
QUrl m_server;
|
||||
|
||||
|
@@ -370,7 +370,7 @@ QByteArray LibraryInfo::calculateFingerprint() const
|
||||
{
|
||||
QCryptographicHash hash(QCryptographicHash::Sha1);
|
||||
auto addData = [&hash](auto p, size_t len) {
|
||||
hash.addData(reinterpret_cast<const char *>(p), len);
|
||||
hash.addData(QByteArrayView(reinterpret_cast<const char *>(p), len));
|
||||
};
|
||||
|
||||
addData(&_status, sizeof(_status));
|
||||
@@ -621,10 +621,10 @@ LibraryInfo Snapshot::libraryInfo(const Utils::FilePath &path) const
|
||||
void ModuleApiInfo::addToHash(QCryptographicHash &hash) const
|
||||
{
|
||||
int len = uri.length();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(uri.constData()), len * sizeofQChar);
|
||||
hash.addData(QByteArrayView(reinterpret_cast<const char *>(&len), sizeof(len)));
|
||||
hash.addData(QByteArrayView(reinterpret_cast<const char *>(uri.constData()), len * sizeofQChar));
|
||||
version.addToHash(hash);
|
||||
len = cppName.length();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(cppName.constData()), len * sizeofQChar);
|
||||
hash.addData(QByteArrayView(reinterpret_cast<const char *>(&len), sizeof(len)));
|
||||
hash.addData(QByteArrayView(reinterpret_cast<const char *>(cppName.constData()), len * sizeofQChar));
|
||||
}
|
||||
|
@@ -226,7 +226,7 @@ struct TerminalSurfacePrivate
|
||||
{
|
||||
TerminalCell result;
|
||||
result.width = cell.width;
|
||||
result.text = QString::fromUcs4(cell.chars);
|
||||
result.text = QString::fromUcs4(reinterpret_cast<const char32_t *>(cell.chars));
|
||||
|
||||
const VTermColor *bg = &cell.bg;
|
||||
const VTermColor *fg = &cell.fg;
|
||||
@@ -459,7 +459,8 @@ std::u32string::value_type TerminalSurface::fetchCharAt(int x, int y) const
|
||||
if (cell->chars[0] == 0xffffffff)
|
||||
return 0;
|
||||
|
||||
QString s = QString::fromUcs4(cell->chars, 6).normalized(QString::NormalizationForm_C);
|
||||
QString s = QString::fromUcs4(reinterpret_cast<const char32_t *>(cell->chars), 6)
|
||||
.normalized(QString::NormalizationForm_C);
|
||||
const QList<uint> ucs4 = s.toUcs4();
|
||||
return std::u32string(ucs4.begin(), ucs4.end()).front();
|
||||
}
|
||||
|
@@ -807,7 +807,7 @@ QString FileUtils::normalizedPathName(const QString &name)
|
||||
TCHAR buffer[MAX_PATH];
|
||||
const bool success = SHGetPathFromIDList(file, buffer);
|
||||
ILFree(file);
|
||||
return success ? QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const ushort *>(buffer)))
|
||||
return success ? QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const char16_t *>(buffer)))
|
||||
: name;
|
||||
#elif defined(Q_OS_MACOS)
|
||||
return Internal::normalizePathName(name);
|
||||
|
@@ -130,7 +130,7 @@ Id::Id(const char *name)
|
||||
|
||||
Id Id::generate()
|
||||
{
|
||||
return {QUuid::createUuid().toByteArray()};
|
||||
return Id{QUuid::createUuid().toByteArray()};
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -44,7 +44,7 @@ void NavigationTreeView::scrollTo(const QModelIndex &index, QAbstractItemView::S
|
||||
const int viewportWidth = viewport()->width();
|
||||
QRect itemRect = visualRect(index);
|
||||
|
||||
QAbstractItemDelegate *delegate = itemDelegate(index);
|
||||
QAbstractItemDelegate *delegate = itemDelegateForIndex(index);
|
||||
if (delegate) {
|
||||
QStyleOptionViewItem option;
|
||||
initViewItemOption(&option);
|
||||
|
@@ -425,7 +425,7 @@ bool ScrollBar::event(QEvent *event)
|
||||
&option,
|
||||
QStyle::SC_ScrollBarSlider,
|
||||
this)
|
||||
.contains(hoverEvent->pos());
|
||||
.contains(hoverEvent->position().toPoint());
|
||||
|
||||
d->isGrooveUnderCursor = !d->isHandleUnderCursor
|
||||
&& style()
|
||||
@@ -433,7 +433,7 @@ bool ScrollBar::event(QEvent *event)
|
||||
&option,
|
||||
QStyle::SC_ScrollBarGroove,
|
||||
this)
|
||||
.contains(hoverEvent->pos());
|
||||
.contains(hoverEvent->position().toPoint());
|
||||
}
|
||||
} break;
|
||||
case QEvent::HoverLeave:
|
||||
|
@@ -20,7 +20,7 @@ QTCREATOR_UTILS_EXPORT QString winErrorMessage(unsigned long error)
|
||||
{
|
||||
QString rc = QString::fromLatin1("#%1: ").arg(error);
|
||||
#ifdef Q_OS_WIN
|
||||
ushort *lpMsgBuf;
|
||||
char16_t *lpMsgBuf;
|
||||
|
||||
const int len = FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
@@ -160,7 +160,7 @@ QTCREATOR_UTILS_EXPORT QString imageName(quint32 processId)
|
||||
wchar_t path[MAX_PATH];
|
||||
DWORD pathLen = MAX_PATH;
|
||||
if (QueryFullProcessImageName(handle, 0, path, &pathLen))
|
||||
result = QString::fromUtf16(reinterpret_cast<const ushort*>(path));
|
||||
result = QString::fromUtf16(reinterpret_cast<const char16_t*>(path));
|
||||
CloseHandle(handle);
|
||||
#else
|
||||
Q_UNUSED(processId)
|
||||
|
Reference in New Issue
Block a user