qglobal.cpp: build under QT_NO_EXCEPTIONS

The boostrap library is built with exceptions disabled, and its
sources include qglobal.cpp. Therefore, the file must work when built
w/o exceptions.

Amend/partially revert 282b724808ea4524ed09b9f0183055fdffc3c38a with
the necessary fixes.

Driveby, cleanup an unnecessary QT_THROW (just throw, if we do have
exceptions).

Change-Id: I370c295c21edd3d81a9fa670e60909b29d1c68aa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 8f7873272ac9e5c5f1a83a5204afb512843cf8d8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2021-05-17 14:53:14 +02:00 committed by Qt Cherry-pick Bot
parent ad12c3c40b
commit 37ff9b02e5

View File

@ -59,8 +59,10 @@
#include <stdarg.h>
#include <string.h>
#include <string>
#include <exception>
#include <exception> // For std::terminate
#ifndef QT_NO_EXCEPTIONS
#include <new> // For std::bad_alloc
#endif
#include <errno.h>
#if defined(Q_CC_MSVC)
@ -3096,7 +3098,11 @@ void qt_check_pointer(const char *n, int l) noexcept
*/
void qBadAlloc()
{
QT_THROW(std::bad_alloc());
#ifndef QT_NO_EXCEPTIONS
throw std::bad_alloc();
#else
std::terminate();
#endif
}
/*