QPersistentModelIndexData *QPersistentModelIndexData::create(const QModelIndex &index)
{
Q_ASSERT(index.isValid()); // we will _never_ insert an invalid index in the list
- QPersistentModelIndexData *d = 0;
+ QPersistentModelIndexData *d = Q_NULLPTR;
QAbstractItemModel *model = const_cast<QAbstractItemModel *>(index.model());
QHash<QModelIndex, QPersistentModelIndexData *> &indexes = model->d_func()->persistent.indexes;
const QHash<QModelIndex, QPersistentModelIndexData *>::iterator it = indexes.find(index);
*/
QPersistentModelIndex::QPersistentModelIndex()
- : d(0)
+ : d(Q_NULLPTR)
{
}
*/
QPersistentModelIndex::QPersistentModelIndex(const QModelIndex &index)
- : d(0)
+ : d(Q_NULLPTR)
{
if (index.isValid()) {
d = QPersistentModelIndexData::create(index);
{
if (d && !d->ref.deref()) {
QPersistentModelIndexData::destroy(d);
- d = 0;
+ d = Q_NULLPTR;
}
}
d = QPersistentModelIndexData::create(other);
if (d) d->ref.ref();
} else {
- d = 0;
+ d = Q_NULLPTR;
}
return *this;
}
{
if (d)
return d->index.internalPointer();
- return 0;
+ return Q_NULLPTR;
}
/*!
{
if (d)
return d->index.model();
- return 0;
+ return Q_NULLPTR;
}
/*!
QPersistentModelIndexData *data = *it;
persistent.indexes.erase(persistent.indexes.find(data->index));
data->index = QModelIndex();
- data->model = 0;
+ data->model = Q_NULLPTR;
}
}
QPersistentModelIndexData *data = *it;
persistent.indexes.erase(persistent.indexes.find(data->index));
data->index = QModelIndex();
- data->model = 0;
+ data->model = Q_NULLPTR;
}
}
QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const
{
if (indexes.count() <= 0)
- return 0;
+ return Q_NULLPTR;
QStringList types = mimeTypes();
if (types.isEmpty())
- return 0;
+ return Q_NULLPTR;
QMimeData *data = new QMimeData();
QString format = types.at(0);
QByteArray encoded;
if (to.isValid())
d->persistent.insertMultiAtEnd(to, data);
else
- data->model = 0;
+ data->model = Q_NULLPTR;
}
}
if (data->index.isValid())
toBeReinserted << data;
else
- data->model = 0;
+ data->model = Q_NULLPTR;
}
}
QModelIndex QAbstractTableModel::index(int row, int column, const QModelIndex &parent) const
{
- return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex();
+ return hasIndex(row, column, parent) ? createIndex(row, column, Q_NULLPTR) : QModelIndex();
}
/*!
QModelIndex QAbstractListModel::index(int row, int column, const QModelIndex &parent) const
{
- return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex();
+ return hasIndex(row, column, parent) ? createIndex(row, column, Q_NULLPTR) : QModelIndex();
}
/*!
version, QObjectPrivateVersion);
// QObjectData initialization
- q_ptr = 0;
- parent = 0; // no parent yet. It is set by setParent()
+ q_ptr = Q_NULLPTR;
+ parent = Q_NULLPTR; // no parent yet. It is set by setParent()
isWidget = false; // assume not a widget object
pendTimer = false; // no timers yet
blockSig = false; // not blocking signals
sendChildEvents = true; // if we should send ChildInsert and ChildRemove events to parent
receiveChildEvents = true;
postedEvents = 0;
- extraData = 0;
+ extraData = Q_NULLPTR;
connectedSignals[0] = connectedSignals[1] = 0;
inThreadChangeEvent = false;
- metaObject = 0;
+ metaObject = Q_NULLPTR;
}
QObjectPrivate::~QObjectPrivate()
// Set to the last entry in the connection list that was *not*
// deleted. This is needed to update the list's last pointer
// at the end of the cleanup.
- QObjectPrivate::Connection *last = 0;
+ QObjectPrivate::Connection *last = Q_NULLPTR;
QObjectPrivate::Connection **prev = &connectionList.first;
QObjectPrivate::Connection *c = *prev;
d->threadData->ref();
if (parent) {
QT_TRY {
- if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
- parent = 0;
+ if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : Q_NULLPTR, d->threadData))
+ parent = Q_NULLPTR;
setParent(parent);
} QT_CATCH(...) {
d->threadData->deref();
d->threadData->ref();
if (parent) {
QT_TRY {
- if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
- parent = 0;
+ if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : Q_NULLPTR, d->threadData))
+ parent = Q_NULLPTR;
if (d->isWidget) {
if (parent) {
d->parent = parent;
delete d->sharedRefcount;
}
-
if (!d->isWidget && d->isSignalConnected(0)) {
emit destroyed(this);
}
} else {
d->connectionLists->orphaned = true;
}
- d->connectionLists = 0;
+ d->connectionLists = Q_NULLPTR;
}
// disconnect all senders
m->unlock();
continue;
}
- node->receiver = 0;
+ node->receiver = Q_NULLPTR;
QObjectConnectionListVector *senderLists = sender->d_func()->connectionLists;
if (senderLists)
senderLists->dirty = true;
}
if (d->parent) // remove it from parent object
- d->setParent_helper(0);
+ d->setParent_helper(Q_NULLPTR);
delete d_ptr;
}
\relates QObject
Returns the given \a object cast to type T if the object is of type
- T (or of a subclass); otherwise returns 0. If \a object is 0 then
- it will also return 0.
+ T (or of a subclass); otherwise returns Q_NULLPTR. If \a object is
+ null then it will also return null.
The class T must inherit (directly or indirectly) QObject and be
declared with the \l Q_OBJECT macro.
QThreadData *currentData = QThreadData::current();
QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : new QThreadData(0);
- if (d->threadData->thread == 0 && currentData == targetData) {
+ if (!d->threadData->thread && currentData == targetData) {
// one exception to the rule: we allow moving objects with no thread affinity to the current thread
currentData = d->threadData;
} else if (Q_UNLIKELY(d->threadData != currentData)) {
// delete siblings
for (int i = 0; i < children.count(); ++i) {
currentChildBeingDeleted = children.at(i);
- children[i] = 0;
+ children[i] = Q_NULLPTR;
delete currentChildBeingDeleted;
}
children.clear();
} else {
const int index = parentD->children.indexOf(q);
if (parentD->wasDeleted) {
- parentD->children[index] = 0;
+ parentD->children[index] = Q_NULLPTR;
} else {
parentD->children.removeAt(index);
if (sendChildEvents && parentD->receiveChildEvents) {
}
// clean up unused items in the list
- d->eventFilters.removeAll((QObject*)0);
+ d->eventFilters.removeAll((QObject*)Q_NULLPTR);
d->eventFilters.removeAll(obj);
d->eventFilters.prepend(obj);
}
Q_D(QObject);
for (int i = 0; i < d->eventFilters.count(); ++i) {
if (d->eventFilters.at(i) == obj)
- d->eventFilters[i] = 0;
+ d->eventFilters[i] = Q_NULLPTR;
}
}
if (*location != '\0')
return location;
}
- return 0;
+ return Q_NULLPTR;
}
static bool check_signal_macro(const QObject *sender, const char *signal,
QMutexLocker locker(signalSlotLock(this));
if (!d->currentSender)
- return 0;
+ return Q_NULLPTR;
for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) {
if (c->sender == d->currentSender->sender)
return d->currentSender->sender;
}
- return 0;
+ return Q_NULLPTR;
}
/*!
return;
const QMetaObject *m = obj->metaObject();
// Check that member is member of obj class
- while (m != 0 && m != member.mobj)
+ while (m && m != member.mobj)
m = m->d.superdata;
if (!m)
return;
if (type == Qt::QueuedConnection && !(types = queuedConnectionTypes(signal.parameterTypes())))
return false;
- if (Q_UNLIKELY(!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, 0, type, types)))
+ if (Q_UNLIKELY(!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, Q_NULLPTR, type, types)))
return false;
const_cast<QObject*>(sender)->connectNotify(signalSignature.constData());
if (Q_UNLIKELY(!QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index)))
return false;
- const_cast<QObject*>(sender)->disconnectNotify(method.mobj ? signalSignature.constData() : 0);
+ const_cast<QObject*>(sender)->disconnectNotify(method.mobj ? signalSignature.constData() : Q_NULLPTR);
return true;
}
signal_index = methodIndexToSignalIndex(sender->metaObject(), signal_index);
return QMetaObjectPrivate::connect(sender, signal_index,
receiver, method_index,
- 0, //FIXME, we could speed this connection up by computing the relative index
+ Q_NULLPTR, //FIXME, we could speed this connection up by computing the relative index
type, types);
}
int method_offset = rmeta ? rmeta->methodOffset() : 0;
Q_ASSERT(!rmeta || QMetaObjectPrivate::get(rmeta)->revision >= 6);
- QObjectPrivate::StaticMetaCallFunction callFunction = rmeta ? rmeta->d.static_metacall : 0;
+ QObjectPrivate::StaticMetaCallFunction callFunction = rmeta ? rmeta->d.static_metacall : Q_NULLPTR;
QOrderedMutexLocker locker(signalSlotLock(sender),
signalSlotLock(receiver));
c->method_offset = method_offset;
c->connectionType = type;
c->argumentTypes = QAtomicPointer<int>(types);
- c->nextConnectionList = 0;
+ c->nextConnectionList = Q_NULLPTR;
c->callFunction = callFunction;
QT_TRY {
bool success = false;
while (c) {
if (c->receiver
- && (receiver == 0 || (c->receiver == receiver
+ && (!receiver || (c->receiver == receiver
&& (method_index < 0 || c->method() == method_index)))) {
bool needToUnlock = false;
- QMutex *receiverMutex = 0;
+ QMutex *receiverMutex = Q_NULLPTR;
if (!receiver) {
receiverMutex = signalSlotLock(c->receiver);
// need to relock this receiver and sender in the correct order
if (needToUnlock)
receiverMutex->unlock();
- c->receiver = 0;
+ c->receiver = Q_NULLPTR;
success = true;
QObject *s = const_cast<QObject *>(sender);
QMutex *senderMutex = signalSlotLock(sender);
- QMutex *receiverMutex = receiver ? signalSlotLock(receiver) : 0;
+ QMutex *receiverMutex = receiver ? signalSlotLock(receiver) : Q_NULLPTR;
QOrderedMutexLocker locker(senderMutex, receiverMutex);
QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
void **args = (void **) malloc(nargs*sizeof(void *));
Q_CHECK_PTR(args);
types[0] = 0; // return type
- args[0] = 0; // return value
+ args[0] = Q_NULLPTR; // 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_offset,
int signal_absolute_index = methodOffset + local_signal_index;
- void *empty_argv[] = { 0 };
- if (qt_signal_spy_callback_set.signal_begin_callback != 0) {
+ void *empty_argv[] = { Q_NULLPTR };
+ if (qt_signal_spy_callback_set.signal_begin_callback) {
qt_signal_spy_callback_set.signal_begin_callback(sender, signal_absolute_index,
argv ? argv : empty_argv);
}
QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists;
if (!connectionLists) {
locker.unlock();
- if (qt_signal_spy_callback_set.signal_end_callback != 0)
+ if (qt_signal_spy_callback_set.signal_end_callback)
qt_signal_spy_callback_set.signal_end_callback(sender, signal_absolute_index);
return;
}
QCoreApplication::postEvent(receiver, new QMetaCallEvent(c->method_offset, c->method_relative,
c->callFunction,
sender, signal_absolute_index,
- 0, 0,
+ 0, Q_NULLPTR,
argv ? argv : empty_argv,
&semaphore));
semaphore.acquire();
}
QObjectPrivate::Sender currentSender;
- QObjectPrivate::Sender *previousSender = 0;
+ QObjectPrivate::Sender *previousSender = Q_NULLPTR;
if (receiverInSameThread) {
currentSender.sender = sender;
currentSender.signal = signal_absolute_index;
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)
+ if (qt_signal_spy_callback_set.slot_begin_callback)
qt_signal_spy_callback_set.slot_begin_callback(receiver, c->method(), argv ? argv : empty_argv);
QT_TRY {
QT_RETHROW;
}
- if (qt_signal_spy_callback_set.slot_end_callback != 0)
+ if (qt_signal_spy_callback_set.slot_end_callback)
qt_signal_spy_callback_set.slot_end_callback(receiver, c->method());
locker.relock();
} else {
const int method = method_relative + c->method_offset;
locker.unlock();
- if (qt_signal_spy_callback_set.slot_begin_callback != 0) {
+ if (qt_signal_spy_callback_set.slot_begin_callback) {
qt_signal_spy_callback_set.slot_begin_callback(receiver,
method,
argv ? argv : empty_argv);
QT_RETHROW;
}
- if (qt_signal_spy_callback_set.slot_end_callback != 0)
+ if (qt_signal_spy_callback_set.slot_end_callback)
qt_signal_spy_callback_set.slot_end_callback(receiver, method);
locker.relock();
if (connectionLists->orphaned)
break;
- } while (c != last && (c = c->nextConnectionList) != 0);
+ } while (c != last && (c = c->nextConnectionList) != Q_NULLPTR);
if (connectionLists->orphaned)
break;
locker.unlock();
- if (qt_signal_spy_callback_set.signal_end_callback != 0)
+ if (qt_signal_spy_callback_set.signal_end_callback)
qt_signal_spy_callback_set.signal_end_callback(sender, signal_absolute_index);
}
/*!
\fn void QObject::removeChild(QObject *object)
- Use setParent() instead, i.e., call object->setParent(0).
+ Use setParent() instead, i.e., call object->setParent(Q_NULLPTR).
*/
/*!