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 282b724808 with
the necessary fixes.

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

Change-Id: I370c295c21edd3d81a9fa670e60909b29d1c68aa
Pick-to: 6.1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2021-05-17 14:53:14 +02:00
parent 42b8bbbef0
commit 8f7873272a

View File

@ -60,8 +60,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)
@ -3289,7 +3291,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
}
/*