diff --git a/src/core/kernel/qcoreevent.cpp b/src/core/kernel/qcoreevent.cpp index 7c37a2dea..57fd1ccf8 100644 --- a/src/core/kernel/qcoreevent.cpp +++ b/src/core/kernel/qcoreevent.cpp @@ -22,8 +22,6 @@ #include "qcoreevent.h" #include "qcoreapplication.h" #include "qcoreapplication_p.h" -#include "qmutex.h" -#include "qstdcontainers_p.h" QT_BEGIN_NAMESPACE @@ -185,12 +183,6 @@ QT_BEGIN_NAMESPACE \value User User-defined event. \value MaxUser Last user event ID. - For convenience, you can use the registerEventType() function to - register and reserve a custom event type for your - application. Doing so will allow you to avoid accidentally - re-using a custom event type already in use elsewhere in your - application. - \omitvalue GraphicsSceneLeave \omitvalue AcceptDropsChange \omitvalue Create @@ -206,7 +198,8 @@ QT_BEGIN_NAMESPACE */ QEvent::QEvent(Type type) : t(type), posted(false), spont(false), m_accept(true), looplevel(0) -{} +{ +} /*! Destroys the event. If it was \link @@ -277,44 +270,6 @@ QEvent::~QEvent() The return value of this function is not defined for paint events. */ -typedef QStdVector QEventUserEventList; -Q_GLOBAL_STATIC(QMutex, qGlobalUserEventsMutex) -Q_GLOBAL_STATIC(QEventUserEventList, qGlobalUserEvents) - -/*! - \since 4.4 - \threadsafe - - Registers and returns a custom event type. The \a hint provided - will be used if it is available, otherwise it will return a value - between QEvent::User and QEvent::MaxUser that has not yet been - registered. The \a hint is ignored if its value is not between - QEvent::User and QEvent::MaxUser. -*/ -int QEvent::registerEventType(int hint) -{ - QMutexLocker locker(qGlobalUserEventsMutex()); - QEventUserEventList *userEventRegistration = qGlobalUserEvents(); - if (!userEventRegistration) - return -1; - - // if the type hint hasn't been registered yet, take it - if (hint >= QEvent::User && hint <= QEvent::MaxUser && !userEventRegistration->contains(hint)) { - userEventRegistration->append(hint); - return hint; - } - - // find a free event type, starting at MaxUser and decreasing - int id = QEvent::MaxUser; - while (userEventRegistration->contains(id) && id >= QEvent::User) - --id; - if (id >= QEvent::User) { - userEventRegistration->append(id); - return id; - } - return -1; -} - /*! \class QTimerEvent \brief The QTimerEvent class contains parameters that describe a diff --git a/src/core/kernel/qcoreevent.h b/src/core/kernel/qcoreevent.h index 5a6d5d666..0ad4cc128 100644 --- a/src/core/kernel/qcoreevent.h +++ b/src/core/kernel/qcoreevent.h @@ -194,8 +194,6 @@ public: inline void accept() { m_accept = true; } inline void ignore() { m_accept = false; } - static int registerEventType(int hint = -1); - protected: Type t; diff --git a/tests/auto/qevent/CMakeLists.txt b/tests/auto/qevent/CMakeLists.txt deleted file mode 100644 index dc923d079..000000000 --- a/tests/auto/qevent/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -katie_test(tst_qevent - ${CMAKE_CURRENT_SOURCE_DIR}/tst_qevent.cpp -) diff --git a/tests/auto/qevent/tst_qevent.cpp b/tests/auto/qevent/tst_qevent.cpp deleted file mode 100644 index 7b94d81a7..000000000 --- a/tests/auto/qevent/tst_qevent.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the test suite of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -#include -#include - -//TESTED_CLASS= -//TESTED_FILES= - -class tst_QEvent : public QObject -{ - Q_OBJECT -public: - tst_QEvent(); - ~tst_QEvent(); - -private slots: - void registerEventType_data(); - void registerEventType(); -}; - -tst_QEvent::tst_QEvent() -{ } - -tst_QEvent::~tst_QEvent() -{ } - -void tst_QEvent::registerEventType_data() -{ - QTest::addColumn("hint"); - QTest::addColumn("expected"); - - // default argument - QTest::newRow("default") << -1 << int(QEvent::MaxUser); - // hint not valid - QTest::newRow("User-1") << int(QEvent::User - 1) << int(QEvent::MaxUser - 1); - // hint valid, but already taken - QTest::newRow("MaxUser-1") << int(QEvent::MaxUser - 1) << int(QEvent::MaxUser - 2); - // hint valid, but not taken - QTest::newRow("User + 1000") << int(QEvent::User + 1000) << int(QEvent::User + 1000); -} - -void tst_QEvent::registerEventType() -{ - QFETCH(int, hint); - QFETCH(int, expected); - QCOMPARE(QEvent::registerEventType(hint), expected); -} - -QTEST_MAIN(tst_QEvent) - -#include "moc_tst_qevent.cpp"