diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 3b3dbd1321..124e2bfa29 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -275,6 +275,7 @@ qt_internal_add_module(Gui QT_NO_CONTEXTLESS_CONNECT QT_NO_FOREACH QT_NO_USING_NAMESPACE + QT_NO_QSNPRINTF QT_USE_NODISCARD_FILE_OPEN QT_QPA_DEFAULT_PLATFORM_NAME="${QT_QPA_DEFAULT_PLATFORM}" INCLUDE_DIRECTORIES diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 5b7792fb51..b7e2e7071b 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include QT_BEGIN_NAMESPACE @@ -167,11 +169,11 @@ static bool write_xbm_image(const QImage &sourceImage, QIODevice *device, const const auto msize = s.size() + 100; char *buf = new char[msize]; - qsnprintf(buf, msize, "#define %s_width %d\n", s.data(), w); + std::snprintf(buf, msize, "#define %s_width %d\n", s.data(), w); device->write(buf, qstrlen(buf)); - qsnprintf(buf, msize, "#define %s_height %d\n", s.data(), h); + std::snprintf(buf, msize, "#define %s_height %d\n", s.data(), h); device->write(buf, qstrlen(buf)); - qsnprintf(buf, msize, "static char %s_bits[] = {\n ", s.data()); + std::snprintf(buf, msize, "static char %s_bits[] = {\n ", s.data()); device->write(buf, qstrlen(buf)); if (image.format() != QImage::Format_MonoLSB) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 680f30c852..285d2e3f4a 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #ifndef QT_NO_COMPRESS @@ -1750,30 +1751,30 @@ void QPdfEnginePrivate::writeInfo(const QDateTime &date) constexpr size_t formattedDateSize = 26; char formattedDate[formattedDateSize]; const int year = qBound(0, d.year(), 9999); // ASN.1, max 4 digits - auto printedSize = qsnprintf(formattedDate, - formattedDateSize, - "(D:%04d%02d%02d%02d%02d%02d", - year, - d.month(), - d.day(), - t.hour(), - t.minute(), - t.second()); + auto printedSize = std::snprintf(formattedDate, + formattedDateSize, + "(D:%04d%02d%02d%02d%02d%02d", + year, + d.month(), + d.day(), + t.hour(), + t.minute(), + t.second()); const int offset = date.offsetFromUtc(); const int hours = (offset / 60) / 60; const int mins = (offset / 60) % 60; if (offset < 0) { - qsnprintf(formattedDate + printedSize, - formattedDateSize - printedSize, - "-%02d'%02d')", -hours, -mins); + std::snprintf(formattedDate + printedSize, + formattedDateSize - printedSize, + "-%02d'%02d')", -hours, -mins); } else if (offset > 0) { - qsnprintf(formattedDate + printedSize, - formattedDateSize - printedSize, - "+%02d'%02d')", hours, mins); + std::snprintf(formattedDate + printedSize, + formattedDateSize - printedSize, + "+%02d'%02d')", hours, mins); } else { - qsnprintf(formattedDate + printedSize, - formattedDateSize - printedSize, - "Z)"); + std::snprintf(formattedDate + printedSize, + formattedDateSize - printedSize, + "Z)"); } write("\n/CreationDate "); @@ -2472,7 +2473,7 @@ void QPdfEnginePrivate::xprintf(const char* fmt, ...) va_list args; va_start(args, fmt); - int bufsize = qvsnprintf(buf, msize, fmt, args); + int bufsize = std::vsnprintf(buf, msize, fmt, args); va_end(args); if (Q_LIKELY(bufsize < msize)) { @@ -2481,7 +2482,7 @@ void QPdfEnginePrivate::xprintf(const char* fmt, ...) // Fallback for abnormal cases QScopedArrayPointer tmpbuf(new char[bufsize + 1]); va_start(args, fmt); - bufsize = qvsnprintf(tmpbuf.data(), bufsize + 1, fmt, args); + bufsize = std::vsnprintf(tmpbuf.data(), bufsize + 1, fmt, args); va_end(args); stream->writeRawData(tmpbuf.data(), bufsize); } diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 7fc2976d76..ba9104fe72 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -10,6 +10,8 @@ #include #include "qrhid3dhelpers_p.h" +#include + QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; @@ -4697,7 +4699,7 @@ bool QD3D11GraphicsPipeline::create() } else { QByteArray sem; sem.resize(16); - qsnprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice); + std::snprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice); matrixSliceSemantics.append(sem); desc.SemanticName = matrixSliceSemantics.last().constData(); desc.SemanticIndex = UINT(matrixSlice); diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 2a178fbb9a..87746d4d3c 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -5703,7 +5703,7 @@ bool QD3D12GraphicsPipeline::create() } else { QByteArray sem; sem.resize(16); - qsnprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice); + std::snprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice); matrixSliceSemantics.append(sem); desc.SemanticName = matrixSliceSemantics.last().constData(); desc.SemanticIndex = UINT(matrixSlice);