Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qassert.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qassert.h"
5
6#include <QtCore/qlogging.h>
7
8#include <cstdio>
9#include <exception>
10#ifndef QT_NO_EXCEPTIONS
11#include <new>
12#endif
13
15
62/*
63 The Q_ASSERT macro calls this function when the test fails.
64*/
65void qt_assert(const char *assertion, const char *file, int line) noexcept
66{
67 QMessageLogger(file, line, nullptr)
68 .fatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line);
69}
70
71/*
72 The Q_ASSERT_X macro calls this function when the test fails.
73*/
74void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept
75{
76 QMessageLogger(file, line, nullptr)
77 .fatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line);
78}
79
115void qt_check_pointer(const char *n, int l) noexcept
116{
117 // make separate printing calls so that the first one may flush;
118 // the second one could want to allocate memory (fputs prints a
119 // newline and stderr auto-flushes).
120 fputs("Out of memory", stderr);
121 fprintf(stderr, " in %s, line %d\n", n, l);
122
123 std::terminate();
124}
125
126/*
127 \internal
128 Allows you to throw an exception without including <new>
129 Called internally from Q_CHECK_PTR on certain OS combinations
130*/
132{
133#ifndef QT_NO_EXCEPTIONS
134 throw std::bad_alloc();
135#else
136 std::terminate();
137#endif
138}
139
\inmodule QtCore
Definition qlogging.h:68
void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION void fatal(const char *msg,...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(2
Logs a fatal message specified with format msg.
Definition qlogging.cpp:930
Combined button and popup list for selecting options.
void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept
Definition qassert.cpp:74
void qt_check_pointer(const char *n, int l) noexcept
Definition qassert.cpp:115
void qBadAlloc()
Definition qassert.cpp:131
GLfloat n
QFile file
[0]