Misc.: fix narrowing conversion warnings with explicit cast to int
And using qsizetype in some places. ::pathconf() returns long. Found by using -Wshorten-64-to-32 clang compiler flag, or adding that flag to the flags clangd uses. Change-Id: I9f9abd3d4d6fe73f525eec869ceabc799317f3d6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 8d77ee0f2b042af7aec43e1e83eb26d92c2f8234) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e71dfbb7db
commit
f22bedf5af
@ -905,7 +905,7 @@ const QList<QMessageDialogOptions::CustomButton> &QMessageDialogOptions::customB
|
|||||||
|
|
||||||
const QMessageDialogOptions::CustomButton *QMessageDialogOptions::customButton(int id)
|
const QMessageDialogOptions::CustomButton *QMessageDialogOptions::customButton(int id)
|
||||||
{
|
{
|
||||||
int i = d->customButtons.indexOf(CustomButton(id));
|
const int i = int(d->customButtons.indexOf(CustomButton(id)));
|
||||||
return (i < 0 ? nullptr : &d->customButtons.at(i));
|
return (i < 0 ? nullptr : &d->customButtons.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,14 +179,14 @@ bool QPlatformGraphicsBufferHelper::bindSWToTexture(const QPlatformGraphicsBuffe
|
|||||||
QRect rect = subRect;
|
QRect rect = subRect;
|
||||||
if (rect.isNull() || rect == QRect(QPoint(0,0),size)) {
|
if (rect.isNull() || rect == QRect(QPoint(0,0),size)) {
|
||||||
if (needsRowLength)
|
if (needsRowLength)
|
||||||
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, image.bytesPerLine() / 4);
|
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, GLint(image.bytesPerLine() / 4));
|
||||||
funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, size.width(), size.height(), 0, GL_RGBA, pixelType, image.constBits());
|
funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, size.width(), size.height(), 0, GL_RGBA, pixelType, image.constBits());
|
||||||
if (needsRowLength)
|
if (needsRowLength)
|
||||||
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
} else {
|
} else {
|
||||||
if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
|
if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
|
||||||
// OpenGL 2.1+ or OpenGL ES/3+
|
// OpenGL 2.1+ or OpenGL ES/3+
|
||||||
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, image.bytesPerLine() / 4);
|
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, GLint(image.bytesPerLine() / 4));
|
||||||
funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, pixelType,
|
funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, pixelType,
|
||||||
image.constScanLine(rect.y()) + rect.x() * 4);
|
image.constScanLine(rect.y()) + rect.x() * 4);
|
||||||
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
@ -651,7 +651,7 @@ void QFileDialogPrivate::retranslateStrings()
|
|||||||
if (proxyModel)
|
if (proxyModel)
|
||||||
abstractModel = proxyModel;
|
abstractModel = proxyModel;
|
||||||
#endif
|
#endif
|
||||||
int total = qMin(abstractModel->columnCount(QModelIndex()), actions.size() + 1);
|
const int total = qMin(abstractModel->columnCount(QModelIndex()), int(actions.size() + 1));
|
||||||
for (int i = 1; i < total; ++i) {
|
for (int i = 1; i < total; ++i) {
|
||||||
actions.at(i - 1)->setText(QFileDialog::tr("Show ") + abstractModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
|
actions.at(i - 1)->setText(QFileDialog::tr("Show ") + abstractModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
|
||||||
}
|
}
|
||||||
@ -1770,7 +1770,7 @@ QLineEdit *QFileDialogPrivate::lineEdit() const {
|
|||||||
return (QLineEdit*)qFileDialogUi->fileNameEdit;
|
return (QLineEdit*)qFileDialogUi->fileNameEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QFileDialogPrivate::maxNameLength(const QString &path)
|
long QFileDialogPrivate::maxNameLength(const QString &path)
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_UNIX)
|
#if defined(Q_OS_UNIX)
|
||||||
return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);
|
return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);
|
||||||
@ -2730,7 +2730,7 @@ void QFileDialog::accept()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!info.exists()) {
|
if (!info.exists()) {
|
||||||
int maxNameLength = d->maxNameLength(info.path());
|
const long maxNameLength = d->maxNameLength(info.path());
|
||||||
if (maxNameLength >= 0 && info.fileName().size() > maxNameLength)
|
if (maxNameLength >= 0 && info.fileName().size() > maxNameLength)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2866,7 +2866,7 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo
|
|||||||
if (proxyModel)
|
if (proxyModel)
|
||||||
abstractModel = proxyModel;
|
abstractModel = proxyModel;
|
||||||
#endif
|
#endif
|
||||||
int total = qMin(abstractModel->columnCount(QModelIndex()), actions.size() + 1);
|
const int total = qMin(abstractModel->columnCount(QModelIndex()), int(actions.size() + 1));
|
||||||
for (int i = 1; i < total; ++i)
|
for (int i = 1; i < total; ++i)
|
||||||
actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i));
|
actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i));
|
||||||
|
|
||||||
@ -3109,7 +3109,8 @@ void QFileDialogPrivate::_q_showHeader(QAction *action)
|
|||||||
{
|
{
|
||||||
Q_Q(QFileDialog);
|
Q_Q(QFileDialog);
|
||||||
QActionGroup *actionGroup = qobject_cast<QActionGroup*>(q->sender());
|
QActionGroup *actionGroup = qobject_cast<QActionGroup*>(q->sender());
|
||||||
qFileDialogUi->treeView->header()->setSectionHidden(actionGroup->actions().indexOf(action) + 1, !action->isChecked());
|
qFileDialogUi->treeView->header()->setSectionHidden(int(actionGroup->actions().indexOf(action) + 1),
|
||||||
|
!action->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_CONFIG(proxymodel)
|
#if QT_CONFIG(proxymodel)
|
||||||
@ -3671,7 +3672,7 @@ void QFileDialogPrivate::_q_updateOkButton()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!idx.isValid()) {
|
if (!idx.isValid()) {
|
||||||
int maxLength = maxNameLength(fileDir);
|
const long maxLength = maxNameLength(fileDir);
|
||||||
enableButton = maxLength < 0 || fileName.size() <= maxLength;
|
enableButton = maxLength < 0 || fileName.size() <= maxLength;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3803,7 +3804,7 @@ void QFileDialogPrivate::_q_useNameFilter(int index)
|
|||||||
QString fileName = lineEdit()->text();
|
QString fileName = lineEdit()->text();
|
||||||
const QString fileNameExtension = QFileInfo(fileName).suffix();
|
const QString fileNameExtension = QFileInfo(fileName).suffix();
|
||||||
if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) {
|
if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) {
|
||||||
const int fileNameExtensionLength = fileNameExtension.size();
|
const qsizetype fileNameExtensionLength = fileNameExtension.size();
|
||||||
fileName.replace(fileName.size() - fileNameExtensionLength,
|
fileName.replace(fileName.size() - fileNameExtensionLength,
|
||||||
fileNameExtensionLength, newNameFilterExtension);
|
fileNameExtensionLength, newNameFilterExtension);
|
||||||
qFileDialogUi->listView->clearSelection();
|
qFileDialogUi->listView->clearSelection();
|
||||||
|
@ -120,11 +120,11 @@ public:
|
|||||||
|
|
||||||
QLineEdit *lineEdit() const;
|
QLineEdit *lineEdit() const;
|
||||||
|
|
||||||
static int maxNameLength(const QString &path);
|
static long maxNameLength(const QString &path);
|
||||||
|
|
||||||
QString basename(const QString &path) const
|
QString basename(const QString &path) const
|
||||||
{
|
{
|
||||||
int separator = QDir::toNativeSeparators(path).lastIndexOf(QDir::separator());
|
const qsizetype separator = QDir::toNativeSeparators(path).lastIndexOf(QDir::separator());
|
||||||
if (separator != -1)
|
if (separator != -1)
|
||||||
return path.mid(separator + 1);
|
return path.mid(separator + 1);
|
||||||
return path;
|
return path;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user