diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-24 20:20:56 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-24 20:20:56 (GMT) |
commit | e4002434bfde5c8206463ea3a0d4140835619944 (patch) | |
tree | f199a1e233867ab4e85d22aa138391585af75fca /src/corelib | |
parent | 3f183debfd677b952b015f6950131dd25bd4768b (diff) | |
parent | 5a7c14af3c27089b0b8698da3c689637ffaa9cfa (diff) | |
download | Qt-e4002434bfde5c8206463ea3a0d4140835619944.zip Qt-e4002434bfde5c8206463ea3a0d4140835619944.tar.gz Qt-e4002434bfde5c8206463ea3a0d4140835619944.tar.bz2 |
Merge branch '4.6'
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qglobal.h | 15 | ||||
-rw-r--r-- | src/corelib/global/qt_windows.h | 7 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 31 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_symbian_p.h | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_symbian.cpp | 1 | ||||
-rw-r--r-- | src/corelib/thread/qthread_win.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qlist.cpp | 53 | ||||
-rw-r--r-- | src/corelib/tools/qlist.h | 11 | ||||
-rw-r--r-- | src/corelib/tools/qscopedpointer.h | 9 |
9 files changed, 110 insertions, 27 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7dbbc1b..d22a863 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -265,6 +265,15 @@ namespace QT_NAMESPACE {} # define Q_OS_WIN #endif +#if defined(Q_OS_WIN32) +# ifndef WINVER +# define WINVER 0x0500 +# endif +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0500 +# endif +#endif + #if defined(Q_OS_DARWIN) # define Q_OS_MAC /* Q_OS_MAC is mostly for compatibility, but also more clear */ # define Q_OS_MACX /* Q_OS_MACX is only for compatibility.*/ @@ -1325,6 +1334,12 @@ class QDataStream; # else # define Q_GUI_EXPORT_INLINE inline # endif +#elif defined(Q_CC_RVCT) +// we force RVCT not to export inlines by passing --visibility_inlines_hidden +// so we need to just inline it, rather than exporting and inlining +// note: this affects the contents of the DEF files (ie. these functions do not appear) +# define Q_CORE_EXPORT_INLINE inline +# define Q_GUI_EXPORT_INLINE inline #else # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h index dd722f9..6e3f242 100644 --- a/src/corelib/global/qt_windows.h +++ b/src/corelib/global/qt_windows.h @@ -53,13 +53,6 @@ #endif #endif -#if defined(Q_CC_MINGW) -// mingw's windows.h does not set _WIN32_WINNT, resulting breaking compilation -#ifndef WINVER -#define WINVER 0x500 -#endif -#endif - #include <windows.h> #ifdef _WIN32_WCE diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index cfa0a49..a8de17b 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -117,9 +117,12 @@ typedef struct _REPARSE_DATA_BUFFER { } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; # define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer) -#ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE -# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384 -#endif +# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE +# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384 +# endif +# ifndef IO_REPARSE_TAG_SYMLINK +# define IO_REPARSE_TAG_SYMLINK (0xA000000CL) +# endif #endif QT_BEGIN_NAMESPACE @@ -455,6 +458,9 @@ bool QFSFileEnginePrivate::nativeClose() q->setError(QFile::UnspecifiedError, qt_error_string()); ok = false; } +#ifdef Q_USE_DEPRECATED_MAP_API + fileMapHandle = INVALID_HANDLE_VALUE; +#endif fileHandle = INVALID_HANDLE_VALUE; cachedFd = -1; // gets closed by CloseHandle above @@ -1252,7 +1258,7 @@ bool QFSFileEnginePrivate::doStat() const static QString readSymLink(const QString &link) { QString result; -#if !defined(Q_OS_WINCE) && defined(FSCTL_GET_REPARSE_POINT) && defined(IO_REPARSE_TAG_MOUNT_POINT) +#if !defined(Q_OS_WINCE) HANDLE handle = CreateFile((wchar_t*)QFSFileEnginePrivate::longFileName(link).utf16(), FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, @@ -1513,7 +1519,7 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions() const */ bool QFSFileEnginePrivate::isSymlink() const { -#if !defined(Q_OS_WINCE) && defined(IO_REPARSE_TAG_SYMLINK) +#if !defined(Q_OS_WINCE) if (need_lstat) { need_lstat = false; is_link = false; @@ -1924,10 +1930,11 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, #ifndef Q_OS_WINCE if (handle == INVALID_HANDLE_VALUE && fh) handle = (HANDLE)_get_osfhandle(QT_FILENO(fh)); -#else - #ifdef Q_USE_DEPRECATED_MAP_API - nativeClose(); +#endif + +#ifdef Q_USE_DEPRECATED_MAP_API if (fileMapHandle == INVALID_HANDLE_VALUE) { + nativeClose(); fileMapHandle = CreateFileForMapping((const wchar_t*)nativeFilePath.constData(), GENERIC_READ | (openMode & QIODevice::WriteOnly ? GENERIC_WRITE : 0), 0, @@ -1937,11 +1944,13 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, NULL); } handle = fileMapHandle; - #endif - if (handle == INVALID_HANDLE_VALUE && fh) - return 0; #endif + if (handle == INVALID_HANDLE_VALUE) { + q->setError(QFile::UnspecifiedError, QLatin1String("No handle on file")); + return 0; + } + // first create the file mapping handle DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY; HANDLE mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0); diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h index 2a81b99..fab7254 100644 --- a/src/corelib/kernel/qcore_symbian_p.h +++ b/src/corelib/kernel/qcore_symbian_p.h @@ -94,6 +94,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/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 881e546..daeb0e1 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -238,7 +238,6 @@ void QTimerActiveObject::Run() if (m_timerInfo->interval > 0) { // Start a new timer immediately so that we don't lose time. - iStatus = KRequestPending; SetActive(); m_rTimer.After(iStatus, m_timerInfo->interval*1000); diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 12ee413..82b462e 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -39,10 +39,6 @@ ** ****************************************************************************/ -//#define WINVER 0x0500 -#define _WIN32_WINNT 0x0400 - - #include "qthread.h" #include "qthread_p.h" #include "qthreadstorage.h" diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 58406b9..1335c30 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -94,16 +94,49 @@ QListData::Data *QListData::detach() /*! * Detaches the QListData by reallocating new memory. * Returns the old (shared) data, it is up to the caller to deref() and free() + * For the new data node_copy needs to be called. * * \internal */ +#if QT_VERSION >= 0x050000 +# error "Remove QListData::detach2(), it is only required for binary compatibility for 4.3.x to 4.5.x" +#endif QListData::Data *QListData::detach2() { Data *x = d; Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + x->alloc * sizeof(void *))); Q_CHECK_PTR(t); - ::memcpy(t, x, DataHeaderSize + x->alloc * sizeof(void *)); + ::memcpy(t, d, DataHeaderSize + d->alloc * sizeof(void *)); + + t->ref = 1; + t->sharable = true; + t->alloc = x->alloc; + if (!t->alloc) { + t->begin = 0; + t->end = 0; + } else { + t->begin = x->begin; + t->end = x->end; + } + d = t; + + return x; +} + +/*! + * Detaches the QListData by reallocating new memory. + * Returns the old (shared) data, it is up to the caller to deref() and free() + * For the new data node_copy needs to be called. + * + * \internal + */ +QListData::Data *QListData::detach3() +{ + Data *x = d; + Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + x->alloc * sizeof(void *))); + Q_CHECK_PTR(t); + t->ref = 1; t->sharable = true; t->alloc = x->alloc; @@ -150,6 +183,9 @@ void **QListData::append() } // ensures that enough space is available to append the list +#if QT_VERSION >= 0x050000 +# error "Remove QListData::append(), it is only required for binary compatibility up to 4.5.x" +#endif void **QListData::append(const QListData& l) { Q_ASSERT(d->ref == 1); @@ -158,6 +194,21 @@ void **QListData::append(const QListData& l) if (n) { if (e + n > d->alloc) realloc(grow(e + l.d->end - l.d->begin)); + ::memcpy(d->array + d->end, l.d->array + l.d->begin, n*sizeof(void*)); + d->end += n; + } + return d->array + e; +} + +// ensures that enough space is available to append the list +void **QListData::append2(const QListData& l) +{ + Q_ASSERT(d->ref == 1); + int e = d->end; + int n = l.d->end - l.d->begin; + if (n) { + if (e + n > d->alloc) + realloc(grow(e + l.d->end - l.d->begin)); d->end += n; } return d->array + e; diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 5fa0f6c..331f448 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -72,13 +72,15 @@ struct Q_CORE_EXPORT QListData { enum { DataHeaderSize = sizeof(Data) - sizeof(void *) }; Data *detach(); // remove in 5.0 - Data *detach2(); + Data *detach2(); // remove in 5.0 + Data *detach3(); void realloc(int alloc); static Data shared_null; Data *d; void **erase(void **xi); void **append(); void **append(const QListData &l); + void **append2(const QListData &l); // remove in 5.0 void **prepend(); void **insert(int i); void remove(int i); @@ -381,6 +383,9 @@ Q_INLINE_TEMPLATE void QList<T>::node_copy(Node *from, Node *to, Node *src) (reinterpret_cast<T*>(current--))->~T(); QT_RETHROW; } + } else { + if (src != from && to - from > 0) + memcpy(from, src, (to - from) * sizeof(Node *)); } } @@ -590,7 +595,7 @@ template <typename T> Q_OUTOFLINE_TEMPLATE void QList<T>::detach_helper() { Node *n = reinterpret_cast<Node *>(p.begin()); - QListData::Data *x = p.detach2(); + QListData::Data *x = p.detach3(); QT_TRY { node_copy(reinterpret_cast<Node *>(p.begin()), reinterpret_cast<Node *>(p.end()), n); } QT_CATCH(...) { @@ -690,7 +695,7 @@ template <typename T> Q_OUTOFLINE_TEMPLATE QList<T> &QList<T>::operator+=(const QList<T> &l) { detach(); - Node *n = reinterpret_cast<Node *>(p.append(l.p)); + Node *n = reinterpret_cast<Node *>(p.append2(l.p)); QT_TRY{ node_copy(n, reinterpret_cast<Node *>(p.end()), reinterpret_cast<Node *>(l.p.begin())); } QT_CATCH(...) { diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 7a3ee14..f801366 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -166,6 +166,11 @@ public: return oldD; } + inline void swap(QScopedPointer<T, Cleanup> &other) + { + qSwap(d, other.d); + } + typedef T *pointer; protected: @@ -175,6 +180,10 @@ private: Q_DISABLE_COPY(QScopedPointer) }; +template <class T, class Cleanup> +Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) +{ p1.swap(p2); } + template <typename T, typename Cleanup = QScopedPointerArrayDeleter<T> > class QScopedArrayPointer : public QScopedPointer<T, Cleanup> { |