From 868201155fd677dbc6d14346f5ea61e82ebce27b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 23 Jan 2015 16:19:11 +0100 Subject: QtCore: Use QDebugStateSaver in (almost) all QDebug operator<< Unify the behavior of the different operator<< by always using QDebugStateSaver (appending an optional space at exit), and making sure that the space(), nospace() setting isn't 'leaked'. Change-Id: I38e4f82fa6f7419d8b5edfc4dc37495af497e8ac Reviewed-by: Alex Blasche --- src/corelib/itemmodels/qabstractitemmodel.cpp | 5 +++-- src/corelib/itemmodels/qitemselectionmodel.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/corelib/itemmodels') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 43b51bcaf5..7eed37033c 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -449,9 +449,10 @@ bool QPersistentModelIndex::isValid() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QModelIndex &idx) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QModelIndex(" << idx.row() << ',' << idx.column() << ',' << idx.internalPointer() << ',' << idx.model() << ')'; - return dbg.space(); + return dbg; } QDebug operator<<(QDebug dbg, const QPersistentModelIndex &idx) diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 920190e712..f1dd503bff 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -1849,9 +1849,10 @@ void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelectio #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QItemSelectionRange &range) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QItemSelectionRange(" << range.topLeft() << ',' << range.bottomRight() << ')'; - return dbg.space(); + return dbg; } #endif -- cgit v1.2.3