summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2009-08-24 07:36:20 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2009-08-24 07:36:20 (GMT)
commit898cba2245b6fafa3820b44203442fedd9f7ed73 (patch)
treec7545af2a15396c7c5d79612d7073de9b4274d43 /src/corelib/kernel
parent6dade01b24f3fd314cb6ec9c2979348e78740a52 (diff)
parent028655065de7f989a35b63bcab583767aba9c048 (diff)
downloadQt-898cba2245b6fafa3820b44203442fedd9f7ed73.zip
Qt-898cba2245b6fafa3820b44203442fedd9f7ed73.tar.gz
Qt-898cba2245b6fafa3820b44203442fedd9f7ed73.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp11
-rw-r--r--src/corelib/kernel/qcore_symbian_p.h6
-rw-r--r--src/corelib/kernel/qcore_unix_p.h3
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp7
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp21
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h7
-rw-r--r--src/corelib/kernel/qvariant.cpp68
-rw-r--r--src/corelib/kernel/qvariant.h5
8 files changed, 65 insertions, 63 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index 17af60d..3b7059b 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -1216,7 +1216,16 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
layoutChanged() after changing the layout.
Subclasses should update any persistent model indexes before emitting
- layoutChanged().
+ layoutChanged(). In other words, when the structure changes:
+
+ \list
+ \o Call beginLayoutChanged()
+ \o Remember the QModelIndex that will change
+ \o Update your internal data
+ \o Call changePersistentIndex()
+ \o Call endLayoutChanged()
+ \endlist
+
\sa layoutAboutToBeChanged(), dataChanged(), headerDataChanged(), reset(),
changePersistentIndex()
diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h
index 60bf95e..6d3616f 100644
--- a/src/corelib/kernel/qcore_symbian_p.h
+++ b/src/corelib/kernel/qcore_symbian_p.h
@@ -95,6 +95,12 @@ static inline TPtrC qt_QString2TPtrC( const QString& string )
return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length());
}
+/*!
+ \internal
+ This class is a wrapper around the Symbian HBufC descriptor class.
+ It makes sure that the heap allocated HBufC class is freed when it is
+ destroyed.
+*/
class Q_CORE_EXPORT QHBufC
{
public:
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index c83c24b..698b05b 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -274,7 +274,8 @@ static inline int qt_safe_close(int fd)
#undef QT_CLOSE
#define QT_CLOSE qt_safe_close
-// Open C does not (yet?) implement these on Symbian OS and VxWorks doesn't have processes
+// - Open C does not (yet?) implement these on Symbian OS
+// - VxWorks doesn't have processes
#if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_VXWORKS)
static inline int qt_safe_execve(const char *filename, char *const argv[],
char *const envp[])
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index dd3027b..6d88d92 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -490,7 +490,7 @@ QCoreApplication::QCoreApplication(int &argc, char **argv)
{
init();
QCoreApplicationPrivate::eventDispatcher->startingUp();
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) && defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
// Refresh factoryloader, as text codecs are requested during lib path
// resolving process and won't be therefore properly loaded.
// Unknown if this is symbian specific issue.
@@ -1768,9 +1768,8 @@ bool QCoreApplicationPrivate::isTranslatorInstalled(QTranslator *translator)
function also assumes that the current directory has not been
changed by the application.
- In Symbian this function will return the application private directory
- in C-drive, not the path to executable itself, as those are always in
- /sys/bin.
+ In Symbian this function will return the application private directory,
+ not the path to executable itself, as those are always in \c {/sys/bin}.
\sa applicationFilePath()
*/
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index d7b9d92..881e546 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -184,7 +184,7 @@ QWakeUpActiveObject::~QWakeUpActiveObject()
void QWakeUpActiveObject::DoCancel()
{
- if (iStatus.Int() & KRequestPending) {
+ if (iStatus.Int() == KRequestPending) {
TRequestStatus *status = &iStatus;
QEventDispatcherSymbian::RequestComplete(status, KErrNone);
}
@@ -214,7 +214,7 @@ void QTimerActiveObject::DoCancel()
m_rTimer.Cancel();
m_rTimer.Close();
} else {
- if (iStatus.Int() & KRequestPending) {
+ if (iStatus.Int() == KRequestPending) {
TRequestStatus *status = &iStatus;
QEventDispatcherSymbian::RequestComplete(status, KErrNone);
}
@@ -225,6 +225,7 @@ void QTimerActiveObject::RunL()
{
int error;
QT_TRYCATCH_ERROR(error, Run());
+ // All Symbian error codes are negative.
if (error < 0) {
CActiveScheduler::Current()->Error(error); // stop and report here, as this timer will be deleted on scope exit
}
@@ -275,7 +276,7 @@ void QTimerActiveObject::Start()
}
SymbianTimerInfo::SymbianTimerInfo()
-: timerAO(0)
+ : timerAO(0)
{
}
@@ -300,7 +301,7 @@ QCompleteDeferredAOs::~QCompleteDeferredAOs()
void QCompleteDeferredAOs::complete()
{
- if (iStatus.Int() & KRequestPending) {
+ if (iStatus.Int() == KRequestPending) {
TRequestStatus *status = &iStatus;
QEventDispatcherSymbian::RequestComplete(status, KErrNone);
}
@@ -308,7 +309,7 @@ void QCompleteDeferredAOs::complete()
void QCompleteDeferredAOs::DoCancel()
{
- if (iStatus.Int() & KRequestPending) {
+ if (iStatus.Int() == KRequestPending) {
TRequestStatus *status = &iStatus;
QEventDispatcherSymbian::RequestComplete(status, KErrNone);
}
@@ -369,10 +370,8 @@ void QSelectThread::run()
int ret;
int savedSelectErrno;
- //do {
- ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0);
- savedSelectErrno = errno;
- //} while (ret == 0);
+ ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0);
+ savedSelectErrno = errno;
char buffer;
@@ -405,7 +404,6 @@ void QSelectThread::run()
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptionfds);
- {
for (QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin();
i != m_AOStatuses.end(); ++i) {
@@ -434,7 +432,6 @@ void QSelectThread::run()
}
} // end for
- }
// traversed all, so update
updateActivatedNotifiers(QSocketNotifier::Read, &readfds);
@@ -581,7 +578,7 @@ QSocketActiveObject::~QSocketActiveObject()
void QSocketActiveObject::DoCancel()
{
- if (iStatus.Int() & KRequestPending) {
+ if (iStatus.Int() == KRequestPending) {
TRequestStatus *status = &iStatus;
QEventDispatcherSymbian::RequestComplete(status, KErrNone);
}
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
index 69912d0..021de13 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h
@@ -281,13 +281,9 @@ private:
};
#ifdef QT_DEBUG
-// EActive is defined to 1 and ERequestPending to 2, but they are both private.
-// A little dangerous to rely on, but it is only for debugging.
-# define REQUEST_STATUS_ACTIVE_AND_PENDING 3
# define VERIFY_PENDING_REQUEST_STATUS \
- Q_ASSERT(status->Int() & REQUEST_STATUS_ACTIVE_AND_PENDING == REQUEST_STATUS_ACTIVE_AND_PENDING);
+ Q_ASSERT(status->Int() == KRequestPending);
#else
-# define REQUEST_STATUS_ACTIVE_AND_PENDING
# define VERIFY_PENDING_REQUEST_STATUS
#endif
@@ -304,7 +300,6 @@ inline void QEventDispatcherSymbian::RequestComplete(RThread &threadHandle, TReq
threadHandle.RequestComplete(status, reason);
}
-#undef REQUEST_STATUS_ACTIVE_AND_PENDING
#undef VERIFY_PENDING_REQUEST_STATUS
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index ebd2e30..a16ece1 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -156,16 +156,7 @@ static void construct(QVariant::Private *x, const void *copy)
x->data.b = copy ? *static_cast<const bool *>(copy) : false;
break;
case QVariant::Double:
-#if defined(Q_CC_RVCT)
- // Using trinary operator with 64bit constants crashes when ran on Symbian device
- if (copy){
- x->data.d = *static_cast<const double*>(copy);
- } else {
- x->data.d = 0.0;
- }
-#else
x->data.d = copy ? *static_cast<const double*>(copy) : 0.0;
-#endif
break;
case QMetaType::Float:
x->data.f = copy ? *static_cast<const float*>(copy) : 0.0f;
@@ -174,37 +165,22 @@ static void construct(QVariant::Private *x, const void *copy)
x->data.o = copy ? *static_cast<QObject *const*>(copy) : 0;
break;
case QVariant::LongLong:
-#if defined(Q_CC_RVCT)
- // Using trinary operator with 64bit constants crashes when ran on Symbian device
- if (copy){
- x->data.ll = *static_cast<const qlonglong *>(copy);
- } else {
- x->data.ll = Q_INT64_C(0);
- }
-#else
x->data.ll = copy ? *static_cast<const qlonglong *>(copy) : Q_INT64_C(0);
-#endif
break;
case QVariant::ULongLong:
-#if defined(Q_CC_RVCT)
- // Using trinary operator with 64bit constants crashes when ran on Symbian device
- if (copy){
- x->data.ull = *static_cast<const qulonglong *>(copy);
- } else {
- x->data.ull = Q_UINT64_C(0);
- }
-#else
x->data.ull = copy ? *static_cast<const qulonglong *>(copy) : Q_UINT64_C(0);
-#endif
break;
case QVariant::Invalid:
case QVariant::UserType:
break;
default:
- x->is_shared = true;
- x->data.shared = new QVariant::PrivateShared(QMetaType::construct(x->type, copy));
- if (!x->data.shared->ptr)
+ void *ptr = QMetaType::construct(x->type, copy);
+ if (!ptr) {
x->type = QVariant::Invalid;
+ } else {
+ x->is_shared = true;
+ x->data.shared = new QVariant::PrivateShared(ptr);
+ }
break;
}
x->is_null = !copy;
@@ -483,15 +459,17 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
if (!QMetaType::isRegistered(a->type))
qFatal("QVariant::compare: type %d unknown to QVariant.", a->type);
+ const void *a_ptr = a->is_shared ? a->data.shared->ptr : &(a->data.ptr);
+ const void *b_ptr = b->is_shared ? b->data.shared->ptr : &(b->data.ptr);
+
/* The reason we cannot place this test in a case branch above for the types
* QMetaType::VoidStar, QMetaType::QObjectStar and so forth, is that it wouldn't include
* user defined pointer types. */
const char *const typeName = QMetaType::typeName(a->type);
if (typeName[qstrlen(typeName) - 1] == '*')
- return *static_cast<void **>(a->data.shared->ptr) ==
- *static_cast<void **>(b->data.shared->ptr);
+ return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr);
- return a->data.shared->ptr == b->data.shared->ptr;
+ return a_ptr == b_ptr;
}
/*!
@@ -1398,7 +1376,7 @@ void QVariant::create(int type, const void *copy)
QVariant::~QVariant()
{
- if (d.type > Char && d.type != QMetaType::Float && d.type != QMetaType::QObjectStar && (!d.is_shared || !d.data.shared->ref.deref()))
+ if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char && d.type < UserType))
handler->clear(&d);
}
@@ -1414,7 +1392,7 @@ QVariant::QVariant(const QVariant &p)
{
if (d.is_shared) {
d.data.shared->ref.ref();
- } else if (p.d.type > Char && p.d.type != QMetaType::Float && p.d.type != QMetaType::QObjectStar) {
+ } else if (p.d.type > Char && p.d.type < QVariant::UserType) {
handler->construct(&d, p.constData());
d.is_null = p.d.is_null;
}
@@ -1654,6 +1632,22 @@ QVariant::QVariant(Type type)
{ create(type, 0); }
QVariant::QVariant(int typeOrUserType, const void *copy)
{ create(typeOrUserType, copy); d.is_null = false; }
+
+/*! \internal
+ flags is true if it is a pointer type
+ */
+QVariant::QVariant(int typeOrUserType, const void *copy, uint flags)
+{
+ if (flags) { //type is a pointer type
+ d.type = typeOrUserType;
+ d.data.ptr = *reinterpret_cast<void *const*>(copy);
+ d.is_null = false;
+ } else {
+ create(typeOrUserType, copy);
+ d.is_null = false;
+ }
+}
+
QVariant::QVariant(int val)
{ d.is_null = false; d.type = Int; d.data.i = val; }
QVariant::QVariant(uint val)
@@ -1770,7 +1764,7 @@ QVariant& QVariant::operator=(const QVariant &variant)
if (variant.d.is_shared) {
variant.d.data.shared->ref.ref();
d = variant.d;
- } else if (variant.d.type > Char && variant.d.type != QMetaType::Float && variant.d.type != QMetaType::QObjectStar) {
+ } else if (variant.d.type > Char && variant.d.type < UserType) {
d.type = variant.d.type;
handler->construct(&d, variant.constData());
d.is_null = variant.d.is_null;
@@ -1824,7 +1818,7 @@ const char *QVariant::typeName() const
*/
void QVariant::clear()
{
- if (!d.is_shared || !d.data.shared->ref.deref())
+ if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type < UserType && d.type > Char))
handler->clear(&d);
d.type = Invalid;
d.is_null = true;
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index d6a704e..97af54b 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -174,6 +174,7 @@ class Q_CORE_EXPORT QVariant
~QVariant();
QVariant(Type type);
QVariant(int typeOrUserType, const void *copy);
+ QVariant(int typeOrUserType, const void *copy, uint flags);
QVariant(const QVariant &other);
#ifndef QT_NO_DATASTREAM
@@ -445,7 +446,7 @@ inline bool qvariant_cast_helper(const QVariant &v, QVariant::Type tp, void *ptr
template <typename T>
inline QVariant qVariantFromValue(const T &t)
{
- return QVariant(qMetaTypeId<T>(reinterpret_cast<T *>(0)), &t);
+ return QVariant(qMetaTypeId<T>(reinterpret_cast<T *>(0)), &t, QTypeInfo<T>::isPointer);
}
template <>
@@ -464,7 +465,7 @@ inline void qVariantSetValue(QVariant &v, const T &t)
old->~T();
new (old) T(t); //call the copy constructor
} else {
- v = QVariant(type, &t);
+ v = QVariant(type, &t, QTypeInfo<T>::isPointer);
}
}