summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.cpp14
-rw-r--r--src/corelib/io/qipaddress.cpp3
-rw-r--r--src/corelib/io/qlockfile_p.h3
-rw-r--r--src/corelib/io/qlockfile_unix.cpp2
-rw-r--r--src/corelib/io/qresource.cpp6
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp29
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h13
-rw-r--r--src/corelib/tools/qelapsedtimer_generic.cpp22
-rw-r--r--src/corelib/tools/qlocale.cpp6
-rw-r--r--src/corelib/tools/qsimd_p.h8
-rw-r--r--src/corelib/tools/qstring.cpp10
11 files changed, 73 insertions, 43 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index bf6db53040..5e2d7b7c1a 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1174,13 +1174,13 @@ bool qSharedBuild() Q_DECL_NOTHROW
QSysInfo::MacintoshVersion variable gives the version of the
system on which the application is run.
- \value MV_9 Mac OS 9 (unsupported)
- \value MV_10_0 Mac OS X 10.0 (unsupported)
- \value MV_10_1 Mac OS X 10.1 (unsupported)
- \value MV_10_2 Mac OS X 10.2 (unsupported)
- \value MV_10_3 Mac OS X 10.3 (unsupported)
- \value MV_10_4 Mac OS X 10.4 (unsupported)
- \value MV_10_5 Mac OS X 10.5 (unsupported)
+ \value MV_9 Mac OS 9
+ \value MV_10_0 Mac OS X 10.0
+ \value MV_10_1 Mac OS X 10.1
+ \value MV_10_2 Mac OS X 10.2
+ \value MV_10_3 Mac OS X 10.3
+ \value MV_10_4 Mac OS X 10.4
+ \value MV_10_5 Mac OS X 10.5
\value MV_10_6 Mac OS X 10.6
\value MV_10_7 Mac OS X 10.7
\value MV_10_8 OS X 10.8
diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp
index 13636ebb8b..02b12f635a 100644
--- a/src/corelib/io/qipaddress.cpp
+++ b/src/corelib/io/qipaddress.cpp
@@ -117,6 +117,9 @@ static bool parseIp4Internal(IPv4Address &address, const char *ptr, bool acceptL
return false;
else if (dotCount == 3 || *endptr == '\0')
return true;
+ if (*endptr != '.')
+ return false;
+
++dotCount;
ptr = endptr + 1;
}
diff --git a/src/corelib/io/qlockfile_p.h b/src/corelib/io/qlockfile_p.h
index b41b9b4604..d7f2a1d52d 100644
--- a/src/corelib/io/qlockfile_p.h
+++ b/src/corelib/io/qlockfile_p.h
@@ -81,7 +81,8 @@ public:
// Returns \c true if the lock belongs to dead PID, or is old.
// The attempt to delete it will tell us if it was really stale or not, though.
bool isApparentlyStale() const;
- static QString processNameByPid(qint64 pid);
+ // used in dbusmenu
+ Q_CORE_EXPORT static QString processNameByPid(qint64 pid);
#ifdef Q_OS_UNIX
static int checkFcntlWorksAfterFlock(const QString &fn);
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index 3455305858..7255414bdc 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -148,6 +148,8 @@ static QBasicMutex fcntlLock;
static bool fcntlWorksAfterFlock(const QString &fn)
{
QMutexLocker lock(&fcntlLock);
+ if (fcntlOK.isDestroyed())
+ return QLockFilePrivate::checkFcntlWorksAfterFlock(fn);
bool *worksPtr = fcntlOK->object(fn);
if (!worksPtr) {
worksPtr = new bool(QLockFilePrivate::checkFcntlWorksAfterFlock(fn));
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index ad24b43568..1ead114235 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -1259,8 +1259,10 @@ bool QResourceFileEngine::open(QIODevice::OpenMode flags)
}
if(flags & QIODevice::WriteOnly)
return false;
- if(!d->resource.isValid())
- return false;
+ if (!d->resource.isValid()) {
+ d->errorString = qt_error_string(ENOENT);
+ return false;
+ }
return true;
}
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index 867aea4184..c1abdf11a7 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -167,7 +167,7 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
break;
}
- if (!(node.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
+ if (!(node.type & DaySectionMask)) {
if (day < cachedDay)
day = cachedDay;
const int max = QDate(year, month, 1).daysInMonth();
@@ -633,6 +633,10 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const
case Internal:
case TimeSectionMask:
case DateSectionMask:
+ case HourSectionMask:
+ case YearSectionMask:
+ case DayOfWeekSectionMask:
+ case DaySectionMask:
qWarning("QDateTimeParser::sectionMaxSize: Invalid section %s",
SectionNode::name(s).toLatin1().constData());
@@ -987,33 +991,27 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
if (state != Invalid) {
if (parserType != QVariant::Time) {
- if (year % 100 != year2digits) {
- switch (isSet & (YearSection2Digits|YearSection)) {
- case YearSection2Digits:
+ if (year % 100 != year2digits && (isSet & YearSection2Digits)) {
+ if (!(isSet & YearSection)) {
year = (year / 100) * 100;
year += year2digits;
- break;
- case ((uint)YearSection2Digits|(uint)YearSection): {
+ } else {
conflicts = true;
const SectionNode &sn = sectionNode(currentSectionIndex);
if (sn.type == YearSection2Digits) {
year = (year / 100) * 100;
year += year2digits;
}
- break; }
- default:
- break;
}
}
const QDate date(year, month, day);
const int diff = dayofweek - date.dayOfWeek();
- if (diff != 0 && state == Acceptable
- && isSet & (DayOfWeekSectionShort | DayOfWeekSectionLong)) {
+ if (diff != 0 && state == Acceptable && isSet & DayOfWeekSectionMask) {
if (isSet & DaySection)
conflicts = true;
const SectionNode &sn = sectionNode(currentSectionIndex);
- if (sn.type & (DayOfWeekSectionShort|DayOfWeekSectionLong) || currentSectionIndex == -1) {
+ if (sn.type & DayOfWeekSectionMask || currentSectionIndex == -1) {
// dayofweek should be preferred
day += diff;
if (day <= 0) {
@@ -1025,8 +1023,9 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
<< diff << QDate(year, month, day).dayOfWeek();
}
}
+
bool needfixday = false;
- if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) {
+ if (sectionType(currentSectionIndex) & DaySectionMask) {
cachedDay = day;
} else if (cachedDay > day) {
day = cachedDay;
@@ -1054,7 +1053,7 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
const SectionNode sn = sectionNode(i);
if (sn.type & DaySection) {
input.replace(sectionPos(sn), sectionSize(i), loc.toString(day));
- } else if (sn.type & (DayOfWeekSectionShort | DayOfWeekSectionLong)) {
+ } else if (sn.type & DayOfWeekSectionMask) {
const int dayOfWeek = QDate(year, month, day).dayOfWeek();
const QLocale::FormatType dayFormat =
(sn.type == DayOfWeekSectionShort
@@ -1313,7 +1312,7 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
int bestCount = 0;
if (!str1.isEmpty()) {
const SectionNode &sn = sectionNode(sectionIndex);
- if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
+ if (!(sn.type & DaySectionMask)) {
qWarning("QDateTimeParser::findDay Internal error");
return -1;
}
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index ad403f695b..9689d88616 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -120,14 +120,20 @@ public:
MinuteSection = 0x00008,
Hour12Section = 0x00010,
Hour24Section = 0x00020,
- TimeSectionMask = (AmPmSection|MSecSection|SecondSection|MinuteSection|Hour12Section|Hour24Section),
+ HourSectionMask = (Hour12Section | Hour24Section),
+ TimeSectionMask = (MSecSection | SecondSection | MinuteSection |
+ HourSectionMask | AmPmSection),
+
DaySection = 0x00100,
MonthSection = 0x00200,
YearSection = 0x00400,
YearSection2Digits = 0x00800,
+ YearSectionMask = YearSection | YearSection2Digits,
DayOfWeekSectionShort = 0x01000,
DayOfWeekSectionLong = 0x02000,
- DateSectionMask = (DaySection|MonthSection|YearSection|YearSection2Digits|DayOfWeekSectionShort|DayOfWeekSectionLong),
+ DayOfWeekSectionMask = DayOfWeekSectionShort | DayOfWeekSectionLong,
+ DaySectionMask = DaySection | DayOfWeekSectionMask,
+ DateSectionMask = DaySectionMask | MonthSection | YearSectionMask,
Internal = 0x10000,
FirstSection = 0x20000 | Internal,
@@ -138,7 +144,7 @@ public:
FirstSectionIndex = -2,
LastSectionIndex = -3,
CalendarPopupIndex = -4
- }; // duplicated from qdatetimeedit.h
+ }; // extending qdatetimeedit.h's equivalent
Q_DECLARE_FLAGS(Sections, Section)
struct Q_CORE_EXPORT SectionNode {
@@ -224,6 +230,7 @@ public:
FieldInfo fieldInfo(int index) const;
+ void setDefaultLocale(const QLocale &loc) { defaultLocale = loc; }
virtual QDateTime getMinimum() const;
virtual QDateTime getMaximum() const;
virtual int cursorPosition() const { return -1; }
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp
index e053d4ced4..8c724247be 100644
--- a/src/corelib/tools/qelapsedtimer_generic.cpp
+++ b/src/corelib/tools/qelapsedtimer_generic.cpp
@@ -85,7 +85,8 @@ void QElapsedTimer::start() Q_DECL_NOTHROW
and then starting the timer again with start(), but it does so in one
single operation, avoiding the need to obtain the clock value twice.
- Restarting the timer makes it valid again.
+ Calling this function on a QElapsedTimer that is invalid
+ results in undefined behavior.
The following example illustrates how to use this function to calibrate a
parameter to a slow operation (for example, an iteration count) so that
@@ -93,7 +94,7 @@ void QElapsedTimer::start() Q_DECL_NOTHROW
\snippet qelapsedtimer/main.cpp 3
- \sa start(), invalidate(), elapsed()
+ \sa start(), invalidate(), elapsed(), isValid()
*/
qint64 QElapsedTimer::restart() Q_DECL_NOTHROW
{
@@ -106,8 +107,10 @@ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW
/*! \since 4.8
Returns the number of nanoseconds since this QElapsedTimer was last
- started. Calling this function in a QElapsedTimer that was invalidated
- will result in undefined results.
+ started.
+
+ Calling this function on a QElapsedTimer that is invalid
+ results in undefined behavior.
On platforms that do not provide nanosecond resolution, the value returned
will be the best estimate available.
@@ -121,10 +124,12 @@ qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW
/*!
Returns the number of milliseconds since this QElapsedTimer was last
- started. Calling this function in a QElapsedTimer that was invalidated
- will result in undefined results.
+ started.
- \sa start(), restart(), hasExpired(), invalidate()
+ Calling this function on a QElapsedTimer that is invalid
+ results in undefined behavior.
+
+ \sa start(), restart(), hasExpired(), isValid(), invalidate()
*/
qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW
{
@@ -172,7 +177,8 @@ qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW
\a other was started before this object, the returned value will be
negative. If it was started later, the returned value will be positive.
- The return value is undefined if this object or \a other were invalidated.
+ Calling this function on or with a QElapsedTimer that is invalid
+ results in undefined behavior.
\sa msecsTo(), elapsed()
*/
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 27d2e4c165..eccedca4c8 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -1832,7 +1832,7 @@ QTime QLocale::toTime(const QString &string, const QString &format) const
QTime time;
#ifndef QT_BOOTSTRAPPED
QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString);
- dt.defaultLocale = *this;
+ dt.setDefaultLocale(*this);
if (dt.parseFormat(format))
dt.fromString(string, 0, &time);
#else
@@ -1863,7 +1863,7 @@ QDate QLocale::toDate(const QString &string, const QString &format) const
QDate date;
#ifndef QT_BOOTSTRAPPED
QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString);
- dt.defaultLocale = *this;
+ dt.setDefaultLocale(*this);
if (dt.parseFormat(format))
dt.fromString(string, &date, 0);
#else
@@ -1896,7 +1896,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format) cons
QDate date;
QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString);
- dt.defaultLocale = *this;
+ dt.setDefaultLocale(*this);
if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time);
#else
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index a4fe8e67f8..8ddaed8032 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -483,7 +483,13 @@ static Q_ALWAYS_INLINE unsigned _bit_scan_forward(unsigned val)
}
#elif defined(Q_PROCESSOR_X86)
// Bit scan functions for x86
-# if defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
+# if defined(Q_CC_MSVC)
+# if defined _WIN32_WCE && _WIN32_WCE < 0x800
+extern "C" unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
+extern "C" unsigned char _BitScanReverse(unsigned long* Index, unsigned long Mask);
+# pragma intrinsic(_BitScanForward)
+# pragma intrinsic(_BitScanReverse)
+# endif
// MSVC calls it _BitScanReverse and returns the carry flag, which we don't need
static __forceinline unsigned long _bit_scan_reverse(uint val)
{
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 5cbad2554c..9bfc46f32e 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -5844,7 +5844,9 @@ QString QString::toUpper_helper(QString &str)
}
/*!
- \obsolete Use asprintf(), arg() or QTextStream instead.
+ \obsolete
+
+ Use asprintf(), arg() or QTextStream instead.
*/
QString &QString::sprintf(const char *cformat, ...)
{
@@ -5900,7 +5902,9 @@ QString QString::asprintf(const char *cformat, ...)
}
/*!
- \obsolete Use vasprintf(), arg() or QTextStream instead.
+ \obsolete
+
+ Use vasprintf(), arg() or QTextStream instead.
*/
QString &QString::vsprintf(const char *cformat, va_list ap)
{
@@ -10574,7 +10578,7 @@ float QStringRef::toFloat(bool *ok) const
\obsolete
\fn QString Qt::escape(const QString &plain)
- \sa QString::toHtmlEscaped()
+ Use QString::toHtmlEscaped() instead.
*/
/*!