summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qdir.cpp10
-rw-r--r--src/corelib/io/qfile.cpp7
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp46
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian.cpp10
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian_p.h18
-rw-r--r--src/corelib/io/qiodevice.cpp6
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp18
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp81
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h3
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp26
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp21
-rw-r--r--src/corelib/kernel/qobject.cpp5
-rw-r--r--src/corelib/kernel/qpointer.cpp2
-rw-r--r--src/corelib/kernel/qtranslator.cpp40
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp239
-rw-r--r--src/corelib/plugin/qfactoryloader_p.h1
-rw-r--r--src/corelib/plugin/qpluginloader.cpp2
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp15
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h9
-rw-r--r--src/corelib/thread/qmutex_p.h8
-rw-r--r--src/corelib/thread/qmutex_unix.cpp50
-rw-r--r--src/corelib/tools/qelapsedtimer_win.cpp14
-rw-r--r--src/corelib/tools/qline.cpp30
-rw-r--r--src/corelib/tools/qlist.cpp4
24 files changed, 427 insertions, 238 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 4ba8e06..48b9358 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1872,7 +1872,10 @@ QString QDir::currentPath()
Under non-Windows operating systems the \c HOME environment
variable is used if it exists, otherwise the path returned by the
- rootPath(). On Symbian always the same as the path returned by the rootPath().
+ rootPath().
+
+ On Symbian this typically returns "c:/data",
+ i.e. the same as native PathInfo::PhoneMemoryRootPath().
\sa home(), currentPath(), rootPath(), tempPath()
*/
@@ -1936,9 +1939,8 @@ QString QDir::tempPath()
/*!
Returns the absolute path of the root directory.
- For Unix operating systems this returns "/". For Windows file
- systems this normally returns "c:/". On Symbian this typically returns
- "c:/data", i.e. the same as native PathInfo::PhoneMemoryRootPath().
+ For Unix operating systems this returns "/". For Windows and Symbian file
+ systems this normally returns "c:/". I.E. the root of the system drive.
\sa root(), drives(), currentPath(), homePath(), tempPath()
*/
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 6f24376..cdee7ce 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -1335,6 +1335,13 @@ bool QFile::open(const RFile &f, OpenMode mode, FileHandleFlags handleFlags)
This function is not supported on Windows CE.
+ On Symbian, this function returns -1 if the file was opened normally,
+ as Symbian OS native file handles do not fit in an int, and are
+ incompatible with C library functions that the handle would be used for.
+ If the file was opened using the overloads that take an open C library
+ file handle / file descriptor, then this function returns that same
+ handle.
+
\sa QSocketNotifier
*/
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 98404a5..86b9496 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -186,14 +186,13 @@ static void resolveLibs()
}
#endif
- triedResolve = true;
#if !defined(Q_OS_WINCE)
- HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32");
- if (advapiHnd) {
- ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW");
- ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW");
- ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW");
- ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW");
+ QSystemLibrary advapi32(QLatin1String("advapi32"));
+ if (advapi32.load()) {
+ ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)advapi32.resolve("GetNamedSecurityInfoW");
+ ptrLookupAccountSidW = (PtrLookupAccountSidW)advapi32.resolve("LookupAccountSidW");
+ ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)advapi32.resolve("BuildTrusteeWithSidW");
+ ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)advapi32.resolve("GetEffectiveRightsFromAclW");
}
if (ptrBuildTrusteeWithSidW) {
// Create TRUSTEE for current user
@@ -208,9 +207,9 @@ static void resolveLibs()
}
typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
- PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid");
+ PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)advapi32.resolve("AllocateAndInitializeSid");
typedef PVOID (WINAPI *PtrFreeSid)(PSID);
- PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid");
+ PtrFreeSid ptrFreeSid = (PtrFreeSid)advapi32.resolve("FreeSid");
if (ptrAllocateAndInitializeSid && ptrFreeSid) {
// Create TRUSTEE for Everyone (World)
SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY };
@@ -220,13 +219,16 @@ static void resolveLibs()
ptrFreeSid(pWorld);
}
}
- HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
- if (userenvHnd)
- ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
- HINSTANCE kernel32 = LoadLibrary(L"kernel32");
- if(kernel32)
- ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW");
+
+ QSystemLibrary userenv(QLatin1String("userenv"));
+ if (userenv.load())
+ ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)userenv.resolve("GetUserProfileDirectoryW");
+
+ QSystemLibrary kernel32(QLatin1String("kernel32"));
+ if (kernel32.load())
+ ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)kernel32.resolve("GetVolumePathNamesForVolumeNameW");
#endif
+ triedResolve = true;
}
}
#endif // QT_NO_LIBRARY
@@ -252,15 +254,15 @@ static bool resolveUNCLibs()
return ptrNetShareEnum && ptrNetApiBufferFree;
}
#endif
- triedResolve = true;
+
#if !defined(Q_OS_WINCE)
- HINSTANCE hLib = QSystemLibrary::load(L"Netapi32");
- if (hLib) {
- ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum");
- if (ptrNetShareEnum)
- ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree");
+ QSystemLibrary netapi32(QLatin1String("Netapi32"));
+ if (netapi32.load()) {
+ ptrNetShareEnum = (PtrNetShareEnum)netapi32.resolve("NetShareEnum");
+ ptrNetApiBufferFree = (PtrNetApiBufferFree)netapi32.resolve("NetApiBufferFree");
}
#endif
+ triedResolve = true;
}
return ptrNetShareEnum && ptrNetApiBufferFree;
}
@@ -692,7 +694,7 @@ bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSyst
if (what & QFileSystemMetaData::UserWritePermission) {
if (::_waccess((wchar_t*)entry.nativeFilePath().utf16(), W_OK) == 0)
data.entryFlags |= QFileSystemMetaData::UserWritePermission;
- data.knownFlagsMask |= QFileSystemMetaData::UserReadPermission;
+ data.knownFlagsMask |= QFileSystemMetaData::UserWritePermission;
}
}
diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp
index 63cc4f1..fa857c6 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian.cpp
+++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
QNotifyChangeEvent::QNotifyChangeEvent(RFs &fs, const TDesC &file,
- QSymbianFileSystemWatcherEngine *e, bool aIsDir,
+ QSymbianFileSystemWatcherInterface *e, bool aIsDir,
TInt aPriority) :
CActive(aPriority),
isDir(aIsDir),
@@ -96,9 +96,9 @@ void QNotifyChangeEvent::RunL()
if (!failureCount) {
int err;
- QT_TRYCATCH_ERROR(err, engine->emitPathChanged(this));
+ QT_TRYCATCH_ERROR(err, engine->handlePathChanged(this));
if (err != KErrNone)
- qWarning("QNotifyChangeEvent::RunL() - emitPathChanged threw exception (Converted error code: %d)", err);
+ qWarning("QNotifyChangeEvent::RunL() - handlePathChanged threw exception (Converted error code: %d)", err);
}
}
}
@@ -203,7 +203,7 @@ QStringList QSymbianFileSystemWatcherEngine::removePaths(const QStringList &path
return p;
}
-void QSymbianFileSystemWatcherEngine::emitPathChanged(QNotifyChangeEvent *e)
+void QSymbianFileSystemWatcherEngine::handlePathChanged(QNotifyChangeEvent *e)
{
QMutexLocker locker(&mutex);
@@ -255,7 +255,7 @@ void QSymbianFileSystemWatcherEngine::addNativeListener(const QString &directory
QMutexLocker locker(&mutex);
QString nativeDir(QDir::toNativeSeparators(directoryPath));
TPtrC ptr(qt_QString2TPtrC(nativeDir));
- currentAddEvent = new QNotifyChangeEvent(qt_s60GetRFs(), ptr, this, directoryPath.endsWith(QChar(L'/'), Qt::CaseSensitive));
+ currentAddEvent = q_check_ptr(new QNotifyChangeEvent(qt_s60GetRFs(), ptr, this, directoryPath.endsWith(QChar(L'/'))));
syncCondition.wakeOne();
}
diff --git a/src/corelib/io/qfilesystemwatcher_symbian_p.h b/src/corelib/io/qfilesystemwatcher_symbian_p.h
index 0b317a0..842df80 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian_p.h
+++ b/src/corelib/io/qfilesystemwatcher_symbian_p.h
@@ -66,29 +66,35 @@
QT_BEGIN_NAMESPACE
-class QSymbianFileSystemWatcherEngine;
+class QSymbianFileSystemWatcherInterface;
class QNotifyChangeEvent : public CActive
{
public:
- QNotifyChangeEvent(RFs &fsSession, const TDesC &file, QSymbianFileSystemWatcherEngine *engine,
+ QNotifyChangeEvent(RFs &fsSession, const TDesC &file, QSymbianFileSystemWatcherInterface *engine,
bool aIsDir, TInt aPriority = EPriorityStandard);
~QNotifyChangeEvent();
bool isDir;
+ TPath watchedPath;
private:
void RunL();
void DoCancel();
RFs &fsSession;
- TPath watchedPath;
- QSymbianFileSystemWatcherEngine *engine;
+ QSymbianFileSystemWatcherInterface *engine;
int failureCount;
};
-class QSymbianFileSystemWatcherEngine : public QFileSystemWatcherEngine
+class QSymbianFileSystemWatcherInterface
+{
+public:
+ virtual void handlePathChanged(QNotifyChangeEvent *e) = 0;
+};
+
+class QSymbianFileSystemWatcherEngine : public QFileSystemWatcherEngine, public QSymbianFileSystemWatcherInterface
{
Q_OBJECT
@@ -111,7 +117,7 @@ public Q_SLOTS:
private:
friend class QNotifyChangeEvent;
- void emitPathChanged(QNotifyChangeEvent *e);
+ void handlePathChanged(QNotifyChangeEvent *e);
void startWatcher();
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index dae4e82..56fff90 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -468,11 +468,17 @@ void QIODevice::setOpenMode(OpenMode openMode)
otherwise the \l Text flag is removed. This feature is useful for classes
that provide custom end-of-line handling on a QIODevice.
+ The IO device should be opened before calling this function.
+
\sa open(), setOpenMode()
*/
void QIODevice::setTextModeEnabled(bool enabled)
{
Q_D(QIODevice);
+ if (!isOpen()) {
+ qWarning("QIODevice::setTextModeEnabled: The device is not open");
+ return;
+ }
if (enabled)
d->openMode |= Text;
else
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp
index 04acfb0..4f953a7 100644
--- a/src/corelib/kernel/qcore_symbian_p.cpp
+++ b/src/corelib/kernel/qcore_symbian_p.cpp
@@ -45,6 +45,7 @@
#include "qcore_symbian_p.h"
#include <string>
#include <in_sock.h>
+#include "qdebug.h"
QT_BEGIN_NAMESPACE
@@ -115,6 +116,23 @@ public:
QS60RFsSession() {
qt_symbian_throwIfError(iFs.Connect());
qt_symbian_throwIfError(iFs.ShareProtected());
+ //BC with 4.7: create private path on system drive
+ TInt sysdrive = iFs.GetSystemDrive();
+ TInt err = iFs.CreatePrivatePath(sysdrive);
+ if (err != KErrNone && err != KErrAlreadyExists)
+ qWarning("Failed to create private path on system drive.");
+ TFileName pfn = RProcess().FileName();
+ TInt drive;
+ if (pfn.Length() > 0 && iFs.CharToDrive(pfn[0], drive) == KErrNone) {
+ //BC with 4.7: create private path on application drive (except rom or system drive which is done above)
+ if (drive != sysdrive && drive != EDriveZ) {
+ err = iFs.CreatePrivatePath(drive);
+ if (err != KErrNone && err != KErrAlreadyExists)
+ qWarning("Failed to create private path on application drive.");
+ }
+ //BC with 4.7: set working directory to same drive as application
+ iFs.SetSessionToPrivate(drive);
+ }
}
~QS60RFsSession() {
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 752bbaa..2eb68f7 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1991,12 +1991,6 @@ QString QCoreApplication::applicationDirPath()
appPath = qt_TDesC2QString(privatePath);
appPath.prepend(QLatin1Char(':')).prepend(qDriveChar);
- // Create the appPath if it doesn't exist. Non-existing appPath will cause
- // Platform Security violations later on if the app doesn't have AllFiles capability.
- err = fs.CreatePrivatePath(drive);
- if (err != KErrNone)
- qWarning("QCoreApplication::applicationDirPath: Failed to create private path.");
-
d->cachedApplicationDirPath = QFileInfo(appPath).path();
}
#else
@@ -2335,6 +2329,33 @@ QString QCoreApplication::applicationVersion()
#ifndef QT_NO_LIBRARY
+#if defined(Q_OS_SYMBIAN)
+void qt_symbian_installLibraryPaths(QString installPathPlugins, QStringList& libPaths)
+{
+ // Add existing path on all drives for relative PluginsPath in Symbian
+ QString tempPath = installPathPlugins;
+ if (tempPath.at(tempPath.length() - 1) != QDir::separator()) {
+ tempPath += QDir::separator();
+ }
+ RFs& fs = qt_s60GetRFs();
+ TPtrC tempPathPtr(reinterpret_cast<const TText*> (tempPath.constData()));
+ // Symbian searches should start from Y:. Fix start drive otherwise TFindFile starts from the session drive
+ _LIT(KStartDir, "Y:");
+ TFileName dirPath(KStartDir);
+ dirPath.Append(tempPathPtr);
+ TFindFile finder(fs);
+ TInt err = finder.FindByDir(tempPathPtr, dirPath);
+ while (err == KErrNone) {
+ QString foundDir(reinterpret_cast<const QChar *>(finder.File().Ptr()),
+ finder.File().Length());
+ foundDir = QDir(foundDir).canonicalPath();
+ if (!libPaths.contains(foundDir))
+ libPaths.append(foundDir);
+ err = finder.Find();
+ }
+}
+#endif
+
Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive))
/*!
@@ -2367,24 +2388,8 @@ QStringList QCoreApplication::libraryPaths()
QStringList *app_libpaths = coreappdata()->app_libpaths = new QStringList;
QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
#if defined(Q_OS_SYMBIAN)
- // Add existing path on all drives for relative PluginsPath in Symbian
if (installPathPlugins.at(1) != QChar(QLatin1Char(':'))) {
- QString tempPath = installPathPlugins;
- if (tempPath.at(tempPath.length() - 1) != QDir::separator()) {
- tempPath += QDir::separator();
- }
- RFs& fs = qt_s60GetRFs();
- TPtrC tempPathPtr(reinterpret_cast<const TText*> (tempPath.constData()));
- TFindFile finder(fs);
- TInt err = finder.FindByDir(tempPathPtr, tempPathPtr);
- while (err == KErrNone) {
- QString foundDir(reinterpret_cast<const QChar *>(finder.File().Ptr()),
- finder.File().Length());
- foundDir = QDir(foundDir).canonicalPath();
- if (!app_libpaths->contains(foundDir))
- app_libpaths->append(foundDir);
- err = finder.Find();
- }
+ qt_symbian_installLibraryPaths(installPathPlugins, *app_libpaths);
}
#else
if (QFile::exists(installPathPlugins)) {
@@ -2499,6 +2504,36 @@ void QCoreApplication::removeLibraryPath(const QString &path)
QFactoryLoader::refreshAll();
}
+#if defined(Q_OS_SYMBIAN)
+void QCoreApplicationPrivate::rebuildInstallLibraryPaths()
+{
+ // check there is not a single fixed install path
+ QString nativeInstallPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
+ if (nativeInstallPathPlugins.at(1) == QChar(QLatin1Char(':')))
+ return;
+ QString installPathPlugins = QDir::cleanPath(nativeInstallPathPlugins);
+ // look for the install path at the drive roots
+ installPathPlugins.prepend(QChar(QLatin1Char(':')));
+
+ QMutexLocker locker(libraryPathMutex());
+ QStringList &app_libpaths = *coreappdata()->app_libpaths;
+ // Build a new library path, copying non-installPath components, and replacing existing install path with new
+ QStringList newPaths;
+ bool installPathFound = false;
+ foreach (QString path, app_libpaths) {
+ if (path.mid(1).compare(installPathPlugins, Qt::CaseInsensitive) == 0) {
+ // skip existing install paths, insert new install path when we find the first
+ if (!installPathFound)
+ qt_symbian_installLibraryPaths(nativeInstallPathPlugins, newPaths);
+ installPathFound = true;
+ } else {
+ newPaths.append(path);
+ }
+ }
+ app_libpaths = newPaths;
+}
+#endif
+
#endif //QT_NO_LIBRARY
/*!
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index c6c6489..6f75da3 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -126,6 +126,9 @@ public:
void symbianInit();
# endif
static CApaCommandLine* symbianCommandLine();
+#ifndef QT_NO_LIBRARY
+ static void rebuildInstallLibraryPaths();
+#endif
#endif
static bool isTranslatorInstalled(QTranslator *translator);
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index b216075..fca2feb 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -60,6 +60,24 @@ QT_BEGIN_NAMESPACE
#define WAKE_UP_PRIORITY CActive::EPriorityStandard
#define TIMER_PRIORITY CActive::EPriorityHigh
+class Incrementer {
+ int &variable;
+public:
+ inline Incrementer(int &variable) : variable(variable)
+ { ++variable; }
+ inline ~Incrementer()
+ { --variable; }
+};
+
+class Decrementer {
+ int &variable;
+public:
+ inline Decrementer(int &variable) : variable(variable)
+ { --variable; }
+ inline ~Decrementer()
+ { ++variable; }
+};
+
static inline int qt_pipe_write(int socket, const char *data, qint64 len)
{
return ::write(socket, data, len);
@@ -951,6 +969,8 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
#endif
while (1) {
+ //native active object callbacks are logically part of the event loop, so inc nesting level
+ Incrementer inc(d->threadData->loopLevel);
if (block) {
// This is where Qt will spend most of its time.
CActiveScheduler::Current()->WaitForAnyRequest();
@@ -1045,6 +1065,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
void QEventDispatcherSymbian::timerFired(int timerId)
{
+ Q_D(QAbstractEventDispatcher);
QHash<int, SymbianTimerInfoPtr>::iterator i = m_timerList.find(timerId);
if (i == m_timerList.end()) {
// The timer has been deleted. Ignore this event.
@@ -1063,6 +1084,8 @@ void QEventDispatcherSymbian::timerFired(int timerId)
m_insideTimerEvent = true;
QTimerEvent event(timerInfo->timerId);
+ //undo the added nesting level around RunIfReady, since Qt's event system also nests
+ Decrementer dec(d->threadData->loopLevel);
QCoreApplication::sendEvent(timerInfo->receiver, &event);
m_insideTimerEvent = oldInsideTimerEventValue;
@@ -1073,6 +1096,7 @@ void QEventDispatcherSymbian::timerFired(int timerId)
void QEventDispatcherSymbian::wakeUpWasCalled()
{
+ Q_D(QAbstractEventDispatcher);
// The reactivation should happen in RunL, right before the call to this function.
// This is because m_wakeUpDone is the "signal" that the object can be completed
// once more.
@@ -1082,6 +1106,8 @@ void QEventDispatcherSymbian::wakeUpWasCalled()
// the sendPostedEvents was done, but before the object was ready to be completed
// again. This could deadlock the application if there are no other posted events.
m_wakeUpDone.fetchAndStoreOrdered(0);
+ //undo the added nesting level around RunIfReady, since Qt's event system also nests
+ Decrementer dec(d->threadData->loopLevel);
sendPostedEvents();
}
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 84663fa..c135c4a 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -53,7 +53,6 @@
#include "qabstracteventdispatcher_p.h"
#include "qcoreapplication_p.h"
#include <private/qthread_p.h>
-#include <private/qmutexpool_p.h>
QT_BEGIN_NAMESPACE
@@ -322,19 +321,17 @@ static void resolveTimerAPI()
{
static bool triedResolve = false;
if (!triedResolve) {
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
- if (triedResolve)
- return;
-#endif
- triedResolve = true;
-#if !defined(Q_OS_WINCE)
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
+#ifndef Q_OS_WINCE
+ QSystemLibrary library(QLatin1String("Mmtimer"));
#else
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent");
+ QSystemLibrary library(QLatin1String("winmm"));
#endif
+ if (library.load()) {
+ qtimeSetEvent = (ptimeSetEvent)library.resolve("timeSetEvent");
+ qtimeKillEvent = (ptimeKillEvent)library.resolve("timeKillEvent");
+ }
+
+ triedResolve = true;
}
}
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 5d6e4d7..1f716bc 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -163,14 +163,15 @@ QObjectPrivate::~QObjectPrivate()
{
if (pendTimer) {
// unregister pending timers
- if (threadData->eventDispatcher)
+ if (threadData && threadData->eventDispatcher)
threadData->eventDispatcher->unregisterTimers(q_ptr);
}
if (postedEvents)
QCoreApplication::removePostedEvents(q_ptr, 0);
- threadData->deref();
+ if (threadData)
+ threadData->deref();
delete static_cast<QAbstractDynamicMetaObject*>(metaObject);
#ifdef QT_JAMBI_BUILD
diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp
index c7fcf4f..87e903f 100644
--- a/src/corelib/kernel/qpointer.cpp
+++ b/src/corelib/kernel/qpointer.cpp
@@ -97,7 +97,7 @@
Note that class \c T must inherit QObject, or a compilation or
link error will result.
- \sa QSharedPointer, QObject, QObjectCleanupHandler
+ \sa QSharedPointer, QWeakPointer, QObject, QObjectCleanupHandler
*/
/*!
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index d255422..dfc90e8 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -51,6 +51,7 @@
#include "qcoreapplication.h"
#include "qcoreapplication_p.h"
#include "qdatastream.h"
+#include "qdir.h"
#include "qfile.h"
#include "qmap.h"
#include "qalgorithms.h"
@@ -63,6 +64,10 @@
#include "private/qcore_unix_p.h"
#endif
+#ifdef Q_OS_SYMBIAN
+#include "private/qcore_symbian_p.h"
+#endif
+
// most of the headers below are already included in qplatformdefs.h
// also this lacks Large File support but that's probably irrelevant
#if defined(QT_USE_MMAP)
@@ -405,11 +410,24 @@ bool QTranslator::load(const QString & filename, const QString & directory,
QString prefix;
if (QFileInfo(filename).isRelative()) {
+#ifdef Q_OS_SYMBIAN
+ if (directory.isEmpty())
+ prefix = QCoreApplication::applicationDirPath();
+ else
+ prefix = QFileInfo(directory).absoluteFilePath(); //TFindFile doesn't like dirty paths
+ if (prefix.length() > 2 && prefix.at(1) == QLatin1Char(':') && prefix.at(0).isLetter())
+ prefix[0] = QLatin1Char('Y');
+#else
prefix = directory;
- if (prefix.length() && !prefix.endsWith(QLatin1Char('/')))
- prefix += QLatin1Char('/');
+#endif
+ if (prefix.length() && !prefix.endsWith(QLatin1Char('/')))
+ prefix += QLatin1Char('/');
}
+#ifdef Q_OS_SYMBIAN
+ QString nativePrefix = QDir::toNativeSeparators(prefix);
+#endif
+
QString fname = filename;
QString realname;
QString delims;
@@ -418,6 +436,24 @@ bool QTranslator::load(const QString & filename, const QString & directory,
for (;;) {
QFileInfo fi;
+#ifdef Q_OS_SYMBIAN
+ //search for translations on other drives, e.g. Qt may be in Z, while app is in C
+ //note this uses symbian search rules, i.e. y:->a:, followed by z:
+ TFindFile finder(qt_s60GetRFs());
+ QString fname2 = fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
+ TInt err = finder.FindByDir(
+ qt_QString2TPtrC(fname2),
+ qt_QString2TPtrC(nativePrefix));
+ if (err != KErrNone)
+ err = finder.FindByDir(qt_QString2TPtrC(fname), qt_QString2TPtrC(nativePrefix));
+ if (err == KErrNone) {
+ fi.setFile(qt_TDesC2QString(finder.File()));
+ realname = fi.canonicalFilePath();
+ if (fi.isReadable() && fi.isFile())
+ break;
+ }
+#endif
+
realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
fi.setFile(realname);
if (fi.isReadable() && fi.isFile())
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index c8831e5..24b4be0 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -50,8 +50,13 @@
#include "qmutex.h"
#include "qplugin.h"
#include "qpluginloader.h"
+#include "qlibraryinfo.h"
#include "private/qobject_p.h"
#include "private/qcoreapplication_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "private/qcore_symbian_p.h"
+#include "private/qfilesystemwatcher_symbian_p.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -59,6 +64,23 @@ Q_GLOBAL_STATIC(QList<QFactoryLoader *>, qt_factory_loaders)
Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_factoryloader_mutex, (QMutex::Recursive))
+#ifdef Q_OS_SYMBIAN
+class QSymbianSystemPluginWatcher : public QSymbianFileSystemWatcherInterface
+{
+public:
+ QSymbianSystemPluginWatcher();
+ ~QSymbianSystemPluginWatcher();
+
+ void watchForUpdates();
+ void handlePathChanged(QNotifyChangeEvent *e);
+
+ QList<QNotifyChangeEvent*> watchers;
+ TDriveList drives;
+};
+
+Q_GLOBAL_STATIC(QSymbianSystemPluginWatcher, qt_symbian_system_plugin_watcher)
+#endif
+
class QFactoryLoaderPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QFactoryLoader)
@@ -98,102 +120,117 @@ QFactoryLoader::QFactoryLoader(const char *iid,
QMutexLocker locker(qt_factoryloader_mutex());
update();
qt_factory_loaders()->append(this);
+#ifdef Q_OS_SYMBIAN
+ // kick off Symbian plugin watcher for updates
+ qt_symbian_system_plugin_watcher();
+#endif
}
-
-void QFactoryLoader::update()
+void QFactoryLoader::updateDir(const QString &pluginDir, QSettings& settings)
{
-#ifdef QT_SHARED
Q_D(QFactoryLoader);
- QStringList paths = QCoreApplication::libraryPaths();
- QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
- for (int i = 0; i < paths.count(); ++i) {
- const QString &pluginDir = paths.at(i);
- // Already loaded, skip it...
- if (d->loadedPaths.contains(pluginDir))
- continue;
- d->loadedPaths << pluginDir;
+ QString path = pluginDir + d->suffix;
+ if (!QDir(path).exists(QLatin1String(".")))
+ return;
- QString path = pluginDir + d->suffix;
- if (!QDir(path).exists(QLatin1String(".")))
- continue;
+ QStringList plugins = QDir(path).entryList(QDir::Files);
+ QLibraryPrivate *library = 0;
+ for (int j = 0; j < plugins.count(); ++j) {
+ QString fileName = QDir::cleanPath(path + QLatin1Char('/') + plugins.at(j));
- QStringList plugins = QDir(path).entryList(QDir::Files);
- QLibraryPrivate *library = 0;
- for (int j = 0; j < plugins.count(); ++j) {
- QString fileName = QDir::cleanPath(path + QLatin1Char('/') + plugins.at(j));
+ if (qt_debug_component()) {
+ qDebug() << "QFactoryLoader::QFactoryLoader() looking at" << fileName;
+ }
+ library = QLibraryPrivate::findOrCreate(QFileInfo(fileName).canonicalFilePath());
+ if (!library->isPlugin(&settings)) {
if (qt_debug_component()) {
- qDebug() << "QFactoryLoader::QFactoryLoader() looking at" << fileName;
+ qDebug() << library->errorString;
+ qDebug() << " not a plugin";
}
- library = QLibraryPrivate::findOrCreate(QFileInfo(fileName).canonicalFilePath());
- if (!library->isPlugin(&settings)) {
+ library->release();
+ continue;
+ }
+ QString regkey = QString::fromLatin1("Qt Factory Cache %1.%2/%3:/%4")
+ .arg((QT_VERSION & 0xff0000) >> 16)
+ .arg((QT_VERSION & 0xff00) >> 8)
+ .arg(QLatin1String(d->iid))
+ .arg(fileName);
+ QStringList reg, keys;
+ reg = settings.value(regkey).toStringList();
+ if (reg.count() && library->lastModified == reg[0]) {
+ keys = reg;
+ keys.removeFirst();
+ } else {
+ if (!library->loadPlugin()) {
if (qt_debug_component()) {
qDebug() << library->errorString;
- qDebug() << " not a plugin";
+ qDebug() << " could not load";
}
library->release();
continue;
}
- QString regkey = QString::fromLatin1("Qt Factory Cache %1.%2/%3:/%4")
- .arg((QT_VERSION & 0xff0000) >> 16)
- .arg((QT_VERSION & 0xff00) >> 8)
- .arg(QLatin1String(d->iid))
- .arg(fileName);
- QStringList reg, keys;
- reg = settings.value(regkey).toStringList();
- if (reg.count() && library->lastModified == reg[0]) {
- keys = reg;
- keys.removeFirst();
- } else {
- if (!library->loadPlugin()) {
- if (qt_debug_component()) {
- qDebug() << library->errorString;
- qDebug() << " could not load";
- }
- library->release();
- continue;
- }
- QObject *instance = library->instance();
- if (!instance) {
- library->release();
- // ignore plugins that have a valid signature but cannot be loaded.
- continue;
- }
- QFactoryInterface *factory = qobject_cast<QFactoryInterface*>(instance);
- if (instance && factory && instance->qt_metacast(d->iid))
- keys = factory->keys();
- if (keys.isEmpty())
- library->unload();
- reg.clear();
- reg << library->lastModified;
- reg += keys;
- settings.setValue(regkey, reg);
- }
- if (qt_debug_component()) {
- qDebug() << "keys" << keys;
- }
-
- if (keys.isEmpty()) {
+ QObject *instance = library->instance();
+ if (!instance) {
library->release();
+ // ignore plugins that have a valid signature but cannot be loaded.
continue;
}
- d->libraryList += library;
- for (int k = 0; k < keys.count(); ++k) {
- // first come first serve, unless the first
- // library was built with a future Qt version,
- // whereas the new one has a Qt version that fits
- // better
- QString key = keys.at(k);
- if (!d->cs)
- key = key.toLower();
- QLibraryPrivate *previous = d->keyMap.value(key);
- if (!previous || (previous->qt_version > QT_VERSION && library->qt_version <= QT_VERSION)) {
- d->keyMap[key] = library;
- d->keyList += keys.at(k);
- }
+ QFactoryInterface *factory = qobject_cast<QFactoryInterface*>(instance);
+ if (instance && factory && instance->qt_metacast(d->iid))
+ keys = factory->keys();
+ if (keys.isEmpty())
+ library->unload();
+ reg.clear();
+ reg << library->lastModified;
+ reg += keys;
+ settings.setValue(regkey, reg);
+ }
+ if (qt_debug_component()) {
+ qDebug() << "keys" << keys;
+ }
+
+ if (keys.isEmpty()) {
+ library->release();
+ continue;
+ }
+
+ int keysUsed = 0;
+ for (int k = 0; k < keys.count(); ++k) {
+ // first come first serve, unless the first
+ // library was built with a future Qt version,
+ // whereas the new one has a Qt version that fits
+ // better
+ QString key = keys.at(k);
+ if (!d->cs)
+ key = key.toLower();
+ QLibraryPrivate *previous = d->keyMap.value(key);
+ if (!previous || (previous->qt_version > QT_VERSION && library->qt_version <= QT_VERSION)) {
+ d->keyMap[key] = library;
+ d->keyList += keys.at(k);
+ keysUsed++;
}
}
+ if (keysUsed)
+ d->libraryList += library;
+ else
+ library->release();
+ }
+}
+
+void QFactoryLoader::update()
+{
+#ifdef QT_SHARED
+ Q_D(QFactoryLoader);
+ QStringList paths = QCoreApplication::libraryPaths();
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ for (int i = 0; i < paths.count(); ++i) {
+ const QString &pluginDir = paths.at(i);
+ // Already loaded, skip it...
+ if (d->loadedPaths.contains(pluginDir))
+ continue;
+ d->loadedPaths << pluginDir;
+ updateDir(pluginDir, settings);
}
#else
Q_D(QFactoryLoader);
@@ -264,6 +301,56 @@ void QFactoryLoader::refreshAll()
}
}
+#ifdef Q_OS_SYMBIAN
+QSymbianSystemPluginWatcher::QSymbianSystemPluginWatcher()
+{
+ qt_s60GetRFs().DriveList(drives);
+ watchForUpdates();
+}
+
+QSymbianSystemPluginWatcher::~QSymbianSystemPluginWatcher()
+{
+ qDeleteAll(watchers);
+}
+
+void QSymbianSystemPluginWatcher::watchForUpdates()
+{
+ QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
+ if (installPathPlugins.at(1) == QChar(QLatin1Char(':')))
+ return;
+
+ installPathPlugins.prepend(QLatin1String("?:"));
+ installPathPlugins = QDir::toNativeSeparators(installPathPlugins);
+ RFs& fs = qt_s60GetRFs();
+ for (int i=0; i<KMaxDrives; i++) {
+ int attr = drives[i];
+ if ((attr & KDriveAttLocal) && !(attr & KDriveAttRom)) {
+ // start new watcher
+ TChar driveLetter;
+ fs.DriveToChar(i, driveLetter);
+ installPathPlugins[0] = driveLetter;
+ TPtrC ptr(qt_QString2TPtrC(installPathPlugins));
+ QNotifyChangeEvent *event = q_check_ptr(new QNotifyChangeEvent(fs, ptr, this, true));
+ watchers.push_back(event);
+ }
+ }
+}
+
+void QSymbianSystemPluginWatcher::handlePathChanged(QNotifyChangeEvent *e)
+{
+ QCoreApplicationPrivate::rebuildInstallLibraryPaths();
+ QMutexLocker locker(qt_factoryloader_mutex());
+ QString dirName(QDir::cleanPath(qt_TDesC2QString(e->watchedPath)));
+ QList<QFactoryLoader *> *loaders = qt_factory_loaders();
+ for (QList<QFactoryLoader *>::const_iterator it = loaders->constBegin();
+ it != loaders->constEnd(); ++it) {
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ (*it)->updateDir(dirName, settings);
+ }
+}
+
+#endif
+
QT_END_NAMESPACE
#endif // QT_NO_LIBRARY
diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h
index e90ebf6..8548ab2 100644
--- a/src/corelib/plugin/qfactoryloader_p.h
+++ b/src/corelib/plugin/qfactoryloader_p.h
@@ -82,6 +82,7 @@ public:
#endif
void update();
+ void updateDir(const QString &pluginDir, QSettings& settings);
static void refreshAll();
};
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index bbb64e4..9f9ea1a 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -198,7 +198,7 @@ QPluginLoader::~QPluginLoader()
*/
QObject *QPluginLoader::instance()
{
- if (!isLoaded() && !load())
+ if (!load())
return 0;
if (!d->inst && d->instance)
d->inst = d->instance();
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
index bb9c82a..7296c5b 100644
--- a/src/corelib/plugin/qsystemlibrary.cpp
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qsystemlibrary_p.h"
+
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qfileinfo.h>
@@ -91,7 +92,7 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
extern QString qAppFileName();
#endif
-static QString qSystemDirectory()
+static inline QString qSystemDirectory()
{
QVarLengthArray<wchar_t, MAX_PATH> fullPath;
@@ -115,27 +116,25 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
searchOrder << qSystemDirectory();
if (!onlySystemDirectory) {
- const QString PATH(QLatin1String(qgetenv("PATH").constData()));
+ const QString PATH = QString::fromWCharArray((const wchar_t *)_wgetenv(L"PATH"));
searchOrder << PATH.split(QLatin1Char(';'), QString::SkipEmptyParts);
}
- QString fileName = QString::fromWCharArray(libraryName);
- fileName.append(QLatin1String(".dll"));
+ const QString fileName = QString::fromWCharArray(libraryName) + QLatin1String(".dll");
// Start looking in the order specified
for (int i = 0; i < searchOrder.count(); ++i) {
QString fullPathAttempt = searchOrder.at(i);
- if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) {
+ if (!fullPathAttempt.endsWith(QLatin1Char('\\')))
fullPathAttempt.append(QLatin1Char('\\'));
- }
fullPathAttempt.append(fileName);
HINSTANCE inst = ::LoadLibrary((const wchar_t *)fullPathAttempt.utf16());
if (inst != 0)
return inst;
}
- return 0;
+ return 0;
}
-#endif //Q_OS_WINCE
+#endif // !Q_OS_WINCE
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h
index f20d0b6..88ab82c 100644
--- a/src/corelib/plugin/qsystemlibrary_p.h
+++ b/src/corelib/plugin/qsystemlibrary_p.h
@@ -85,9 +85,9 @@ public:
if (!m_handle)
return 0;
#ifdef Q_OS_WINCE
- return (void*)GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16());
+ return (void*)GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16());
#else
- return (void*)GetProcAddress(m_handle, symbol);
+ return (void*)GetProcAddress(m_handle, symbol);
#endif
}
@@ -97,6 +97,7 @@ public:
}
static Q_CORE_EXPORT HINSTANCE load(const wchar_t *lpFileName, bool onlySystemDirectory = true);
+
private:
HINSTANCE m_handle;
QString m_libraryName;
@@ -105,6 +106,6 @@ private:
QT_END_NAMESPACE
-#endif //Q_OS_WIN
+#endif // Q_OS_WIN
-#endif //QSYSTEMLIBRARY_P_H
+#endif // QSYSTEMLIBRARY_P_H
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index a9923c4..d2ffd28 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -58,10 +58,6 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qmutex.h>
-#if defined(Q_OS_MAC)
-# include <mach/semaphore.h>
-#endif
-
#if defined(Q_OS_SYMBIAN)
# include <e32std.h>
#endif
@@ -83,9 +79,7 @@ public:
Qt::HANDLE owner;
uint count;
-#if defined(Q_OS_MAC)
- semaphore_t mach_semaphore;
-#elif defined(Q_OS_UNIX) && !defined(Q_OS_LINUX) && !defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_LINUX) && !defined(Q_OS_SYMBIAN)
volatile bool wakeup;
pthread_mutex_t mutex;
pthread_cond_t cond;
diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp
index 2a9d23c..790fad3 100644
--- a/src/corelib/thread/qmutex_unix.cpp
+++ b/src/corelib/thread/qmutex_unix.cpp
@@ -65,7 +65,7 @@
QT_BEGIN_NAMESPACE
-#if !defined(Q_OS_MAC) && !defined(Q_OS_LINUX)
+#if !defined(Q_OS_LINUX)
static void report_error(int code, const char *where, const char *what)
{
if (code != 0)
@@ -77,11 +77,7 @@ static void report_error(int code, const char *where, const char *what)
QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
: QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
{
-#if defined(Q_OS_MAC)
- kern_return_t r = semaphore_create(mach_task_self(), &mach_semaphore, SYNC_POLICY_FIFO, 0);
- if (r != KERN_SUCCESS)
- qWarning("QMutex: failed to create semaphore, error %d", r);
-#elif !defined(Q_OS_LINUX)
+#if !defined(Q_OS_LINUX)
wakeup = false;
report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
@@ -90,47 +86,13 @@ QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
QMutexPrivate::~QMutexPrivate()
{
-#if defined(Q_OS_MAC)
- kern_return_t r = semaphore_destroy(mach_task_self(), mach_semaphore);
- if (r != KERN_SUCCESS)
- qWarning("QMutex: failed to destroy semaphore, error %d", r);
-#elif !defined(Q_OS_LINUX)
+#if !defined(Q_OS_LINUX)
report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
#endif
}
-#if defined(Q_OS_MAC)
-
-bool QMutexPrivate::wait(int timeout)
-{
- if (contenders.fetchAndAddAcquire(1) == 0) {
- // lock acquired without waiting
- return true;
- }
- kern_return_t r;
- if (timeout < 0) {
- do {
- r = semaphore_wait(mach_semaphore);
- } while (r == KERN_ABORTED);
- if (r != KERN_SUCCESS)
- qWarning("QMutex: infinite wait failed, error %d", r);
- } else {
- mach_timespec_t ts;
- ts.tv_nsec = ((timeout % 1000) * 1000) * 1000;
- ts.tv_sec = (timeout / 1000);
- r = semaphore_timedwait(mach_semaphore, ts);
- }
- contenders.deref();
- return r == KERN_SUCCESS;
-}
-
-void QMutexPrivate::wakeUp()
-{
- semaphore_signal(mach_semaphore);
-}
-
-#elif defined(Q_OS_LINUX)
+#if defined(Q_OS_LINUX)
static inline int _q_futex(volatile int *addr, int op, int val, const struct timespec *timeout, int *addr2, int val2)
{
@@ -174,7 +136,7 @@ void QMutexPrivate::wakeUp()
(void) _q_futex(&contenders._q_value, FUTEX_WAKE, 1, 0, 0, 0);
}
-#else // !Q_OS_MAC && !Q_OS_LINUX
+#else // !Q_OS_LINUX
bool QMutexPrivate::wait(int timeout)
{
@@ -221,7 +183,7 @@ void QMutexPrivate::wakeUp()
report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock");
}
-#endif // !Q_OS_MAC && !Q_OS_LINUX
+#endif // !Q_OS_LINUX
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp
index d79dc5d..e6bce27 100644
--- a/src/corelib/tools/qelapsedtimer_win.cpp
+++ b/src/corelib/tools/qelapsedtimer_win.cpp
@@ -42,6 +42,8 @@
#include "qelapsedtimer.h"
#include <windows.h>
+#include <private/qsystemlibrary_p.h>
+
typedef ULONGLONG (WINAPI *PtrGetTickCount64)(void);
static PtrGetTickCount64 ptrGetTickCount64 = 0;
@@ -52,21 +54,17 @@ static quint64 counterFrequency = 0;
static void resolveLibs()
{
- static bool done = false;
+ static volatile bool done = false;
if (done)
return;
// try to get GetTickCount64 from the system
- HMODULE kernel32 = GetModuleHandleW(L"kernel32");
- if (!kernel32)
+ QSystemLibrary kernel32(QLatin1String("kernel32"));
+ if (!kernel32.load())
return;
-#if defined(Q_OS_WINCE)
// does this function exist on WinCE, or will ever exist?
- ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, L"GetTickCount64");
-#else
- ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64");
-#endif
+ ptrGetTickCount64 = (PtrGetTickCount64)kernel32.resolve("GetTickCount64");
// Retrieve the number of high-resolution performance counter ticks per second
LARGE_INTEGER frequency;
diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp
index 0f67652..7e3dd34 100644
--- a/src/corelib/tools/qline.cpp
+++ b/src/corelib/tools/qline.cpp
@@ -302,10 +302,15 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
#endif // QT_NO_DATASTREAM
+inline static qreal q_deg2rad(qreal x)
+{
+ return x * qreal(0.01745329251994329576923690768489); /* pi/180 */
+}
-#ifndef M_2PI
-#define M_2PI 6.28318530717958647692528676655900576
-#endif
+inline static qreal q_rad2deg(qreal x)
+{
+ return x * qreal(57.295779513082320876798154814105); /* 180/pi */
+}
/*!
\class QLineF
@@ -483,7 +488,8 @@ bool QLineF::isNull() const
/*!
\fn qreal QLineF::dx() const
- Returns the horizontal component of the line's vector.
+ Returns the horizontal component of the line's vector.
+ Return value is positive if x2() >= x1() and negative if x2() < x1().
\sa dy(), pointAt()
*/
@@ -492,6 +498,7 @@ bool QLineF::isNull() const
\fn qreal QLineF::dy() const
Returns the vertical component of the line's vector.
+ Return value is positive if y2() >= y1() and negative if y2() < y1().
\sa dx(), pointAt()
*/
@@ -501,7 +508,8 @@ bool QLineF::isNull() const
Sets the length of the line to the given \a length. QLineF will
move the end point - p2() - of the line to give the line its new length.
-
+ If the given \a length is negative the angle() is also changed.
+
If the line is a null line, the length will remain zero regardless
of the length specified.
@@ -575,7 +583,7 @@ qreal QLineF::angle() const
const qreal dx = pt2.x() - pt1.x();
const qreal dy = pt2.y() - pt1.y();
- const qreal theta = qAtan2(-dy, dx) * 360.0 / M_2PI;
+ const qreal theta = q_rad2deg(qAtan2(-dy, dx));
const qreal theta_normalized = theta < 0 ? theta + 360 : theta;
@@ -599,7 +607,7 @@ qreal QLineF::angle() const
*/
void QLineF::setAngle(qreal angle)
{
- const qreal angleR = angle * M_2PI / 360.0;
+ const qreal angleR = q_deg2rad(angle);
const qreal l = length();
const qreal dx = qCos(angleR) * l;
@@ -621,7 +629,7 @@ void QLineF::setAngle(qreal angle)
*/
QLineF QLineF::fromPolar(qreal length, qreal angle)
{
- const qreal angleR = angle * M_2PI / 360.0;
+ const qreal angleR = q_deg2rad(angle);
return QLineF(0, 0, qCos(angleR) * length, -qSin(angleR) * length);
}
@@ -757,7 +765,7 @@ QLineF::IntersectType QLineF::intersect(const QLineF &l, QPointF *intersectionPo
\since 4.4
- Returns the angle (in degrees) from this line to the given \a
+ Returns the angle (in positive degrees) from this line to the given \a
line, taking the direction of the lines into account. If the lines
do not intersect within their range, it is the intersection point of
the extended lines that serves as origin (see
@@ -815,8 +823,8 @@ qreal QLineF::angle(const QLineF &l) const
qreal cos_line = (dx()*l.dx() + dy()*l.dy()) / (length()*l.length());
qreal rad = 0;
// only accept cos_line in the range [-1,1], if it is outside, use 0 (we return 0 rather than PI for those cases)
- if (cos_line >= -1.0 && cos_line <= 1.0) rad = qAcos( cos_line );
- return rad * 360 / M_2PI;
+ if (cos_line >= qreal(-1.0) && cos_line <= qreal(1.0)) rad = qAcos( cos_line );
+ return q_rad2deg(rad);
}
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index 18bfe24..2e95ef8 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -469,8 +469,8 @@ void **QListData::erase(void **xi)
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 0
Qt includes a QStringList class that inherits QList\<QString\>
- and adds a few convenience functions, such as QStringList::join()
- and QStringList::find(). (QString::split() creates QStringLists
+ and adds a convenience function QStringList::join().
+ (QString::split() creates QStringLists
from strings.)
QList stores a list of items. The default constructor creates an