summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm54
-rw-r--r--src/corelib/kernel/qcore_mac_p.h6
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp76
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp10
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h2
-rw-r--r--src/corelib/kernel/qobject.cpp85
-rw-r--r--src/corelib/kernel/qobject.h8
-rw-r--r--src/corelib/kernel/qsystemsemaphore_systemv.cpp26
-rw-r--r--src/corelib/kernel/qvariant.cpp2
-rw-r--r--src/corelib/kernel/qwineventnotifier.h2
10 files changed, 111 insertions, 160 deletions
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index d7e8d4847a..231afb991c 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -47,14 +47,8 @@
#include <qdebug.h>
-#if defined(Q_OS_IOS)
-#import <UIKit/UIKit.h>
-#endif
-
QT_BEGIN_NAMESPACE
-typedef qint16 (*GestaltFunction)(quint32 selector, qint32 *response);
-
// -------------------------------------------------------------------------
QDebug operator<<(QDebug dbg, const NSObject *nsObject)
@@ -87,54 +81,6 @@ QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TY
// -------------------------------------------------------------------------
-QAppleOperatingSystemVersion qt_apple_os_version()
-{
- QAppleOperatingSystemVersion v = {0, 0, 0};
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) || defined(Q_OS_TVOS) || defined(Q_OS_WATCHOS)
- if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) {
- NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
- v.major = osv.majorVersion;
- v.minor = osv.minorVersion;
- v.patch = osv.patchVersion;
- return v;
- }
-#endif
- // Use temporary variables so we can return 0.0.0 (unknown version)
- // in case of an error partway through determining the OS version
- qint32 major = 0, minor = 0, patch = 0;
-#if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_10, __IPHONE_8_0)
-#if defined(Q_OS_IOS)
- @autoreleasepool {
- NSArray *parts = [UIDevice.currentDevice.systemVersion componentsSeparatedByString:@"."];
- major = parts.count > 0 ? [[parts objectAtIndex:0] intValue] : 0;
- minor = parts.count > 1 ? [[parts objectAtIndex:1] intValue] : 0;
- patch = parts.count > 2 ? [[parts objectAtIndex:2] intValue] : 0;
- }
-#elif defined(Q_OS_OSX)
- static GestaltFunction pGestalt = 0;
- if (!pGestalt) {
- CFBundleRef b = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreServices"));
- pGestalt = reinterpret_cast<GestaltFunction>(CFBundleGetFunctionPointerForName(b,
- CFSTR("Gestalt")));
- }
- if (!pGestalt)
- return v;
- if (pGestalt('sys1', &major) != 0)
- return v;
- if (pGestalt('sys2', &minor) != 0)
- return v;
- if (pGestalt('sys3', &patch) != 0)
- return v;
-#endif
-#endif
- v.major = major;
- v.minor = minor;
- v.patch = patch;
- return v;
-}
-
-// -------------------------------------------------------------------------
-
QMacAutoReleasePool::QMacAutoReleasePool()
: pool([[NSAutoreleasePool alloc] init])
{
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index cb709f9d4b..d0edef33a2 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -131,12 +131,6 @@ private:
QString string;
};
-typedef struct {
- int major, minor, patch;
-} QAppleOperatingSystemVersion;
-
-QAppleOperatingSystemVersion qt_apple_os_version();
-
#ifdef Q_OS_OSX
Q_CORE_EXPORT QChar qt_mac_qtKey2CocoaKey(Qt::Key key);
Q_CORE_EXPORT Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode);
diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp
index d670637d53..99d223ca88 100644
--- a/src/corelib/kernel/qdeadlinetimer.cpp
+++ b/src/corelib/kernel/qdeadlinetimer.cpp
@@ -173,9 +173,9 @@ Q_DECL_CONST_FUNCTION static inline QPair<qint64, qint64> toSecsAndNSecs(qint64
*/
/*!
- \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant foreverConstant, Qt::TimerType timerType)
+ \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant forever, Qt::TimerType timerType)
- QDeadlineTimer objects created with parameter \a foreverConstant never expire.
+ QDeadlineTimer objects created with parameter \a forever never expire.
For such objects, remainingTime() will return -1, deadline() will return the
maximum value, and isForever() will return true.
@@ -341,54 +341,6 @@ void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::Time
*/
/*!
- \fn std::chrono::nanoseconds remainingTimeAsDuration() const
-
- Returns a \c{std::chrono::duration} object of type \c{Duration} containing
- the remaining time in this QDeadlineTimer, if it still has time left. If
- the deadline has passed, this returns \c{Duration::zero()}, whereas if the
- object is set to never expire, it returns \c{Duration::max()} (instead of
- -1).
-
- It is not possible to obtain the overdue time for expired timers with this
- function. To do that, see deadline().
-
- \note The overload of this function without template parameter always
- returns milliseconds.
-
- \sa setRemainingTime(), deadline<Clock, Duration>()
-*/
-
-/*!
- \overload
- \fn std::chrono::time_point<Clock, Duration> QDeadlineTimer::deadline() const
-
- Returns the absolute time point for the deadline stored in QDeadlineTimer
- object as a \c{std::chrono::time_point} object. The template parameter
- \c{Clock} is mandatory and indicates which of the C++ timekeeping clocks to
- use as a reference. The value will be in the past if this QDeadlineTimer
- has expired.
-
- If this QDeadlineTimer never expires, this function returns
- \c{std::chrono::time_point<Clock, Duration>::max()}.
-
- This function can be used to calculate the amount of time a timer is
- overdue, by subtracting the current time point of the reference clock, as
- in the following example:
-
- \code
- auto realTimeLeft = std::chrono::nanoseconds::max();
- auto tp = deadline.deadline<std::chrono::steady_clock>();
- if (tp != std::chrono::steady_clock::max())
- realTimeLeft = tp - std::chrono::steady_clock::now();
- \endcode
-
- \note Timers that were created as expired have an indetermine time point in
- the past as their deadline, so the above calculation may not work.
-
- \sa remainingTime(), deadlineNSecs(), setDeadline()
-*/
-
-/*!
\fn bool QDeadlineTimer::isForever() const
Returns true if this QDeadlineTimer object never expires, false otherwise.
@@ -789,6 +741,30 @@ QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_
To subtract times of precision greater than 1 millisecond, use addNSecs().
*/
+/*!
+ \fn void QDeadlineTimer::swap(QDeadlineTimer &other)
+
+ Swaps this deadline timer with the \a other deadline timer.
+ */
+
+/*!
+ \fn QDeadlineTimer & QDeadlineTimer::operator=(std::chrono::time_point<Clock, Duration> deadline_)
+
+ Assigns \a deadline_ to this deadline timer.
+ */
+
+/*!
+ \fn QDeadlineTimer & QDeadlineTimer::operator=(std::chrono::duration<Rep, Period> remaining)
+
+ Sets this deadline timer to the \a remaining time.
+ */
+
+/*!
+ \fn std::chrono::nanoseconds QDeadlineTimer::remainingTimeAsDuration() const
+
+ Returns the time remaining before the deadline.
+ */
+
// the rest of the functions are in qelapsedtimer_xxx.cpp
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 1a0efae2dc..75ac104155 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -42,6 +42,7 @@
#include "qcoreapplication.h"
#include <private/qsystemlibrary_p.h>
+#include "qoperatingsystemversion.h"
#include "qpair.h"
#include "qset.h"
#include "qsocketnotifier.h"
@@ -236,7 +237,7 @@ static inline UINT inputTimerMask()
// QTBUG 28513, QTBUG-29097, QTBUG-29435: QS_TOUCH, QS_POINTER became part of
// QS_INPUT in Windows Kit 8. They should not be used when running on pre-Windows 8.
#if WINVER > 0x0601
- if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8)
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8)
result &= ~(QS_TOUCH | QS_POINTER);
#endif // WINVER > 0x0601
return result;
@@ -1058,4 +1059,11 @@ void QEventDispatcherWin32::sendPostedEvents()
QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
}
+HWND QEventDispatcherWin32::internalHwnd()
+{
+ Q_D(QEventDispatcherWin32);
+ createInternalHwnd();
+ return d->internalHwnd;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index 773315c04f..227fcf89ff 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -106,6 +106,8 @@ public:
bool event(QEvent *e);
+ HWND internalHwnd();
+
protected:
QEventDispatcherWin32(QEventDispatcherWin32Private &dd, QObject *parent = 0);
virtual void sendPostedEvents();
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 63b02d2c0c..fd1c767b4c 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -147,12 +147,13 @@ static inline QMutex *signalSlotLock(const QObject *o)
uint(quintptr(o)) % sizeof(_q_ObjectMutexPool)/sizeof(QBasicMutex)]);
}
-// ### Qt >= 5.6, remove qt_add/removeObject
+#if QT_VERSION < 0x60000
extern "C" Q_CORE_EXPORT void qt_addObject(QObject *)
{}
extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
{}
+#endif
struct QConnectionSenderSwitcher {
QObject *receiver;
@@ -754,30 +755,6 @@ void QMetaCallEvent::placeMetaCall(QObject *object)
\sa {Object Trees & Ownership}
*/
-/*!
- \relates QObject
-
- Returns a pointer to the object named \a name that inherits \a
- type and with a given \a parent.
-
- Returns 0 if there is no such child.
-
- \snippet code/src_corelib_kernel_qobject.cpp 0
-*/
-
-void *qt_find_obj_child(QObject *parent, const char *type, const QString &name)
-{
- QObjectList list = parent->children();
- if (list.size() == 0) return 0;
- for (int i = 0; i < list.size(); ++i) {
- QObject *obj = list.at(i);
- if (name == obj->objectName() && obj->inherits(type))
- return obj;
- }
- return 0;
-}
-
-
/*****************************************************************************
QObject member functions
*****************************************************************************/
@@ -835,7 +812,9 @@ QObject::QObject(QObject *parent)
QT_RETHROW;
}
}
+#if QT_VERSION < 0x60000
qt_addObject(this);
+#endif
if (Q_UNLIKELY(qtHookData[QHooks::AddQObject]))
reinterpret_cast<QHooks::AddQObjectCallback>(qtHookData[QHooks::AddQObject])(this);
}
@@ -868,7 +847,9 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent)
QT_RETHROW;
}
}
+#if QT_VERSION < 0x60000
qt_addObject(this);
+#endif
if (Q_UNLIKELY(qtHookData[QHooks::AddQObject]))
reinterpret_cast<QHooks::AddQObjectCallback>(qtHookData[QHooks::AddQObject])(this);
}
@@ -1040,7 +1021,9 @@ QObject::~QObject()
if (!d->children.isEmpty())
d->deleteChildren();
+#if QT_VERSION < 0x60000
qt_removeObject(this);
+#endif
if (Q_UNLIKELY(qtHookData[QHooks::RemoveQObject]))
reinterpret_cast<QHooks::RemoveQObjectCallback>(qtHookData[QHooks::RemoveQObject])(this);
@@ -3941,9 +3924,8 @@ QList<QByteArray> QObject::dynamicPropertyNames() const
QObject debugging output routines.
*****************************************************************************/
-static void dumpRecursive(int level, QObject *object)
+static void dumpRecursive(int level, const QObject *object)
{
-#if defined(QT_DEBUG)
if (object) {
QByteArray buf;
buf.fill(' ', level / 2 * 8);
@@ -3972,45 +3954,65 @@ static void dumpRecursive(int level, QObject *object)
dumpRecursive(level+1, children.at(i));
}
}
-#else
- Q_UNUSED(level)
- Q_UNUSED(object)
-#endif
}
/*!
- Dumps a tree of children to the debug output.
+ \overload
+ \obsolete
- This function is useful for debugging, but does nothing if the
- library has been compiled in release mode (i.e. without debugging
- information).
+ Dumps a tree of children to the debug output.
\sa dumpObjectInfo()
*/
void QObject::dumpObjectTree()
{
+ const_cast<const QObject *>(this)->dumpObjectTree();
+}
+
+/*!
+ Dumps a tree of children to the debug output.
+
+ \note before Qt 5.9, this function was not const.
+
+ \sa dumpObjectInfo()
+*/
+
+void QObject::dumpObjectTree() const
+{
dumpRecursive(0, this);
}
/*!
+ \overload
+ \obsolete
+
Dumps information about signal connections, etc. for this object
to the debug output.
- This function is useful for debugging, but does nothing if the
- library has been compiled in release mode (i.e. without debugging
- information).
-
\sa dumpObjectTree()
*/
void QObject::dumpObjectInfo()
{
-#if defined(QT_DEBUG)
+ const_cast<const QObject *>(this)->dumpObjectInfo();
+}
+
+/*!
+ Dumps information about signal connections, etc. for this object
+ to the debug output.
+
+ \note before Qt 5.9, this function was not const.
+
+ \sa dumpObjectTree()
+*/
+
+void QObject::dumpObjectInfo() const
+{
qDebug("OBJECT %s::%s", metaObject()->className(),
objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data());
- Q_D(QObject);
+ Q_D(const QObject);
QMutexLocker locker(signalSlotLock(this));
// first, look for connections where this object is the sender
@@ -4066,7 +4068,6 @@ void QObject::dumpObjectInfo()
} else {
qDebug(" <None>");
}
-#endif
}
#ifndef QT_NO_USERDATA
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 69b70ad6ec..25acdefeaf 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -375,8 +375,12 @@ public:
#endif //Q_QDOC
- void dumpObjectTree();
- void dumpObjectInfo();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ void dumpObjectTree(); // ### Qt 6: remove
+ void dumpObjectInfo(); // ### Qt 6: remove
+#endif
+ void dumpObjectTree() const;
+ void dumpObjectInfo() const;
#ifndef QT_NO_PROPERTIES
bool setProperty(const char *name, const QVariant &value);
diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
index 1967899a58..83da09da44 100644
--- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
@@ -72,7 +72,13 @@ QT_BEGIN_NAMESPACE
key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
{
if (key.isEmpty()){
- errorString = QCoreApplication::tr("%1: key is empty", "QSystemSemaphore").arg(QLatin1String("QSystemSemaphore::handle:"));
+ errorString =
+#if QT_CONFIG(translation)
+ QCoreApplication::tr("%1: key is empty", "QSystemSemaphore")
+#else
+ QString::fromLatin1("%1: key is empty")
+#endif
+ .arg(QLatin1String("QSystemSemaphore::handle:"));
error = QSystemSemaphore::KeyError;
return -1;
}
@@ -84,16 +90,30 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
// Create the file needed for ftok
int built = QSharedMemoryPrivate::createUnixKeyFile(fileName);
if (-1 == built) {
- errorString = QCoreApplication::tr("%1: unable to make key", "QSystemSemaphore").arg(QLatin1String("QSystemSemaphore::handle:"));
+ errorString =
+#if QT_CONFIG(translation)
+ QCoreApplication::tr("%1: unable to make key", "QSystemSemaphore")
+#else
+ QString::fromLatin1("%1: unable to make key")
+#endif
+ .arg(QLatin1String("QSystemSemaphore::handle:"));
error = QSystemSemaphore::KeyError;
return -1;
}
createdFile = (1 == built);
+#if !defined(QT_NO_SHAREDMEMORY) && !defined(QT_POSIX_IPC) && !defined(Q_OS_ANDROID)
// Get the unix key for the created file
unix_key = qt_safe_ftok(QFile::encodeName(fileName), 'Q');
+#endif
if (-1 == unix_key) {
- errorString = QCoreApplication::tr("%1: ftok failed", "QSystemSemaphore").arg(QLatin1String("QSystemSemaphore::handle:"));
+ errorString =
+#if QT_CONFIG(translation)
+ QCoreApplication::tr("%1: ftok failed", "QSystemSemaphore")
+#else
+ QString::fromLatin1("%1: ftok failed")
+#endif
+ .arg(QLatin1String("QSystemSemaphore::handle:"));
error = QSystemSemaphore::KeyError;
return -1;
}
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 0ffc22d810..4a4d5b9294 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -2914,7 +2914,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix);
#ifndef QT_BOOTSTRAPPED
-/*!
+/*
Returns \c true if from inherits to.
*/
static bool canConvertMetaObject(const QMetaObject *from, const QMetaObject *to)
diff --git a/src/corelib/kernel/qwineventnotifier.h b/src/corelib/kernel/qwineventnotifier.h
index f17fa059a1..f29f325d13 100644
--- a/src/corelib/kernel/qwineventnotifier.h
+++ b/src/corelib/kernel/qwineventnotifier.h
@@ -42,7 +42,7 @@
#include "QtCore/qobject.h"
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
QT_BEGIN_NAMESPACE