diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-16 01:22:45 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-16 01:22:45 +0100 |
commit | 7075e291998612a3c0a530bb37a515dd07739e28 (patch) | |
tree | 4e1992498d82ee3f6f92fd6d42754c92928dd581 /src/corelib/tools | |
parent | 1161a8a62907796ea45b1877bec31e66aeef77f6 (diff) | |
parent | 3d9a40038f01bc2a3df0027a9be04e7fa3ce3850 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/widgets/styles/qstyleanimation.cpp
Change-Id: Iae570895be6544de80f9c1ec309d1a08c59daff8
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 5 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_unix.cpp | 27 |
2 files changed, 26 insertions, 6 deletions
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 65201374a9..ca1b6f8b07 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -380,10 +380,13 @@ class QQNXLocaleData: public QObject public: QQNXLocaleData(); virtual ~QQNXLocaleData(); - void readPPSLocale(); public Q_SLOTS: void updateMeasurementSystem(); + void installSocketNotifier(); + +private: + void initialize(); public: uint ppsMeasurement; diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp index 088e40b176..49bed37075 100644 --- a/src/corelib/tools/qlocale_unix.cpp +++ b/src/corelib/tools/qlocale_unix.cpp @@ -66,7 +66,12 @@ QQNXLocaleData::QQNXLocaleData() :ppsNotifier(0) ,ppsFd(-1) { - readPPSLocale(); + initialize(); + + // we cannot call this directly, because by the time this constructor is + // called, the event dispatcher has not yet been created, causing the + // subsequent call to QSocketNotifier constructor to fail. + QMetaObject::invokeMethod(this, "installSocketNotifier", Qt::QueuedConnection); } QQNXLocaleData::~QQNXLocaleData() @@ -106,7 +111,7 @@ void QQNXLocaleData::updateMeasurementSystem() ppsMeasurement = QLocale::MetricSystem; } -void QQNXLocaleData::readPPSLocale() +void QQNXLocaleData::initialize() { errno = 0; ppsFd = qt_safe_open(ppsServicePath, O_RDONLY); @@ -116,10 +121,22 @@ void QQNXLocaleData::readPPSLocale() } updateMeasurementSystem(); - if (QCoreApplication::instance()) { - ppsNotifier = new QSocketNotifier(ppsFd, QSocketNotifier::Read, this); - QObject::connect(ppsNotifier, SIGNAL(activated(int)), this, SLOT(updateMeasurementSystem())); +} + +void QQNXLocaleData::installSocketNotifier() +{ + if (!QCoreApplication::instance() || ppsFd == -1) { + qWarning("QQNXLocaleData: Failed to create socket notifier, locale updates may not work."); + return; } + + if (ppsNotifier) { + qWarning("QQNXLocaleData: socket notifier already created."); + return; + } + + ppsNotifier = new QSocketNotifier(ppsFd, QSocketNotifier::Read, this); + QObject::connect(ppsNotifier, SIGNAL(activated(int)), this, SLOT(updateMeasurementSystem())); } #endif |