Re-add QInternal::EventNotifyCallback
This is needed by QtScript, so we need to keep it for now. Change-Id: Iee6bd7daf7e86a09242523f5aca72ede413a6981 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
d242d78339
commit
2c9d042476
@ -2831,6 +2831,47 @@ int qrand()
|
|||||||
with meaningful parameter names in their signatures.
|
with meaningful parameter names in their signatures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct QInternal_CallBackTable {
|
||||||
|
QVector<QList<qInternalCallback> > callbacks;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table)
|
||||||
|
|
||||||
|
bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
|
||||||
|
{
|
||||||
|
if (cb >= 0 && cb < QInternal::LastCallback) {
|
||||||
|
QInternal_CallBackTable *cbt = global_callback_table();
|
||||||
|
cbt->callbacks.resize(cb + 1);
|
||||||
|
cbt->callbacks[cb].append(callback);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)
|
||||||
|
{
|
||||||
|
if (cb >= 0 && cb < QInternal::LastCallback) {
|
||||||
|
QInternal_CallBackTable *cbt = global_callback_table();
|
||||||
|
return (bool) cbt->callbacks[cb].removeAll(callback);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QInternal::activateCallbacks(Callback cb, void **parameters)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(cb >= 0, "QInternal::activateCallback()", "Callback id must be a valid id");
|
||||||
|
|
||||||
|
QInternal_CallBackTable *cbt = global_callback_table();
|
||||||
|
if (cbt && cb < cbt->callbacks.size()) {
|
||||||
|
QList<qInternalCallback> callbacks = cbt->callbacks[cb];
|
||||||
|
bool ret = false;
|
||||||
|
for (int i=0; i<callbacks.size(); ++i)
|
||||||
|
ret |= (callbacks.at(i))(parameters);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\macro Q_BYTE_ORDER
|
\macro Q_BYTE_ORDER
|
||||||
\relates <QtGlobal>
|
\relates <QtGlobal>
|
||||||
|
@ -1599,6 +1599,14 @@ public:
|
|||||||
BottomDock,
|
BottomDock,
|
||||||
DockCount
|
DockCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Callback {
|
||||||
|
EventNotifyCallback,
|
||||||
|
LastCallback
|
||||||
|
};
|
||||||
|
static bool registerCallback(Callback, qInternalCallback);
|
||||||
|
static bool unregisterCallback(Callback, qInternalCallback);
|
||||||
|
static bool activateCallbacks(Callback, void **);
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -787,6 +787,14 @@ bool QCoreApplication::testAttribute(Qt::ApplicationAttribute attribute)
|
|||||||
*/
|
*/
|
||||||
bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event)
|
bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event)
|
||||||
{
|
{
|
||||||
|
// Make it possible for QtScript to hook into events even
|
||||||
|
// though QApplication is subclassed...
|
||||||
|
bool result = false;
|
||||||
|
void *cbdata[] = { receiver, event, &result };
|
||||||
|
if (QInternal::activateCallbacks(QInternal::EventNotifyCallback, cbdata)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Qt enforces the rule that events can only be sent to objects in
|
// Qt enforces the rule that events can only be sent to objects in
|
||||||
// the current thread, so receiver->d_func()->threadData is
|
// the current thread, so receiver->d_func()->threadData is
|
||||||
// equivalent to QThreadData::current(), just without the function
|
// equivalent to QThreadData::current(), just without the function
|
||||||
|
Loading…
Reference in New Issue
Block a user