From ffde36c9a31c488eb327a86a7437a6aa3665b452 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 19 May 2021 10:03:40 +0300 Subject: [PATCH] qcborstreamreader.cpp: Use QT_TRY/QT_CATCH To avoid build error with no exceptions: qtbase/src/corelib/serialization/qcborstreamreader.cpp:1586:9: error: cannot use 'try' with exceptions disabled try { ^ qtbase/src/corelib/serialization/qcborstreamreader.cpp:1629:9: error: cannot use 'try' with exceptions disabled try { ^ 2 errors generated. Used compiler: https://github.com/mstorsjo/llvm-mingw It's not a supported configuration, but the change is simple. Change-Id: I263ce23b458f114b2330e832c5f4fd2a99cbb973 Reviewed-by: Thiago Macieira --- src/corelib/serialization/qcborstreamreader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/serialization/qcborstreamreader.cpp b/src/corelib/serialization/qcborstreamreader.cpp index 460813cece..8e42efb0cc 100644 --- a/src/corelib/serialization/qcborstreamreader.cpp +++ b/src/corelib/serialization/qcborstreamreader.cpp @@ -1583,9 +1583,9 @@ QCborStreamReaderPrivate::readStringChunk_byte(ReadStringChunk params, qsizetype handleError(CborErrorDataTooLarge); return -1; } - try { + QT_TRY { params.array->resize(newSize); - } catch (const std::bad_alloc &) { + } QT_CATCH (const std::bad_alloc &) { // the distinction between DataTooLarge and OOM is mostly for // compatibility with Qt 5; in Qt 6, we could consider everything // to be OOM. @@ -1626,9 +1626,9 @@ QCborStreamReaderPrivate::readStringChunk_unicode(ReadStringChunk params, qsizet // conversion uses the same number of words or less. QChar *begin = nullptr; if (params.isString()) { - try { + QT_TRY { params.string->resize(utf8len); - } catch (const std::bad_alloc &) { + } QT_CATCH (const std::bad_alloc &) { if (utf8len > MaxStringSize) handleError(CborErrorDataTooLarge); else