return false;
}
-extern void qt_set_current_thread_to_main_thread();
-
-bool QInternal::callFunction(InternalFunction func, void **args)
-{
- Q_ASSERT_X(func >= 0,
- "QInternal::callFunction()", "Callback id must be a valid id");
-#ifndef QT_NO_QOBJECT
- switch (func) {
-#ifndef QT_NO_THREAD
- case QInternal::CreateThreadForAdoption:
- *args = QAdoptedThread::createThreadForAdoption();
- return true;
-#endif
- case QInternal::RefAdoptedThread:
- QThreadData::get2((QThread *) *args)->ref();
- return true;
- case QInternal::DerefAdoptedThread:
- QThreadData::get2((QThread *) *args)->deref();
- return true;
- case QInternal::SetCurrentThreadToMainThread:
- qt_set_current_thread_to_main_thread();
- return true;
- case QInternal::SetQObjectSender: {
- QObject *receiver = (QObject *) args[0];
- QObjectPrivate::Sender *sender = new QObjectPrivate::Sender;
- sender->sender = (QObject *) args[1];
- sender->signal = *(int *) args[2];
- sender->ref = 1;
-
- // Store the old sender as "return value"
- args[3] = QObjectPrivate::setCurrentSender(receiver, sender);
- args[4] = sender;
- return true;
- }
- case QInternal::GetQObjectSender: {
- QObject *receiver = (QObject *) args[0];
- QObjectPrivate *d = QObjectPrivate::get(receiver);
- args[1] = d->currentSender ? d->currentSender->sender : 0;
- return true;
- }
- case QInternal::ResetQObjectSender: {
- QObject *receiver = (QObject *) args[0];
- QObjectPrivate::Sender *oldSender = (QObjectPrivate::Sender *) args[1];
- QObjectPrivate::Sender *sender = (QObjectPrivate::Sender *) args[2];
- QObjectPrivate::resetCurrentSender(receiver, sender, oldSender);
- delete sender;
- return true;
- }
-
- default:
- break;
- }
-#else
- Q_UNUSED(args);
- Q_UNUSED(func);
-#endif
-
- return false;
-}
-
/*!
\macro Q_BYTE_ORDER
\relates <QtGlobal>
};
enum Callback {
- ConnectCallback,
- DisconnectCallback,
- AdoptCurrentThread,
EventNotifyCallback,
LastCallback
};
- enum InternalFunction {
- CreateThreadForAdoption,
- RefAdoptedThread,
- DerefAdoptedThread,
- SetCurrentThreadToMainThread,
- SetQObjectSender,
- GetQObjectSender,
- ResetQObjectSender,
- LastInternalFunction
- };
-
enum DockPosition {
LeftDock,
RightDock,
static bool unregisterCallback(Callback, qInternalCallback);
static bool activateCallbacks(Callback, void **);
- static bool callFunction(InternalFunction func, void **);
};
QT_END_NAMESPACE
const QObject *receiver, const char *method,
Qt::ConnectionType type)
{
- {
- const void *cbdata[] = { sender, signal, receiver, method, &type };
- if (QInternal::activateCallbacks(QInternal::ConnectCallback, (void **) cbdata))
- return true;
- }
-
if (sender == 0 || receiver == 0 || signal == 0 || method == 0) {
qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
sender ? sender->metaObject()->className() : "(null)",
QVarLengthArray<char> signalSignature;
QObjectPrivate::signalSignature(signal, &signalSignature);
- {
- QByteArray methodSignature;
- methodSignature.reserve(qstrlen(method.signature())+1);
- methodSignature.append((char)(method.methodType() == QMetaMethod::Slot ? QSLOT_CODE
- : method.methodType() == QMetaMethod::Signal ? QSIGNAL_CODE : 0 + '0'));
- methodSignature.append(method.signature());
- const void *cbdata[] = { sender, signalSignature.constData(), receiver, methodSignature.constData(), &type };
- if (QInternal::activateCallbacks(QInternal::ConnectCallback, (void **) cbdata))
- return true;
- }
-
-
int signal_index;
int method_index;
{
return false;
}
- {
- const void *cbdata[] = { sender, signal, receiver, method };
- if (QInternal::activateCallbacks(QInternal::DisconnectCallback, (void **) cbdata))
- return true;
- }
-
const char *signal_arg = signal;
QByteArray signal_name;
bool signal_found = false;
if (signal.mobj)
QObjectPrivate::signalSignature(signal, &signalSignature);
- {
- QByteArray methodSignature;
- if (method.mobj) {
- methodSignature.reserve(qstrlen(method.signature())+1);
- methodSignature.append((char)(method.methodType() == QMetaMethod::Slot ? QSLOT_CODE
- : method.methodType() == QMetaMethod::Signal ? QSIGNAL_CODE : 0 + '0'));
- methodSignature.append(method.signature());
- }
- const void *cbdata[] = { sender, signal.mobj ? signalSignature.constData() : 0,
- receiver, method.mobj ? methodSignature.constData() : 0 };
- if (QInternal::activateCallbacks(QInternal::DisconnectCallback, (void **) cbdata))
- return true;
- }
-
int signal_index;
int method_index;
{
private:
QMutex *createMutex(int index);
std::array<QAtomicPointer<QMutex>, QMUTEXPOOL_SIZE> mutexes;
- QMutex::RecursionMode recursionMode;
+ const QMutex::RecursionMode recursionMode;
};
QT_END_NAMESPACE
QThreadData *data = currentThreadData;
if (!data) {
void *a;
- if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, &a)) {
- QThread *adopted = static_cast<QThread*>(a);
- Q_ASSERT(adopted);
- data = QThreadData::get2(adopted);
+ data = new QThreadData;
+ QT_TRY {
set_thread_data(data);
- adopted->d_func()->running = true;
- adopted->d_func()->finished = false;
- static_cast<QAdoptedThread *>(adopted)->init();
- } else {
- data = new QThreadData;
- QT_TRY {
- set_thread_data(data);
- data->thread = new QAdoptedThread(data);
- } QT_CATCH(...) {
- clear_thread_data();
- data->deref();
- data = Q_NULLPTR;
- QT_RETHROW;
- }
+ data->thread = new QAdoptedThread(data);
+ } QT_CATCH(...) {
+ clear_thread_data();
data->deref();
+ data = Q_NULLPTR;
+ QT_RETHROW;
}
+ data->deref();
+
data->isAdopted = true;
data->threadId = (Qt::HANDLE)pthread_self();
if (!QCoreApplicationPrivate::theMainThread)