summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-01-10 15:42:19 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-14 08:45:00 +0100
commit85e576535c9c39756ecaddefa245f71fb35b8589 (patch)
treeb5f9333825c3d1eb901cbddb67101a29d486202d /src
parentb648f11227054b1e029c202c2a996f359335a86b (diff)
Let Q_DECLARE_LOGGING_CATEGORY and Q_LOGGING_CATEGORY return a const reference
In general QLoggingCategory should be treated as a const object that's configured by the backend. The only legitimate place where user code should call setEnabled is in a CategoryFilter ... [ChangeLog][QtCore][Logging] Make Q_LOGGING_CATEGORY and Q_DECLARE_LOGGING_CATEGORY return a const object. Change-Id: I6140442ab48286e05cd3b55064a502bbe6dfb16a Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/doc/snippets/code/qlogging/qlogging.cpp2
-rw-r--r--src/corelib/global/qlogging.h2
-rw-r--r--src/corelib/io/qloggingcategory.h6
3 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/doc/snippets/code/qlogging/qlogging.cpp b/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
index d3b9e1fd14..ff5ce23eff 100644
--- a/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
+++ b/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
@@ -54,5 +54,5 @@
//! [1]
//! [2]
- QLoggingCategory &category();
+ const QLoggingCategory &category();
//! [2]
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h
index 6d651ee8a0..6ebffa3ba1 100644
--- a/src/corelib/global/qlogging.h
+++ b/src/corelib/global/qlogging.h
@@ -100,7 +100,7 @@ public:
void warning(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
void critical(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
- typedef QLoggingCategory &(*CategoryFunction)();
+ typedef const QLoggingCategory &(*CategoryFunction)();
void debug(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
void debug(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h
index 37735908a1..e701f93472 100644
--- a/src/corelib/io/qloggingcategory.h
+++ b/src/corelib/io/qloggingcategory.h
@@ -84,13 +84,13 @@ private:
};
#define Q_DECLARE_LOGGING_CATEGORY(name) \
- extern QLoggingCategory &name();
+ extern const QLoggingCategory &name();
// relies on QLoggingCategory(QString) being thread safe!
#define Q_LOGGING_CATEGORY(name, string) \
- QLoggingCategory &name() \
+ const QLoggingCategory &name() \
{ \
- static QLoggingCategory category(string); \
+ static const QLoggingCategory category(string); \
return category; \
}