summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcore_unix_p.h9
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp50
-rw-r--r--src/corelib/kernel/qfunctions_wince.h4
-rw-r--r--src/corelib/kernel/qmetaobject.cpp53
-rw-r--r--src/corelib/kernel/qmetaobject_p.h6
-rw-r--r--src/corelib/kernel/qobject.cpp183
-rw-r--r--src/corelib/kernel/qobject_p.h20
-rw-r--r--src/corelib/kernel/qobjectdefs.h13
-rw-r--r--src/corelib/kernel/qsystemsemaphore_unix.cpp7
-rw-r--r--src/corelib/kernel/qtranslator.cpp32
10 files changed, 241 insertions, 136 deletions
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 2e84f3b..33df0da 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -319,6 +319,15 @@ timeval qt_gettime(); // in qelapsedtimer_mac.cpp or qtimestamp_unix.cpp
Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
const struct timeval *tv);
+// according to X/OPEN we have to define semun ourselves
+// we use prefix as on some systems sem.h will have it
+struct semid_ds;
+union qt_semun {
+ int val; /* value for SETVAL */
+ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
+ unsigned short *array; /* array for GETALL, SETALL */
+};
+
QT_END_NAMESPACE
#endif
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index a95e7d5..79f2596 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -43,6 +43,7 @@
#include <private/qthread_p.h>
#include <qcoreapplication.h>
#include <private/qcoreapplication_p.h>
+#include <qsemaphore.h>
#include <unistd.h>
#include <errno.h>
@@ -685,34 +686,54 @@ class QIdleDetectorThread
{
public:
QIdleDetectorThread()
- : m_state(STATE_RUN), m_stop(false)
+ : m_state(STATE_RUN), m_stop(false), m_running(false)
{
- qt_symbian_throwIfError(m_lock.CreateLocal(0));
+ start();
+ }
+
+ ~QIdleDetectorThread()
+ {
+ stop();
+ }
+
+ void start()
+ {
+ QMutexLocker lock(&m_mutex);
+ if (m_running)
+ return;
+ m_stop = false;
+ m_state = STATE_RUN;
TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, &User::Allocator(), this);
if (err != KErrNone)
- m_lock.Close();
- qt_symbian_throwIfError(err);
+ return; // Fail silently on error. Next kick will try again. Exception might stop the event being processed
m_idleDetectorThread.SetPriority(EPriorityAbsoluteBackgroundNormal);
m_idleDetectorThread.Resume();
+ m_running = true;
+ // get a callback from QCoreApplication destruction to stop this thread
+ qAddPostRoutine(StopIdleDetectorThread);
}
- ~QIdleDetectorThread()
+ void stop()
{
+ QMutexLocker lock(&m_mutex);
+ if (!m_running)
+ return;
// close down the idle thread because if corelib is loaded temporarily, this would leak threads into the host process
m_stop = true;
- m_lock.Signal();
+ m_kick.release();
m_idleDetectorThread.SetPriority(EPriorityNormal);
TRequestStatus s;
m_idleDetectorThread.Logon(s);
User::WaitForRequest(s);
m_idleDetectorThread.Close();
- m_lock.Close();
+ m_running = false;
}
void kick()
{
+ start();
m_state = STATE_KICKED;
- m_lock.Signal();
+ m_kick.release();
}
bool hasRun()
@@ -731,20 +752,29 @@ private:
void IdleLoop()
{
while (!m_stop) {
- m_lock.Wait();
+ m_kick.acquire();
m_state = STATE_RUN;
}
}
+ static void StopIdleDetectorThread();
+
private:
enum IdleStates {STATE_KICKED, STATE_RUN} m_state;
bool m_stop;
+ bool m_running;
RThread m_idleDetectorThread;
- RSemaphore m_lock;
+ QSemaphore m_kick;
+ QMutex m_mutex;
};
Q_GLOBAL_STATIC(QIdleDetectorThread, idleDetectorThread);
+void QIdleDetectorThread::StopIdleDetectorThread()
+{
+ idleDetectorThread()->stop();
+}
+
const int maxBusyTime = 2000; // maximum time we allow idle detector to be blocked before worrying, in milliseconds
const int baseDelay = 1000; // minimum delay time used when backing off to allow idling, in microseconds
#endif
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
index e282457..fffe407 100644
--- a/src/corelib/kernel/qfunctions_wince.h
+++ b/src/corelib/kernel/qfunctions_wince.h
@@ -84,10 +84,6 @@ errno_t qt_wince__putenv_s(const char*, const char*);
extern "C" {
#endif
-#define SetWindowLongA SetWindowLong
-#define GetWindowLongA GetWindowLong
-#define SendMessageA SendMessage
-
#if !defined(NO_ERRNO_H)
#define NO_ERRNO_H
#endif
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index c5775f6..e671056 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -218,12 +218,20 @@ QObject *QMetaObject::newInstance(QGenericArgument val0,
*/
int QMetaObject::static_metacall(Call cl, int idx, void **argv) const
{
- if (priv(d.data)->revision < 2)
- return 0;
- const QMetaObjectExtraData *extra = (const QMetaObjectExtraData*)(d.extradata);
- if (!extra || !extra->static_metacall)
- return 0;
- return extra->static_metacall(cl, idx, argv);
+ const QMetaObjectExtraData *extra = reinterpret_cast<const QMetaObjectExtraData *>(d.extradata);
+ if (priv(d.data)->revision >= 6) {
+ if (!extra || !extra->static_metacall)
+ return 0;
+ extra->static_metacall(0, cl, idx, argv);
+ return -1;
+ } else if (priv(d.data)->revision >= 2) {
+ if (!extra || !extra->static_metacall)
+ return 0;
+ typedef int (*OldMetacall)(QMetaObject::Call, int, void **);
+ OldMetacall o = reinterpret_cast<OldMetacall>(extra->static_metacall);
+ return o(cl, idx, argv);
+ }
+ return 0;
}
/*!
@@ -639,20 +647,21 @@ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject,
*/
int QMetaObject::indexOfSlot(const char *slot) const
{
- int i = QMetaObjectPrivate::indexOfSlot(this, slot, false);
+ const QMetaObject *m = this;
+ int i = QMetaObjectPrivate::indexOfSlotRelative(&m, slot, false);
if (i < 0)
- i = QMetaObjectPrivate::indexOfSlot(this, slot, true);
+ i = QMetaObjectPrivate::indexOfSlotRelative(&m, slot, true);
+ if (i >= 0)
+ i += m->methodOffset();
return i;
}
-int QMetaObjectPrivate::indexOfSlot(const QMetaObject *m,
+// same as indexOfSignalRelative but for slots.
+int QMetaObjectPrivate::indexOfSlotRelative(const QMetaObject **m,
const char *slot,
bool normalizeStringData)
{
- int i = indexOfMethodRelative<MethodSlot>(&m, slot, normalizeStringData);
- if (i >= 0)
- i += m->methodOffset();
- return i;
+ return indexOfMethodRelative<MethodSlot>(m, slot, normalizeStringData);
}
static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, const char *name)
@@ -1616,9 +1625,19 @@ bool QMetaMethod::invoke(QObject *object,
val9.data()
};
// recompute the methodIndex by reversing the arithmetic in QMetaObject::property()
- int methodIndex = ((handle - priv(mobj->d.data)->methodData) / 5) + mobj->methodOffset();
+ int idx_relative = ((handle - priv(mobj->d.data)->methodData) / 5);
+ int idx_offset = mobj->methodOffset();
+ QObjectPrivate::StaticMetaCallFunction callFunction =
+ (QMetaObjectPrivate::get(mobj)->revision >= 6 && mobj->d.extradata)
+ ? reinterpret_cast<const QMetaObjectExtraData *>(mobj->d.extradata)->static_metacall : 0;
+
if (connectionType == Qt::DirectConnection) {
- return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, methodIndex, param) < 0;
+ if (callFunction) {
+ callFunction(object, QMetaObject::InvokeMetaMethod, idx_relative, param);
+ return true;
+ } else {
+ return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, idx_relative + idx_offset, param) < 0;
+ }
} else if (connectionType == Qt::QueuedConnection) {
if (returnValue.data()) {
qWarning("QMetaMethod::invoke: Unable to invoke methods with return values in "
@@ -1652,7 +1671,7 @@ bool QMetaMethod::invoke(QObject *object,
}
}
- QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
+ QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
0, -1, nargs, types, args));
} else { // blocking queued connection
#ifndef QT_NO_THREAD
@@ -1663,7 +1682,7 @@ bool QMetaMethod::invoke(QObject *object,
}
QSemaphore semaphore;
- QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
+ QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
0, -1, 0, 0, param, &semaphore));
semaphore.acquire();
#endif // QT_NO_THREAD
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 210b32c..fdadf4a 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -118,6 +118,7 @@ struct QMetaObjectPrivate
int flags; //since revision 3
int signalCount; //since revision 4
// revision 5 introduces changes in normalized signatures, no new members
+ // revision 6 added qt_static_metacall as a member of each Q_OBJECT and inside QMetaObject itself
static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject)
{ return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
@@ -125,7 +126,7 @@ struct QMetaObjectPrivate
static int indexOfSignalRelative(const QMetaObject **baseObject,
const char* name,
bool normalizeStringData);
- static int indexOfSlot(const QMetaObject *m,
+ static int indexOfSlotRelative(const QMetaObject **m,
const char *slot,
bool normalizeStringData);
static int originalClone(const QMetaObject *obj, int local_method_index);
@@ -136,7 +137,8 @@ struct QMetaObjectPrivate
static void memberIndexes(const QObject *obj, const QMetaMethod &member,
int *signalIndex, int *methodIndex);
static bool connect(const QObject *sender, int signal_index,
- const QObject *receiver, int method_index,
+ const QObject *receiver, int method_index_relative,
+ const QMetaObject *rmeta = 0,
int type = 0, int *types = 0);
static bool disconnect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index,
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index c6153cb..357cfd3 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -263,12 +263,6 @@ public:
: QVector<QObjectPrivate::ConnectionList>(), orphaned(false), dirty(false), inUse(0)
{ }
- const QObjectPrivate::ConnectionList &at(int at) const
- {
- if (at < 0)
- return allsignals;
- return QVector<QObjectPrivate::ConnectionList>::at(at);
- }
QObjectPrivate::ConnectionList &operator[](int at)
{
if (at < 0)
@@ -496,10 +490,12 @@ void QObjectPrivate::clearGuards(QObject *object)
/*! \internal
*/
-QMetaCallEvent::QMetaCallEvent(int id, const QObject *sender, int signalId,
+QMetaCallEvent::QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction,
+ const QObject *sender, int signalId,
int nargs, int *types, void **args, QSemaphore *semaphore)
- : QEvent(MetaCall), id_(id), sender_(sender), signalId_(signalId),
- nargs_(nargs), types_(types), args_(args), semaphore_(semaphore)
+ : QEvent(MetaCall), sender_(sender), signalId_(signalId),
+ nargs_(nargs), types_(types), args_(args), semaphore_(semaphore),
+ callFunction_(callFunction), method_offset_(method_offset), method_relative_(method_relative)
{ }
/*! \internal
@@ -522,9 +518,13 @@ QMetaCallEvent::~QMetaCallEvent()
/*! \internal
*/
-int QMetaCallEvent::placeMetaCall(QObject *object)
+void QMetaCallEvent::placeMetaCall(QObject *object)
{
- return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, id_, args_);
+ if (callFunction_) {
+ callFunction_(object, QMetaObject::InvokeMetaMethod, method_relative_, args_);
+ } else {
+ QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, method_offset_ + method_relative_, args_);
+ }
}
/*!
@@ -2613,18 +2613,17 @@ bool QObject::connect(const QObject *sender, const char *signal,
++method; // skip code
const QMetaObject *rmeta = receiver->metaObject();
- int method_index = -1;
+ int method_index_relative = -1;
switch (membcode) {
case QSLOT_CODE:
- method_index = QMetaObjectPrivate::indexOfSlot(rmeta, method, false);
+ method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(&rmeta, method, false);
break;
case QSIGNAL_CODE:
- method_index = QMetaObjectPrivate::indexOfSignalRelative(&rmeta, method, false);
- if (method_index >= 0)
- method_index += rmeta->methodOffset();
+ method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(&rmeta, method, false);
break;
}
- if (method_index < 0) {
+
+ if (method_index_relative < 0) {
// check for normalized methods
tmp_method_name = QMetaObject::normalizedSignature(method);
method = tmp_method_name.constData();
@@ -2633,19 +2632,24 @@ bool QObject::connect(const QObject *sender, const char *signal,
rmeta = receiver->metaObject();
switch (membcode) {
case QSLOT_CODE:
- method_index = rmeta->indexOfSlot(method);
+ method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(&rmeta, method, false);
+ if (method_index_relative < 0)
+ method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(&rmeta, method, true);
break;
case QSIGNAL_CODE:
- method_index = rmeta->indexOfSignal(method);
+ method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(&rmeta, method, false);
+ if (method_index_relative < 0)
+ method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(&rmeta, method, true);
break;
}
}
- if (method_index < 0) {
+ if (method_index_relative < 0) {
err_method_notfound(receiver, method_arg, "connect");
err_info_about_objects("connect", sender, receiver);
return false;
}
+
if (!QMetaObject::checkConnectArgs(signal, method)) {
qWarning("QObject::connect: Incompatible sender/receiver arguments"
"\n %s::%s --> %s::%s",
@@ -2660,14 +2664,13 @@ bool QObject::connect(const QObject *sender, const char *signal,
return false;
#ifndef QT_NO_DEBUG
- {
+ if (warnCompat) {
QMetaMethod smethod = smeta->method(signal_absolute_index);
- QMetaMethod rmethod = rmeta->method(method_index);
- if (warnCompat)
- check_and_warn_compat(smeta, smethod, rmeta, rmethod);
+ QMetaMethod rmethod = rmeta->method(method_index_relative + rmeta->methodOffset());
+ check_and_warn_compat(smeta, smethod, rmeta, rmethod);
}
#endif
- if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types))
+ if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index_relative, rmeta ,type, types))
return false;
const_cast<QObject*>(sender)->connectNotify(signal - 1);
return true;
@@ -2772,7 +2775,7 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal,
if (warnCompat)
check_and_warn_compat(smeta, signal, rmeta, method);
#endif
- if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types))
+ if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, 0, type, types))
return false;
const_cast<QObject*>(sender)->connectNotify(signalSignature.constData());
@@ -3163,18 +3166,28 @@ bool QMetaObject::connect(const QObject *sender, int signal_index,
{
signal_index = methodIndexToSignalIndex(sender->metaObject(), signal_index);
return QMetaObjectPrivate::connect(sender, signal_index,
- receiver, method_index, type, types);
+ receiver, method_index,
+ 0, //FIXME, we could speed this connection up by computing the relative index
+ type, types);
}
/*! \internal
Same as the QMetaObject::connect, but \a signal_index must be the result of QObjectPrivate::signalIndex
+
+ method_index is relative to the rmeta metaobject, if rmeta is null, then it is absolute index
*/
bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index,
- const QObject *receiver, int method_index, int type, int *types)
+ const QObject *receiver, int method_index,
+ const QMetaObject *rmeta, int type, int *types)
{
QObject *s = const_cast<QObject *>(sender);
QObject *r = const_cast<QObject *>(receiver);
+ int method_offset = rmeta ? rmeta->methodOffset() : 0;
+ QObjectPrivate::StaticMetaCallFunction callFunction =
+ (rmeta && QMetaObjectPrivate::get(rmeta)->revision >= 6 && rmeta->d.extradata)
+ ? reinterpret_cast<const QMetaObjectExtraData *>(rmeta->d.extradata)->static_metacall : 0;
+
QOrderedMutexLocker locker(signalSlotLock(sender),
signalSlotLock(receiver));
@@ -3184,8 +3197,10 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index,
const QObjectPrivate::Connection *c2 =
(*connectionLists)[signal_index].first;
+ int method_index_absolute = method_index + method_offset;
+
while (c2) {
- if (c2->receiver == receiver && c2->method == method_index)
+ if (c2->receiver == receiver && c2->method() == method_index_absolute)
return false;
c2 = c2->nextConnectionList;
}
@@ -3196,10 +3211,12 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index,
QObjectPrivate::Connection *c = new QObjectPrivate::Connection;
c->sender = s;
c->receiver = r;
- c->method = method_index;
+ c->method_relative = method_index;
+ c->method_offset = method_offset;
c->connectionType = type;
c->argumentTypes = types;
c->nextConnectionList = 0;
+ c->callFunction = callFunction;
QT_TRY {
QObjectPrivate::get(s)->addConnection(signal_index, c);
@@ -3260,7 +3277,7 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c,
while (c) {
if (c->receiver
&& (receiver == 0 || (c->receiver == receiver
- && (method_index < 0 || c->method == method_index)))) {
+ && (method_index < 0 || c->method() == method_index)))) {
bool needToUnlock = false;
QMutex *receiverMutex = 0;
if (!receiver) {
@@ -3434,12 +3451,11 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
args[0] = 0; // return value
for (int n = 1; n < nargs; ++n)
args[n] = QMetaType::construct((types[n] = c->argumentTypes[n-1]), argv[n]);
- QCoreApplication::postEvent(c->receiver, new QMetaCallEvent(c->method,
- sender,
- signal,
- nargs,
- types,
- args));
+ QCoreApplication::postEvent(c->receiver, new QMetaCallEvent(c->method_offset,
+ c->method_relative,
+ c->callFunction,
+ sender, signal, nargs,
+ types, args));
}
@@ -3478,7 +3494,7 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
argv ? argv : empty_argv);
}
- QThreadData *currentThreadData = QThreadData::current();
+ Qt::HANDLE currentThreadId = QThread::currentThreadId();
QMutexLocker locker(signalSlotLock(sender));
QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists;
@@ -3489,24 +3505,27 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
return;
}
++connectionLists->inUse;
- if (signal_index >= connectionLists->count()) {
- signal_index = -2; //for "all signals";
- }
+
+
+ const QObjectPrivate::ConnectionList *list;
+ if (signal_index < connectionLists->count())
+ list = &connectionLists->at(signal_index);
+ else
+ list = &connectionLists->allsignals;
do {
- QObjectPrivate::Connection *c = connectionLists->at(signal_index).first;
+ QObjectPrivate::Connection *c = list->first;
if (!c) continue;
// We need to check against last here to ensure that signals added
// during the signal emission are not emitted in this emission.
- QObjectPrivate::Connection *last = connectionLists->at(signal_index).last;
+ QObjectPrivate::Connection *last = list->last;
do {
if (!c->receiver)
continue;
QObject * const receiver = c->receiver;
- const int method = c->method;
- const bool receiverInSameThread = currentThreadData == receiver->d_func()->threadData;
+ const bool receiverInSameThread = currentThreadId == receiver->d_func()->threadData->threadId;
// determine if this connection should be sent immediately or
// put into the event queue
@@ -3524,7 +3543,8 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
receiver->metaObject()->className(), receiver);
}
QSemaphore semaphore;
- QCoreApplication::postEvent(receiver, new QMetaCallEvent(method,
+ QCoreApplication::postEvent(receiver, new QMetaCallEvent(c->method_offset, c->method_relative,
+ c->callFunction,
sender, signal_absolute_index,
0, 0,
argv ? argv : empty_argv,
@@ -3534,6 +3554,7 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
continue;
#endif
}
+
QObjectPrivate::Sender currentSender;
QObjectPrivate::Sender *previousSender = 0;
if (receiverInSameThread) {
@@ -3542,36 +3563,52 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
currentSender.ref = 1;
previousSender = QObjectPrivate::setCurrentSender(receiver, &currentSender);
}
- locker.unlock();
+ const QObjectPrivate::StaticMetaCallFunction callFunction = c->callFunction;
+ const int method_relative = c->method_relative;
+ if (callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) {
+ //we compare the vtable to make sure we are not in the destructor of the object.
+ locker.unlock();
+ if (qt_signal_spy_callback_set.slot_begin_callback != 0)
+ qt_signal_spy_callback_set.slot_begin_callback(receiver, c->method(), argv ? argv : empty_argv);
- if (qt_signal_spy_callback_set.slot_begin_callback != 0) {
- qt_signal_spy_callback_set.slot_begin_callback(receiver,
- method,
- argv ? argv : empty_argv);
- }
+ callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv ? argv : empty_argv);
-#if defined(QT_NO_EXCEPTIONS)
- metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
-#else
- QT_TRY {
- metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
- } QT_CATCH(...) {
+ if (qt_signal_spy_callback_set.slot_end_callback != 0)
+ qt_signal_spy_callback_set.slot_end_callback(receiver, c->method());
locker.relock();
- if (receiverInSameThread)
- QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
+ } else {
+ const int method = method_relative + c->method_offset;
+ locker.unlock();
- --connectionLists->inUse;
- Q_ASSERT(connectionLists->inUse >= 0);
- if (connectionLists->orphaned && !connectionLists->inUse)
- delete connectionLists;
- QT_RETHROW;
- }
+ if (qt_signal_spy_callback_set.slot_begin_callback != 0) {
+ qt_signal_spy_callback_set.slot_begin_callback(receiver,
+ method,
+ argv ? argv : empty_argv);
+ }
+
+#if defined(QT_NO_EXCEPTIONS)
+ metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
+#else
+ QT_TRY {
+ metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
+ } QT_CATCH(...) {
+ locker.relock();
+ if (receiverInSameThread)
+ QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
+
+ --connectionLists->inUse;
+ Q_ASSERT(connectionLists->inUse >= 0);
+ if (connectionLists->orphaned && !connectionLists->inUse)
+ delete connectionLists;
+ QT_RETHROW;
+ }
#endif
- if (qt_signal_spy_callback_set.slot_end_callback != 0)
- qt_signal_spy_callback_set.slot_end_callback(receiver, method);
+ if (qt_signal_spy_callback_set.slot_end_callback != 0)
+ qt_signal_spy_callback_set.slot_end_callback(receiver, method);
- locker.relock();
+ locker.relock();
+ }
if (receiverInSameThread)
QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
@@ -3582,7 +3619,9 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
if (connectionLists->orphaned)
break;
- } while (signal_index >= 0 && (signal_index = -1)); //start over for -1 (all signal)
+ } while (list != &connectionLists->allsignals &&
+ //start over for all signals;
+ ((list = &connectionLists->allsignals), true));
--connectionLists->inUse;
Q_ASSERT(connectionLists->inUse >= 0);
@@ -3870,7 +3909,7 @@ void QObject::dumpObjectInfo()
continue;
}
const QMetaObject *receiverMetaObject = c->receiver->metaObject();
- const QMetaMethod method = receiverMetaObject->method(c->method);
+ const QMetaMethod method = receiverMetaObject->method(c->method());
qDebug(" --> %s::%s %s",
receiverMetaObject->className(),
c->receiver->objectName().isEmpty() ? "unnamed" : qPrintable(c->receiver->objectName()),
@@ -3887,7 +3926,7 @@ void QObject::dumpObjectInfo()
if (d->senders) {
for (QObjectPrivate::Connection *s = d->senders; s; s = s->next) {
- const QMetaMethod slot = metaObject()->method(s->method);
+ const QMetaMethod slot = metaObject()->method(s->method());
qDebug(" <-- %s::%s %s",
s->sender->metaObject()->className(),
s->sender->objectName().isEmpty() ? "unnamed" : qPrintable(s->sender->objectName()),
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index c7555be..2711a4b 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -108,19 +108,23 @@ public:
QList<QVariant> propertyValues;
};
+ typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **);
struct Connection
{
QObject *sender;
QObject *receiver;
- int method;
- uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
- QBasicAtomicPointer<int> argumentTypes;
+ StaticMetaCallFunction callFunction;
// The next pointer for the singly-linked ConnectionList
Connection *nextConnectionList;
//senders linked list
Connection *next;
Connection **prev;
+ QBasicAtomicPointer<int> argumentTypes;
+ ushort method_offset;
+ ushort method_relative;
+ ushort connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
~Connection();
+ int method() const { return method_offset + method_relative; }
};
// ConnectionList is a singly-linked list
struct ConnectionList {
@@ -253,25 +257,27 @@ class QSemaphore;
class Q_CORE_EXPORT QMetaCallEvent : public QEvent
{
public:
- QMetaCallEvent(int id, const QObject *sender, int signalId,
+ QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction , const QObject *sender, int signalId,
int nargs = 0, int *types = 0, void **args = 0, QSemaphore *semaphore = 0);
~QMetaCallEvent();
- inline int id() const { return id_; }
+ inline int id() const { return method_offset_ + method_relative_; }
inline const QObject *sender() const { return sender_; }
inline int signalId() const { return signalId_; }
inline void **args() const { return args_; }
- virtual int placeMetaCall(QObject *object);
+ virtual void placeMetaCall(QObject *object);
private:
- int id_;
const QObject *sender_;
int signalId_;
int nargs_;
int *types_;
void **args_;
QSemaphore *semaphore_;
+ QObjectPrivate::StaticMetaCallFunction callFunction_;
+ ushort method_offset_;
+ ushort method_relative_;
};
class QBoolBlocker
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 54b5ab2..4384837 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -55,7 +55,7 @@ class QByteArray;
class QString;
#ifndef Q_MOC_OUTPUT_REVISION
-#define Q_MOC_OUTPUT_REVISION 62
+#define Q_MOC_OUTPUT_REVISION 63
#endif
// The following macros are our "extensions" to C++
@@ -163,7 +163,10 @@ public: \
virtual void *qt_metacast(const char *); \
QT_TR_FUNCTIONS \
virtual int qt_metacall(QMetaObject::Call, int, void **); \
-private:
+private: \
+ Q_DECL_HIDDEN static const QMetaObjectExtraData staticMetaObjectExtraData; \
+ Q_DECL_HIDDEN static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
+
/* tmake ignore Q_OBJECT */
#define Q_OBJECT_FAKE Q_OBJECT
/* tmake ignore Q_GADGET */
@@ -468,7 +471,6 @@ struct Q_CORE_EXPORT QMetaObject
const uint *data;
const void *extradata;
} d;
-
};
typedef const QMetaObject& (*QMetaObjectAccessor)();
@@ -480,7 +482,10 @@ struct QMetaObjectExtraData
#else
const QMetaObject **objects;
#endif
- int (*static_metacall)(QMetaObject::Call, int, void **);
+
+ typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **); //from revision 6
+ //typedef int (*StaticMetaCall)(QMetaObject::Call, int, void **); //used from revison 2 until revison 5
+ StaticMetacallFunction static_metacall;
};
inline const char *QMetaObject::className() const
diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp
index a68abd3..55b65b7 100644
--- a/src/corelib/kernel/qsystemsemaphore_unix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp
@@ -64,13 +64,6 @@
QT_BEGIN_NAMESPACE
-// We have to define this as on some sem.h will have it
-union qt_semun {
- int val; /* value for SETVAL */
- struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
- unsigned short *array; /* array for GETALL, SETALL */
-};
-
QSystemSemaphorePrivate::QSystemSemaphorePrivate() :
semaphore(-1), createdFile(false),
createdSemaphore(false), unix_key(-1), error(QSystemSemaphore::NoError)
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 802cf1c..22b06a5 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -357,10 +357,15 @@ QTranslator::~QTranslator()
}
/*!
- Loads \a filename + \a suffix (".qm" if the \a suffix is
- not specified), which may be an absolute file name or relative
- to \a directory. Returns true if the translation is successfully
- loaded; otherwise returns false.
+
+ Loads \a filename + \a suffix (".qm" if the \a suffix is not
+ specified), which may be an absolute file name or relative to \a
+ directory. Returns true if the translation is successfully loaded;
+ otherwise returns false.
+
+ If \a directory is not specified, the directory of the
+ application's executable is used (i.e., as
+ \l{QCoreApplication::}{applicationDirPath()}).
The previous contents of this translator object are discarded.
@@ -595,10 +600,10 @@ static QString find_translation(const QLocale & locale,
/*!
\since 4.8
- Loads \a filename + \a prefix + \a locale name + \a suffix (".qm" if the \a
- suffix is not specified), which may be an absolute file name or relative to
- \a directory. Returns true if the translation is successfully loaded;
- otherwise returns false.
+ Loads \a filename + \a prefix + \a \l{QLocale::uiLanguages()}{ui language
+ name} + \a suffix (".qm" if the \a suffix is not specified), which may be
+ an absolute file name or relative to \a directory. Returns true if the
+ translation is successfully loaded; otherwise returns false.
The previous contents of this translator object are discarded.
@@ -607,15 +612,16 @@ static QString find_translation(const QLocale & locale,
\list 1
\o File name without \a suffix appended.
- \o File name with locale part after a "_" character stripped and \a suffix.
- \o File name with locale part stripped without \a suffix appended.
- \o File name with locale part stripped further, etc.
+ \o File name with ui language part after a "_" character stripped and \a suffix.
+ \o File name with ui language part stripped without \a suffix appended.
+ \o File name with ui language part stripped further, etc.
\endlist
For example, an application running in the locale with the following
l{QLocale::uiLanguages()}{ui languages} - "es", "fr-CA", "de" might call
load(QLocale::system(), "foo", ".", "/opt/foolib", ".qm"). load() would
- then try to open the first existing readable file from this list:
+ replace '-' (dash) with '_' (underscore) in the ui language and then try to
+ open the first existing readable file from this list:
\list 1
\o \c /opt/foolib/foo.es.qm
@@ -836,7 +842,7 @@ QString QTranslatorPrivate::do_translate(const char *context, const char *source
numerus = numerusHelper(n, numerusRulesArray, numerusRulesLength);
for (;;) {
- quint32 h = elfHash(QByteArray(sourceText) + comment);
+ quint32 h = elfHash(QByteArray(QByteArray(sourceText) + comment).constData());
const uchar *start = offsetArray;
const uchar *end = start + ((numItems-1) << 3);