From 9bb27ca6cc76a848d9c4a1d7757abf5ffc3943e6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 31 Jul 2018 12:36:47 -0700 Subject: Make local symbols of some leaked names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unnamed namespaces and static are great tools. Use them. Change-Id: Ie01831ddac5446fdbdeefffd15468b3acb3ced79 Reviewed-by: Kai Koehne Reviewed-by: André Hartmann Reviewed-by: Edward Welbourne --- src/corelib/global/qlogging.cpp | 2 +- src/corelib/statemachine/qhistorystate.cpp | 21 ++++++++++++++++++++- src/corelib/statemachine/qhistorystate_p.h | 17 ----------------- src/gui/opengl/qopenglprogrambinarycache.cpp | 2 ++ src/gui/util/qtexturefiledata.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfshooks.cpp | 2 ++ src/plugins/platforms/xcb/qxcbclipboard.cpp | 2 ++ src/widgets/widgets/qtabbar.cpp | 20 ++++++++++++++++++-- src/widgets/widgets/qtabbar_p.h | 15 --------------- 9 files changed, 46 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 308ebe7a68..a931b43220 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -243,7 +243,7 @@ static bool systemHasStderr() \internal \sa systemHasStderr() */ -bool stderrHasConsoleAttached() +static bool stderrHasConsoleAttached() { static const bool stderrHasConsoleAttached = []() -> bool { if (!systemHasStderr()) diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp index d4fb214a31..ccf04d4799 100644 --- a/src/corelib/statemachine/qhistorystate.cpp +++ b/src/corelib/statemachine/qhistorystate.cpp @@ -126,6 +126,25 @@ QT_BEGIN_NAMESPACE descendant state the parent was in the last time it was exited. */ +namespace { +class DefaultStateTransition: public QAbstractTransition +{ + Q_OBJECT + +public: + DefaultStateTransition(QHistoryState *source, QAbstractState *target); + +protected: + // It doesn't matter whether this transition matches any event or not. It is always associated + // with a QHistoryState, and as soon as the state-machine detects that it enters a history + // state, it will handle this transition as a special case. The history state itself is never + // entered either: either the stored configuration will be used, or the target(s) of this + // transition are used. + bool eventTest(QEvent *event) override { Q_UNUSED(event); return false; } + void onTransition(QEvent *event) override { Q_UNUSED(event); } +}; +} + QHistoryStatePrivate::QHistoryStatePrivate() : QAbstractStatePrivate(HistoryState) , defaultTransition(0) @@ -312,4 +331,4 @@ bool QHistoryState::event(QEvent *e) QT_END_NAMESPACE #include "moc_qhistorystate.cpp" -#include "moc_qhistorystate_p.cpp" +#include "qhistorystate.moc" diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h index d22e5c4aaf..18d571feb7 100644 --- a/src/corelib/statemachine/qhistorystate_p.h +++ b/src/corelib/statemachine/qhistorystate_p.h @@ -75,23 +75,6 @@ public: QList configuration; }; -class DefaultStateTransition: public QAbstractTransition -{ - Q_OBJECT - -public: - DefaultStateTransition(QHistoryState *source, QAbstractState *target); - -protected: - // It doesn't matter whether this transition matches any event or not. It is always associated - // with a QHistoryState, and as soon as the state-machine detects that it enters a history - // state, it will handle this transition as a special case. The history state itself is never - // entered either: either the stored configuration will be used, or the target(s) of this - // transition are used. - bool eventTest(QEvent *event) override { Q_UNUSED(event); return false; } - void onTransition(QEvent *event) override { Q_UNUSED(event); } -}; - QT_END_NAMESPACE #endif // QHISTORYSTATE_P_H diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp index d16173df83..f2d093ebed 100644 --- a/src/gui/opengl/qopenglprogrambinarycache.cpp +++ b/src/gui/opengl/qopenglprogrambinarycache.cpp @@ -62,6 +62,7 @@ const quint32 BINSHADER_MAGIC = 0x5174; const quint32 BINSHADER_VERSION = 0x2; const quint32 BINSHADER_QTVERSION = QT_VERSION; +namespace { struct GLEnvInfo { GLEnvInfo(); @@ -70,6 +71,7 @@ struct GLEnvInfo QByteArray glrenderer; QByteArray glversion; }; +} GLEnvInfo::GLEnvInfo() { diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index f9129e86c2..ae230800c0 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -244,7 +244,7 @@ void QTextureFileData::setLogName(const QByteArray &name) d->logName = name; } -QByteArray glFormatName(quint32 fmt) +static QByteArray glFormatName(quint32 fmt) { const char *id = 0; #if QT_CONFIG(opengl) diff --git a/src/plugins/platforms/eglfs/api/qeglfshooks.cpp b/src/plugins/platforms/eglfs/api/qeglfshooks.cpp index d8332a94cb..ff5c5deee4 100644 --- a/src/plugins/platforms/eglfs/api/qeglfshooks.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfshooks.cpp @@ -54,6 +54,7 @@ QEglFSDeviceIntegration *qt_egl_device_integration() #else +namespace { class DeviceIntegration { public: @@ -63,6 +64,7 @@ public: private: QEglFSDeviceIntegration *m_integration; }; +} Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration) diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index 263ef5fb1f..24eb13326c 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -157,6 +157,7 @@ private: QByteArray format_atoms; }; +namespace { class INCRTransaction; typedef QMap TransactionMap; static TransactionMap *transactions = 0; @@ -263,6 +264,7 @@ private: uint offset; int abort_timer; }; +} // unnamed namespace const int QXcbClipboard::clipboard_timeout = 5000; diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index c92e38f74a..5959dd0ae4 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -74,6 +74,23 @@ QT_BEGIN_NAMESPACE +namespace { +class CloseButton : public QAbstractButton +{ + Q_OBJECT + +public: + explicit CloseButton(QWidget *parent = 0); + + QSize sizeHint() const override; + QSize minimumSizeHint() const override + { return sizeHint(); } + void enterEvent(QEvent *event) override; + void leaveEvent(QEvent *event) override; + void paintEvent(QPaintEvent *event) override; +}; +} + QMovableTabWidget::QMovableTabWidget(QWidget *parent) : QWidget(parent) { @@ -2695,5 +2712,4 @@ void QTabBarPrivate::Tab::TabBarAnimation::updateState(QAbstractAnimation::State QT_END_NAMESPACE #include "moc_qtabbar.cpp" - -#include "moc_qtabbar_p.cpp" +#include "qtabbar.moc" diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index f303ed54d1..3948b42bc1 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -271,21 +271,6 @@ public: }; -class CloseButton : public QAbstractButton -{ - Q_OBJECT - -public: - explicit CloseButton(QWidget *parent = 0); - - QSize sizeHint() const override; - QSize minimumSizeHint() const override - { return sizeHint(); } - void enterEvent(QEvent *event) override; - void leaveEvent(QEvent *event) override; - void paintEvent(QPaintEvent *event) override; -}; - QT_END_NAMESPACE #endif -- cgit v1.2.3