Debugging and error handling
*/
-#if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
-# define QT_DEBUG
-#endif
-
#if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)
#define QT_NO_DEBUG_STREAM
#endif
}
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (receiver && eventType == 0) {
Q_ASSERT(!receiver->d_func()->postedEvents);
}
QMutexLocker locker(&data->postEventList.mutex);
if (data->postEventList.size() == 0) {
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
qDebug("QCoreApplication::removePostedEvent: Internal error: %p %d is posted",
(void*)event, event->type());
return;
static void dumpRecursive(int level, QObject *object)
{
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
if (object) {
QByteArray buf;
buf.fill(' ', level / 2 * 8);
#else
Q_UNUSED(level)
Q_UNUSED(object)
-#endif
+#endif // QT_NO_DEBUG
}
/*!
void QObject::dumpObjectInfo()
{
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
qDebug("OBJECT %s::%s", metaObject()->className(),
objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data());
} else {
qDebug(" <None>");
}
-#endif
+#endif // QT_NO_DEBUG
}
#ifndef QT_NO_DEBUG_STREAM
const QVector<int> &firstOccurrence() const { return occ1; }
#endif
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
void dump() const;
#endif
void heuristicallyChooseHeuristic();
#endif
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
void dump() const;
#endif
void setupHeuristics();
#endif
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
void dump() const;
#endif
}
#endif
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
void QRegExpEngine::dump() const
{
int i, j;
return n;
}
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
void QRegExpCharClass::dump() const
{
int i;
}
#endif
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
void QRegExpEngine::Box::dump() const
{
int i;
return true;
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
qFatal("QDBusArgument: write from a read-only object");
#else
qWarning("QDBusArgument: write from a read-only object");
if (d->direction == Demarshalling)
return true;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
qFatal("QDBusArgument: read from a write-only object");
#else
qWarning("QDBusArgument: read from a write-only object");
{
// Creates a bidirectional edge
if (edgeData(first, second)) {
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
qWarning("%s-%s already has an edge", qPrintable(first->toString()), qPrintable(second->toString()));
#endif
}
return conns;
}
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
QString serializeToDot() { // traversal
QString strVertices;
QString edges;
}
return QString::fromAscii("%1\n%2\n").arg(strVertices).arg(edges);
}
-#endif
+#endif // QT_NO_DEBUG
protected:
void createDirectedEdge(Vertex *from, Vertex *to, EdgeData *data)
#include <QtCore/qstack.h>
#include <QtCore/qqueue.h>
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
#include <QtCore/qfile.h>
#endif
sizeAtMaximum = prefSize;
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void AnchorData::dump(int indent) {
if (type == Parallel) {
qDebug("%*s type: parallel:", indent, "");
return c;
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
QString GraphPath::toString() const
{
QString string(QLatin1String("Path: "));
AnchorData *ad = edges[i];
AnchorVertex *otherV = replaceVertex_helper(ad, oldV, newV);
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
ad->name = QString::fromAscii("%1 --to--> %2").arg(ad->from->toString()).arg(ad->to->toString());
#endif
// so we still know that the anchor direction is from 1 to 2.
data->from = v1;
data->to = v2;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
data->name = QString::fromAscii("%1 --to--> %2").arg(v1->toString()).arg(v2->toString());
#endif
// ### bit to track internal anchors, since inside AnchorData methods
void QGraphicsAnchorLayoutPrivate::calculateGraphs(
QGraphicsAnchorLayoutPrivate::Orientation orientation)
{
-#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT)
+#if !defined(QT_NO_DEBUG) || defined(Q_AUTOTEST_EXPORT)
lastCalculationUsedSimplex[orientation] = false;
#endif
sizeHints[orientation][Qt::MaximumSize] = ad->sizeAtMaximum;
}
-#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT)
+#if !defined(QT_NO_DEBUG) || defined(Q_AUTOTEST_EXPORT)
lastCalculationUsedSimplex[orientation] = needsSimplex;
#endif
return graphHasConflicts[0] || graphHasConflicts[1] || floatConflict;
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void QGraphicsAnchorLayoutPrivate::dumpGraph(const QString &name)
{
QFile file(QString::fromAscii("anchorlayout.%1.dot").arg(name));
AnchorVertex()
: m_item(0), m_edge(Qt::AnchorPoint(0)), m_type(Normal) {}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
inline QString toString() const;
#endif
virtual void updateChildrenSizes() {}
void refreshSizeHints(const QLayoutStyleInfo *styleInfo = 0);
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void dump(int indent = 2);
inline QString toString() const;
QString name;
uint orientation;
};
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
inline QString AnchorData::toString() const
{
return QString::fromAscii("Anchor(%1)").arg(name);
{
type = AnchorData::Sequential;
orientation = m_edges.at(0)->orientation;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
name = QString::fromAscii("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString());
#endif
}
// direction as the first anchor.
from = first->from;
to = first->to;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
name = QString::fromAscii("%1 | %2").arg(first->toString(), second->toString());
#endif
}
QList<AnchorData *> m_secondAnchors;
};
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
inline QString AnchorVertex::toString() const
{
if (m_type == Pair) {
GraphPath() {}
QSimplexConstraint *constraint(const GraphPath &path) const;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
QString toString() const;
#endif
QSet<AnchorData *> positives;
const QList<AnchorData *> &variables);
bool hasConflicts() const;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void dumpGraph(const QString &name = QString());
#endif
bool graphHasConflicts[2];
QSet<QGraphicsLayoutItem *> m_floatItems[2];
-#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT)
+#if !defined(QT_NO_DEBUG) || defined(Q_AUTOTEST_EXPORT)
bool lastCalculationUsedSimplex[2];
#endif
QLayoutStyleInfo styleInfo() const;
QGridLayoutEngine engine;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void dump(int indent) const;
#endif
};
QGraphicsLayout::invalidate();
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void QGraphicsGridLayoutPrivate::dump(int indent) const
{
if (qt_graphicsLayoutDebug()) {
qSwap(left, right);
effectiveRect.adjust(+left, +top, -right, -bottom);
d->engine.setGeometries(d->styleInfo(), effectiveRect);
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (qt_graphicsLayoutDebug()) {
static int counter = 0;
qDebug("==== BEGIN DUMP OF QGraphicsGridLayout (%d)====", counter++);
l->d_func()->reparentChildItems(newParent);
} else if (QGraphicsItem *itemChild = layoutChild->graphicsItem()){
QGraphicsItem *childParent = itemChild->parentItem();
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (childParent && childParent != newParent && itemChild->isWidget() && qt_graphicsLayoutDebug()) {
QGraphicsWidget *w = static_cast<QGraphicsWidget*>(layoutChild);
qWarning("QGraphicsLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent",
if (oldParent == newParent || !newParent)
return;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (oldParent && item->isWidget()) {
QGraphicsWidget *w = static_cast<QGraphicsWidget*>(item);
qWarning("QGraphicsLayout::addChildLayoutItem: %s \"%s\" in wrong parent; moved to correct parent",
class QGraphicsLayoutItem;
class QGraphicsWidget;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
inline bool qt_graphicsLayoutDebug()
{
static int checked_env = -1;
#include "qgraphicslinearlayout.h"
#include "qgraphicswidget.h"
#include "qgridlayoutengine_p.h"
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
#include <QtCore/qdebug.h>
#endif
#include "qguicommon_p.h"
if (visualDir == Qt::RightToLeft)
qSwap(left, right);
effectiveRect.adjust(+left, +top, -right, -bottom);
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (qt_graphicsLayoutDebug()) {
static int counter = 0;
qDebug() << counter++ << "QGraphicsLinearLayout::setGeometry - " << rect;
}
#endif
d->engine.setGeometries(d->styleInfo(), effectiveRect);
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (qt_graphicsLayoutDebug()) {
qDebug() << "post dump";
dump(1);
*/
void QGraphicsLinearLayout::dump(int indent) const
{
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (qt_graphicsLayoutDebug()) {
Q_D(const QGraphicsLinearLayout);
qDebug("%*s%s layout", indent, "",
Q_ASSERT((q_minimumDescent < 0.0) == (q_minimumAscent < 0.0));
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void QGridLayoutBox::dump(int indent) const
{
qDebug("%*sBox (%g <= %g <= %g [%g/%g])", indent, "", q_minimumSize, q_preferredSize,
}
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void QGridLayoutRowData::dump(int indent) const
{
qDebug("%*sData", indent, "");
return size;
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void QGridLayoutItem::dump(int indent) const
{
qDebug("%*s%p (%d, %d) %d x %d", indent, "", q_layoutItem, firstRow(), firstColumn(),
insertOrRemoveItems(boxes, row, delta);
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void QGridLayoutRowInfo::dump(int indent) const
{
qDebug("%*sInfo (count: %d)", indent, "", count);
return m_visualDirection;
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void QGridLayoutEngine::dump(int indent) const
{
qDebug("%*sEngine", indent, "");
void combine(const QGridLayoutBox &other);
void normalize();
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void dump(int indent = 0) const;
#endif
// This code could use the union-struct-array trick, but a compiler
QGridLayoutBox totalBox(int start, int end) const;
void stealBox(int start, int end, int which, qreal *positions, qreal *sizes);
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void dump(int indent = 0) const;
#endif
void insertOrRemoveRows(int row, int delta, Qt::Orientation orientation = Qt::Vertical);
QSizeF effectiveMaxSize(const QSizeF &constraint) const;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void dump(int indent = 0) const;
#endif
void insertOrRemoveRows(int row, int delta);
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void dump(int indent = 0) const;
#endif
void transpose();
void setVisualDirection(Qt::LayoutDirection direction);
Qt::LayoutDirection visualDirection() const;
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
void dump(int indent = 0) const;
#endif
solveMaxHelper();
collectResults();
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
for (int i = 0; i < constraints.size(); ++i) {
Q_ASSERT(constraints[i]->isSatisfied());
}
}
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
QString toString() {
QString result;
result += QString::fromAscii("-- QSimplexConstraint %1 --").arg(quintptr(this), 0, 16);
return result;
}
-#endif
+#endif // QT_NO_DEBUG
};
class QSimplex
static const char *mwGeometry = 0; // main widget geometry
static const char *mwTitle = 0; // main widget title
static bool appSync = false; // X11 synchronization
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
static bool appNoGrab = false; // X11 grabbing enabled
static bool appDoGrab = false; // X11 grabbing override (gdb)
#endif
}
#endif
-#if defined(QT_DEBUG) && defined(Q_OS_LINUX)
+#if !defined(QT_NO_DEBUG) && defined(Q_OS_LINUX)
// Find out if our parent process is gdb by looking at the 'exe' symlink under /proc,.
// or, for older Linuxes, read out 'cmdline'.
bool runningUnderDebugger()
}
else if (arg == "-sync")
appSync = !appSync;
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
else if (arg == "-nograb")
appNoGrab = !appNoGrab;
else if (arg == "-dograb")
priv->argc = j;
-#if defined(QT_DEBUG) && defined(Q_OS_LINUX)
+#if !defined(QT_NO_DEBUG) && defined(Q_OS_LINUX)
if (!appNoGrab && !appDoGrab && runningUnderDebugger()) {
appNoGrab = true;
qDebug("Qt: gdb: -nograb added to command-line options.\n"
bool qt_nograb() // application no-grab option
{
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
return appNoGrab;
#else
return false;
return ok;
}
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
static bool layoutDebug()
{
static int checked_env = -1;
QLayoutItem *item = q->itemAt(i);
if (QWidget *w = item->widget()) {
QWidget *pw = w->parentWidget();
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (pw && pw != mw && layoutDebug()) {
qWarning("QLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent",
w->metaObject()->className(), w->objectName().toLocal8Bit().data());
if (pw && w->testAttribute(Qt::WA_LaidOut)) {
QLayout *l = pw->layout();
if (l && removeWidgetRecursively(l, w)) {
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (layoutDebug())
qWarning("QLayout::addChildWidget: %s \"%s\" is already in a layout; moved to new layout",
w->metaObject()->className(), w->objectName().toLocal8Bit().data());
}
}
if (pw && mw && pw != mw) {
-#ifdef QT_DEBUG
+#ifndef QT_NO_DEBUG
if (layoutDebug())
qWarning("QLayout::addChildWidget: %s \"%s\" in wrong parent; moved to correct parent",
w->metaObject()->className(), w->objectName().toLocal8Bit().data());
tl[0] = mapped.data();
tl[1] = 0;
errCode = XmbTextListToTextProperty(qt_x11Data->display, tl, 1, XStdICCTextStyle, &tp);
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
if (errCode < 0)
qDebug("qstring_to_xtp result code %d", errCode);
#endif
if (found)
reformat();
-#if defined(QT_DEBUG)
+#ifndef QT_NO_DEBUG
else
qDebug("QStatusBar::removeWidget(): Widget not found.");
#endif
QNetworkAccessCache::CacheableObject::~CacheableObject()
{
-#if 0 //def QT_DEBUG
+#if 0 // ifndef QT_NO_DEBUG
if (!key.isEmpty() && Ptr()->hasEntry(key))
qWarning() << "QNetworkAccessCache: object" << (void*)this << "key" << key
<< "destroyed without being removed from cache first!";