embracing the STL

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2016-09-30 22:56:15 +00:00
parent dd6f050cfe
commit 4a5bcff7ec
149 changed files with 808 additions and 3379 deletions

View file

@ -1,7 +1,7 @@
# Editors notes:
#
# * To find all FIXME/TODO related to the CMake build system (and those
# inherited from the autotools build system) execute the following in the
# inherited from the QMake build system) execute the following in the
# top-level directory of the source tree:
#
# find -name '*.cmake' -exec grep -E 'TODO|FIXME' {} +
@ -139,9 +139,10 @@ set(CPACK_GENERATOR "TXZ")
set(CPACK_SOURCE_GENERATOR "TXZ")
include(CPack)
# 9 minutes timeout for the tests, Travis timeouts on 10min and I do not want
# some tests to be skipped because of one test. Like the qpainter test - it
# does a lot of tests and can (and sometimes it does) take more then 10min.
# 9 minutes timeout for the tests, Travis timeouts on 10min if there is no
# output and I do not want some tests to be skipped because of one test. Like
# the qpainter test - it does a lot of tests and can (and sometimes it does)
# take more then 10min.
set(CTEST_TEST_TIMEOUT 540)
if(NOT CMAKE_VERSION VERSION_LESS "3.3.0")
@ -154,10 +155,11 @@ add_definitions(
-DKATIE_DATE="${KATIE_DATE}"
-DQT_USE_QSTRINGBUILDER
-DQT_ASCII_CAST_WARNINGS
# maybe one day, use with caution!
# -DQT_STRICT_ITERATORS
# maybe one day, this forces it onto other projects which (most likely)
# means source code adjustments!
# -DQT_NO_CAST_FROM_ASCII
# -DQT_NO_CAST_TO_ASCII
# -DQT_STRICT_ITERATORS
)
# this is how Qt4 does it
@ -422,9 +424,7 @@ if(PYTHONINTERP_FOUND)
message(SEND_ERROR "${genmap_error}")
endif()
else()
message(WARNING
"\nUsing pre-generated classes map"
)
message(WARNING "\nUsing pre-generated classes map")
endif()
# various sources use #include <shared/blah.h>
@ -432,8 +432,11 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
if(ENABLE_TESTING)
message(WARNING
"\nUnless it is intentionall you should not enable testing. You will have to unset "
"QT_PLUGIN_PATH if you have Qt4 installed on the system prior to running the tests."
"\nUnless it is intentionall you should not enable testing, deploying tests builds"
" is a bad idea.\n\n"
"Prior to runing the test you will have to unset the QT_PLUGIN_PATH environmental"
"variable if you have Qt4 installed on the system because the plugins are not "
"compatible and using them will cause undefined behaviour."
)
enable_testing()
add_definitions(-DQT_BUILD_INTERNAL)

View file

@ -91,6 +91,14 @@ if("${KATIE_COMPILER}" MATCHES "(gcc|clang)")
set(QT_VISIBILITY_AVAILABLE TRUE)
endif()
# Set compiler standard to C++ 11
if(NOT CMAKE_VERSION VERSION_LESS "3.1.0")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
elseif("${KATIE_COMPILER}" MATCHES "(gcc|clang)")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
# TODO: make use of GNUInstallDirs
set(QT_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" CACHE PATH "General installation prefix")
set(QT_HEADERS_PATH "${QT_PREFIX_PATH}/include/katie" CACHE PATH "Headers installation path")

View file

@ -1,150 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
/* Sample program for configure to test STL support on target
platforms. We are mainly concerned with being able to instantiate
templates for common STL container classes.
*/
#include <iterator>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
// something mean to see if the compiler and C++ standard lib are good enough
template<class K, class T>
class DummyClass
{
// everything in std namespace ?
typedef std::bidirectional_iterator_tag i;
typedef std::ptrdiff_t d;
// typename implemented ?
typedef typename std::map<K,T>::iterator MyIterator;
};
// extracted from QVector's strict iterator
template<class T>
class DummyIterator
{
typedef DummyIterator<int> iterator;
public:
T *i;
typedef std::random_access_iterator_tag iterator_category;
typedef std::ptrdiff_t difference_type;
typedef T value_type;
typedef T *pointer;
typedef T &reference;
inline DummyIterator() : i(0) {}
inline DummyIterator(T *n) : i(n) {}
inline DummyIterator(const DummyIterator &o): i(o.i){}
inline T &operator*() const { return *i; }
inline T *operator->() const { return i; }
inline T &operator[](int j) const { return *(i + j); }
inline bool operator==(const DummyIterator &o) const { return i == o.i; }
inline bool operator!=(const DummyIterator &o) const { return i != o.i; }
inline bool operator<(const DummyIterator& other) const { return i < other.i; }
inline bool operator<=(const DummyIterator& other) const { return i <= other.i; }
inline bool operator>(const DummyIterator& other) const { return i > other.i; }
inline bool operator>=(const DummyIterator& other) const { return i >= other.i; }
inline DummyIterator &operator++() { ++i; return *this; }
inline DummyIterator operator++(int) { T *n = i; ++i; return n; }
inline DummyIterator &operator--() { i--; return *this; }
inline DummyIterator operator--(int) { T *n = i; i--; return n; }
inline DummyIterator &operator+=(int j) { i+=j; return *this; }
inline DummyIterator &operator-=(int j) { i-=j; return *this; }
inline DummyIterator operator+(int j) const { return DummyIterator(i+j); }
inline DummyIterator operator-(int j) const { return DummyIterator(i-j); }
inline int operator-(DummyIterator j) const { return i - j.i; }
};
int main()
{
std::vector<int> v1;
v1.push_back( 0 );
v1.push_back( 1 );
v1.push_back( 2 );
v1.push_back( 3 );
v1.push_back( 4 );
int v1size = v1.size();
v1size = 0;
int v1capacity = v1.capacity();
v1capacity = 0;
std::vector<int>::iterator v1it = std::find( v1.begin(), v1.end(), 99 );
bool v1notfound = (v1it == v1.end());
v1notfound = false;
v1it = std::find( v1.begin(), v1.end(), 3 );
bool v1found = (v1it != v1.end());
v1found = false;
std::vector<int> v2;
std::copy( v1.begin(), v1it, std::back_inserter( v2 ) );
int v2size = v2.size();
v2size = 0;
std::map<int, double> m1;
m1.insert( std::make_pair( 1, 2.0 ) );
m1.insert( std::make_pair( 3, 2.0 ) );
m1.insert( std::make_pair( 5, 2.0 ) );
m1.insert( std::make_pair( 7, 2.0 ) );
int m1size = m1.size();
m1size = 0;
std::map<int,double>::iterator m1it = m1.begin();
for ( ; m1it != m1.end(); ++m1it ) {
int first = (*m1it).first;
first = 0;
double second = (*m1it).second;
second = 0.0;
}
std::map< int, double > m2( m1 );
int m2size = m2.size();
m2size = 0;
DummyIterator<int> it1, it2;
int n = std::distance(it1, it2);
std::advance(it1, 3);
return 0;
}

View file

@ -51,31 +51,4 @@ endif()
################################ MISC TESTS ################################
macro(KATIE_MISC_TEST _test _define)
string(TOUPPER ${_test} uppertest)
try_compile(
_has_misc_feature
${CMAKE_BINARY_DIR}/katie_tests/misc
${KATIE_MKSPECS_DIR}/tests/misc/${_test}.cpp
OUTPUT_VARIABLE _misc_feature_log
)
file(WRITE ${CMAKE_BINARY_DIR}/katie_tests/misc/${_test}.log "${_misc_feature_log}")
set(KATIE_${uppertest}_RESULT ${_has_misc_feature} CACHE BOOL "Host supports ${uppertest}")
if(KATIE_${uppertest}_RESULT)
add_definitions(-DQT_${_define})
else()
add_definitions(-DQT_NO_${_define})
endif()
set(_cache_override)
if(NOT _has_misc_feature STREQUAL KATIE_${uppertest}_RESULT)
set(_cache_override " (cache override)")
endif()
message(STATUS "Host supports ${uppertest}: ${KATIE_${uppertest}_RESULT}${_cache_override}")
endmacro()
katie_misc_test(stl STL)
# TODO: check if data relocations should be disabled before any target additions and define Q_NO_DATA_RELOCATION

View file

@ -85,13 +85,13 @@ JSObject* constructDate(ExecState* exec, const ArgList& args)
value = primitive.toNumber(exec);
}
} else {
if (isnan(args.at(0).toNumber(exec))
|| isnan(args.at(1).toNumber(exec))
|| (numArgs >= 3 && isnan(args.at(2).toNumber(exec)))
|| (numArgs >= 4 && isnan(args.at(3).toNumber(exec)))
|| (numArgs >= 5 && isnan(args.at(4).toNumber(exec)))
|| (numArgs >= 6 && isnan(args.at(5).toNumber(exec)))
|| (numArgs >= 7 && isnan(args.at(6).toNumber(exec))))
if (std::isnan(args.at(0).toNumber(exec))
|| std::isnan(args.at(1).toNumber(exec))
|| (numArgs >= 3 && std::isnan(args.at(2).toNumber(exec)))
|| (numArgs >= 4 && std::isnan(args.at(3).toNumber(exec)))
|| (numArgs >= 5 && std::isnan(args.at(4).toNumber(exec)))
|| (numArgs >= 6 && std::isnan(args.at(5).toNumber(exec)))
|| (numArgs >= 7 && std::isnan(args.at(6).toNumber(exec))))
value = NaN;
else {
GregorianDateTime t;
@ -153,13 +153,13 @@ static JSValue JSC_HOST_CALL dateNow(ExecState* exec, JSObject*, JSValue, const
static JSValue JSC_HOST_CALL dateUTC(ExecState* exec, JSObject*, JSValue, const ArgList& args)
{
int n = args.size();
if (isnan(args.at(0).toNumber(exec))
|| isnan(args.at(1).toNumber(exec))
|| (n >= 3 && isnan(args.at(2).toNumber(exec)))
|| (n >= 4 && isnan(args.at(3).toNumber(exec)))
|| (n >= 5 && isnan(args.at(4).toNumber(exec)))
|| (n >= 6 && isnan(args.at(5).toNumber(exec)))
|| (n >= 7 && isnan(args.at(6).toNumber(exec))))
if (std::isnan(args.at(0).toNumber(exec))
|| std::isnan(args.at(1).toNumber(exec))
|| (n >= 3 && std::isnan(args.at(2).toNumber(exec)))
|| (n >= 4 && std::isnan(args.at(3).toNumber(exec)))
|| (n >= 5 && std::isnan(args.at(4).toNumber(exec)))
|| (n >= 6 && std::isnan(args.at(5).toNumber(exec)))
|| (n >= 7 && std::isnan(args.at(6).toNumber(exec))))
return jsNaN(exec);
GregorianDateTime t;

View file

@ -49,7 +49,7 @@ DateInstance::DateInstance(ExecState* exec, double time)
const GregorianDateTime* DateInstance::calculateGregorianDateTime(ExecState* exec) const
{
double milli = internalNumber();
if (isnan(milli))
if (std::isnan(milli))
return 0;
if (!m_data)
@ -65,7 +65,7 @@ const GregorianDateTime* DateInstance::calculateGregorianDateTime(ExecState* exe
const GregorianDateTime* DateInstance::calculateGregorianDateTimeUTC(ExecState* exec) const
{
double milli = internalNumber();
if (isnan(milli))
if (std::isnan(milli))
return 0;
if (!m_data)

View file

@ -216,11 +216,7 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, const ArgList& args, in
// milliseconds
if (idx < numArgs) {
double millis = args.at(idx).toNumber(exec);
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
ok = std::isfinite(millis);
#else
ok = isfinite(millis);
#endif
milliseconds += millis;
} else
milliseconds += *ms;
@ -657,7 +653,7 @@ JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject*, J
DateInstance* thisDateObj = asDateInstance(thisValue);
double milli = thisDateObj->internalNumber();
if (isnan(milli))
if (std::isnan(milli))
return jsNaN(exec);
double secs = floor(milli / msPerSecond);
@ -672,7 +668,7 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject*
DateInstance* thisDateObj = asDateInstance(thisValue);
double milli = thisDateObj->internalNumber();
if (isnan(milli))
if (std::isnan(milli))
return jsNaN(exec);
double secs = floor(milli / msPerSecond);
@ -714,7 +710,7 @@ static JSValue setNewValueFromTimeArgs(ExecState* exec, JSValue thisValue, const
DateInstance* thisDateObj = asDateInstance(thisValue);
double milli = thisDateObj->internalNumber();
if (args.isEmpty() || isnan(milli)) {
if (args.isEmpty() || std::isnan(milli)) {
JSValue result = jsNaN(exec);
thisDateObj->setInternalValue(result);
return result;
@ -758,7 +754,7 @@ static JSValue setNewValueFromDateArgs(ExecState* exec, JSValue thisValue, const
double ms = 0;
GregorianDateTime gregorianDateTime;
if (numArgsToUse == 3 && isnan(milli))
if (numArgsToUse == 3 && std::isnan(milli))
msToGregorianDateTime(exec, 0, true, gregorianDateTime);
else {
ms = milli - floor(milli / msPerSecond) * msPerSecond;
@ -881,7 +877,7 @@ JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue t
double ms = 0;
GregorianDateTime gregorianDateTime;
if (isnan(milli))
if (std::isnan(milli))
// Based on ECMA 262 B.2.5 (setYear)
// the time must be reset to +0 if it is NaN.
msToGregorianDateTime(exec, 0, true, gregorianDateTime);

View file

@ -309,13 +309,9 @@ JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec, JSObject*, JSValue, co
if (value.isDouble()) {
double d = value.asDouble();
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
if (std::isfinite(d))
#else
if (isfinite(d))
#endif
return jsNumber(exec, (d > 0) ? floor(d) : ceil(d));
if (isnan(d) || isinf(d))
if (std::isnan(d) || std::isinf(d))
return jsNaN(exec);
return jsNumber(exec, 0);
}
@ -330,13 +326,13 @@ JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec, JSObject*, JSValue,
JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec, JSObject*, JSValue, const ArgList& args)
{
return jsBoolean(isnan(args.at(0).toNumber(exec)));
return jsBoolean(std::isnan(args.at(0).toNumber(exec)));
}
JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec, JSObject*, JSValue, const ArgList& args)
{
double n = args.at(0).toNumber(exec);
return jsBoolean(!isnan(n) && !isinf(n));
return jsBoolean(!std::isnan(n) && !std::isinf(n));
}
JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec, JSObject*, JSValue, const ArgList& args)

View file

@ -486,7 +486,7 @@ namespace JSC {
const int intVal = static_cast<int>(d);
// Check for data loss from conversion to int.
if (intVal != d || (!intVal && signbit(d)))
if (intVal != d || (!intVal && std::signbit(d)))
return fromNumberOutsideIntegerRange(d);
return from(intVal);

View file

@ -399,11 +399,7 @@ Stringifier::StringifyResult Stringifier::appendStringifiedValue(StringBuilder&
double numericValue;
if (value.getNumber(numericValue)) {
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
if (!std::isfinite(numericValue))
#else
if (!isfinite(numericValue))
#endif
builder.append("null");
else
builder.append(UString::from(numericValue));

View file

@ -43,7 +43,7 @@ double JSValue::toInteger(ExecState* exec) const
if (isInt32())
return asInt32();
double d = toNumber(exec);
return isnan(d) ? 0.0 : trunc(d);
return std::isnan(d) ? 0.0 : trunc(d);
}
double JSValue::toIntegerPreserveNaN(ExecState* exec) const
@ -141,7 +141,7 @@ int32_t toInt32SlowCase(double d, bool& ok)
if (d >= -D32 / 2 && d < D32 / 2)
return static_cast<int32_t>(d);
if (isnan(d) || isinf(d)) {
if (std::isnan(d) || std::isinf(d)) {
ok = false;
return 0;
}
@ -161,7 +161,7 @@ uint32_t toUInt32SlowCase(double d, bool& ok)
if (d >= 0.0 && d < D32)
return static_cast<uint32_t>(d);
if (isnan(d) || isinf(d)) {
if (std::isnan(d) || std::isinf(d)) {
ok = false;
return 0;
}

View file

@ -25,7 +25,7 @@
#include "CallData.h"
#include "ConstructData.h"
#include <math.h>
#include <cmath>
#include <stddef.h> // for size_t
#include <stdint.h>
#include <wtf/AlwaysInline.h>
@ -606,11 +606,7 @@ namespace JSC {
inline JSValue::JSValue(ExecState* exec, double d)
{
const int32_t asInt32 = static_cast<int32_t>(d);
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
if (asInt32 != d || (!asInt32 && std::signbit(d))) { // true for -0.0
#else
if (asInt32 != d || (!asInt32 && signbit(d))) { // true for -0.0
#endif
u.asDouble = d;
return;
}
@ -691,11 +687,7 @@ namespace JSC {
inline JSValue::JSValue(JSGlobalData* globalData, double d)
{
const int32_t asInt32 = static_cast<int32_t>(d);
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
if (asInt32 != d || (!asInt32 && std::signbit(d))) { // true for -0.0
#else
if (asInt32 != d || (!asInt32 && signbit(d))) { // true for -0.0
#endif
u.asDouble = d;
return;
}

View file

@ -166,15 +166,11 @@ JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec, JSObject*, JSValue, cons
double result = -Inf;
for (unsigned k = 0; k < argsCount; ++k) {
double val = args.at(k).toNumber(exec);
if (isnan(val)) {
if (std::isnan(val)) {
result = NaN;
break;
}
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
if (val > result || (val == 0 && result == 0 && !std::signbit(val)))
#else
if (val > result || (val == 0 && result == 0 && !signbit(val)))
#endif
result = val;
}
return jsNumber(exec, result);
@ -186,15 +182,11 @@ JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec, JSObject*, JSValue, cons
double result = +Inf;
for (unsigned k = 0; k < argsCount; ++k) {
double val = args.at(k).toNumber(exec);
if (isnan(val)) {
if (std::isnan(val)) {
result = NaN;
break;
}
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
if (val < result || (val == 0 && result == 0 && std::signbit(val)))
#else
if (val < result || (val == 0 && result == 0 && signbit(val)))
#endif
result = val;
}
return jsNumber(exec, result);
@ -207,9 +199,9 @@ JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec, JSObject*, JSValue, cons
double arg = args.at(0).toNumber(exec);
double arg2 = args.at(1).toNumber(exec);
if (isnan(arg2))
if (std::isnan(arg2))
return jsNaN(exec);
if (isinf(arg2) && fabs(arg) == 1)
if (std::isinf(arg2) && fabs(arg) == 1)
return jsNaN(exec);
return jsNumber(exec, pow(arg, arg2));
}
@ -222,11 +214,7 @@ JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec, JSObject*, JSValue, c
JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec, JSObject*, JSValue, const ArgList& args)
{
double arg = args.at(0).toNumber(exec);
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
if (std::signbit(arg) && arg >= -0.5)
#else
if (signbit(arg) && arg >= -0.5)
#endif
return jsNumber(exec, -0.0);
double integer = ceil(arg);
return jsNumber(exec, integer - (integer - arg > 0.5));

View file

@ -157,7 +157,7 @@ JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec, JSObject*, JSValu
char s[2048 + 3];
const char* lastCharInString = s + sizeof(s) - 1;
double x = v.uncheckedGetNumber();
if (isnan(x) || isinf(x))
if (std::isnan(x) || std::isinf(x))
return jsString(exec, UString::from(x));
bool isNegative = x < 0.0;
@ -233,7 +233,7 @@ JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec, JSObject*, JSValue
int f = static_cast<int>(df);
double x = v.uncheckedGetNumber();
if (isnan(x))
if (std::isnan(x))
return jsNontrivialString(exec, "NaN");
UString s;
@ -319,7 +319,7 @@ JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec, JSObject*, J
double x = v.uncheckedGetNumber();
if (isnan(x) || isinf(x))
if (std::isnan(x) || std::isinf(x))
return jsString(exec, UString::from(x));
JSValue fractionalDigitsValue = args.at(0);
@ -345,7 +345,7 @@ JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec, JSObject*, J
decimalAdjust = static_cast<int>(logx);
}
if (isnan(x))
if (std::isnan(x))
return jsNontrivialString(exec, "NaN");
if (x == -0.0) // (-0.0).toExponential() should print as 0 instead of -0
@ -391,7 +391,7 @@ JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec, JSObject*, JSV
double doublePrecision = args.at(0).toIntegerPreserveNaN(exec);
double x = v.uncheckedGetNumber();
if (args.at(0).isUndefined() || isnan(x) || isinf(x))
if (args.at(0).isUndefined() || std::isnan(x) || std::isinf(x))
return jsString(exec, v.toString(exec));
UString s;

View file

@ -675,9 +675,9 @@ JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec, JSObject*, JSVal
double start = a0.toNumber(exec);
double end = a1.toNumber(exec);
if (isnan(start))
if (std::isnan(start))
start = 0;
if (isnan(end))
if (std::isnan(end))
end = 0;
if (start < 0)
start = 0;

View file

@ -71,28 +71,28 @@ public:
return adoptRef(new UStringImpl(buffer, length, sharedBuffer));
}
static PassRefPtr<UStringImpl> createUninitialized(unsigned length, UChar*& output)
static PassRefPtr<UStringImpl> createUninitialized(unsigned int length, UChar*& output)
{
if (!length) {
output = 0;
return &empty();
}
if (length > ((std::numeric_limits<size_t>::max() - sizeof(UStringImpl)) / sizeof(UChar)))
if (length > ((std::numeric_limits<unsigned int>::max() - sizeof(UStringImpl)) / sizeof(UChar)))
CRASH();
UStringImpl* resultImpl = static_cast<UStringImpl*>(fastMalloc(sizeof(UChar) * length + sizeof(UStringImpl)));
output = reinterpret_cast<UChar*>(resultImpl + 1);
return adoptRef(new(resultImpl) UStringImpl(output, length, BufferInternal));
}
static PassRefPtr<UStringImpl> tryCreateUninitialized(unsigned length, UChar*& output)
static PassRefPtr<UStringImpl> tryCreateUninitialized(unsigned int length, UChar*& output)
{
if (!length) {
output = 0;
return &empty();
}
if (length > ((std::numeric_limits<size_t>::max() - sizeof(UStringImpl)) / sizeof(UChar)))
if (length > ((std::numeric_limits<unsigned int>::max() - sizeof(UStringImpl)) / sizeof(UChar)))
return 0;
UStringImpl* resultImpl = static_cast<UStringImpl*>(tryFastMalloc(sizeof(UChar) * length + sizeof(UStringImpl)));
if (!resultImpl)

View file

@ -838,7 +838,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString)
bool haveTZ;
int offset;
double ms = parseDateFromNullTerminatedCharacters(dateString, haveTZ, offset);
if (isnan(ms))
if (std::isnan(ms))
return NaN;
// fall back to local timezone
@ -850,11 +850,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString)
double timeClip(double t)
{
#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)
if (!std::isfinite(t))
#else
if (!isfinite(t))
#endif
return NaN;
if (fabs(t) > maxECMAScriptTime)
return NaN;
@ -966,7 +962,7 @@ double parseDateFromNullTerminatedCharacters(ExecState* exec, const char* dateSt
bool haveTZ;
int offset;
double ms = WTF::parseDateFromNullTerminatedCharacters(dateString, haveTZ, offset);
if (isnan(ms))
if (std::isnan(ms))
return NaN;
// fall back to local timezone

View file

@ -30,15 +30,6 @@
#include <math.h>
#include <stdlib.h>
#if OS(SOLARIS)
#include <ieeefp.h>
#endif
#if OS(OPENBSD)
#include <sys/types.h>
#include <machine/ieee.h>
#endif
#ifndef M_PI
const double piDouble = 3.14159265358979323846;
const float piFloat = 3.14159265358979323846f;
@ -55,31 +46,6 @@ const double piOverFourDouble = M_PI_4;
const float piOverFourFloat = static_cast<float>(M_PI_4);
#endif
#if OS(SOLARIS)
#ifndef isfinite
inline bool isfinite(double x) { return finite(x) && !isnand(x); }
#endif
#ifndef isinf
inline bool isinf(double x) { return !finite(x) && !isnand(x); }
#endif
#ifndef signbit
inline bool signbit(double x) { return x < 0.0; } // FIXME: Wrong for negative 0.
#endif
#endif
#if OS(OPENBSD)
#ifndef isfinite
inline bool isfinite(double x) { return finite(x); }
#endif
#ifndef signbit
inline bool signbit(double x) { struct ieee_double *p = (struct ieee_double *)&x; return p->dbl_sign; }
#endif
#endif
inline double deg2rad(double d) { return d * piDouble / 180.0; }
inline double rad2deg(double r) { return r * 180.0 / piDouble; }
inline double deg2grad(double d) { return d * 400.0 / 360.0; }

View file

@ -36,17 +36,14 @@ namespace WTF {
using std::max;
// WTF_ALIGN_OF / WTF_ALIGNED
#if COMPILER(GCC) || COMPILER(MINGW) || COMPILER(RVCT) || COMPILER(WINSCW)
#if COMPILER(GCC)
#define WTF_ALIGN_OF(type) __alignof__(type)
#define WTF_ALIGNED(variable_type, variable, n) variable_type variable __attribute__((__aligned__(n)))
#elif COMPILER(MSVC)
#define WTF_ALIGN_OF(type) __alignof(type)
#define WTF_ALIGNED(variable_type, variable, n) __declspec(align(n)) variable_type variable
#else
#define WTF_ALIGN_OF(type) 0
#endif
#if COMPILER(GCC) && !COMPILER(INTEL) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 303)
#if COMPILER(GCC) && !COMPILER(INTEL)
typedef char __attribute__((__may_alias__)) AlignedBufferChar;
#else
typedef char AlignedBufferChar;

View file

@ -774,7 +774,7 @@ static ALWAYS_INLINE void diff(BigInt& c, const BigInt& aRef, const BigInt& bRef
static double ulp(U *x)
{
register int32_t L;
int32_t L;
U u;
L = (word0(x) & Exp_mask) - (P - 1) * Exp_msk1;
@ -2379,7 +2379,7 @@ void doubleToStringInJavaScriptFormat(double d, DtoaBuffer buffer, unsigned* res
Q_ASSERT(buffer);
// avoid ever printing -NaN, in JS conceptually there is only one NaN value
if (isnan(d)) {
if (std::isnan(d)) {
append(buffer, "NaN", 3);
if (resultLength)
*resultLength = 3;

View file

@ -152,7 +152,6 @@ set(CORE_PUBLIC_HEADERS
QStateMachine
QVariantComparisonHelper
QMetaObject
QBasicAtomicPointer
QPauseAnimation
QMapData
QByteRef
@ -178,7 +177,6 @@ set(CORE_PUBLIC_HEADERS
QCharRef
QReturnArgument
QMetaObjectAccessor
QBasicAtomicInt
QConcatenable
QLocale
QMetaType
@ -260,7 +258,6 @@ set(CORE_PUBLIC_HEADERS
)
include(animation/animation.cmake)
include(arch/arch.cmake)
include(codecs/codecs.cmake)
include(concurrent/concurrent.cmake)
include(global/global.cmake)
@ -280,7 +277,6 @@ include_directories(
${CMAKE_BINARY_DIR}/include/QtCore
${CMAKE_BINARY_DIR}/privateinclude/QtCore
${CMAKE_CURRENT_SOURCE_DIR}/animation
${CMAKE_CURRENT_SOURCE_DIR}/arch
${CMAKE_CURRENT_SOURCE_DIR}/codecs
${CMAKE_CURRENT_SOURCE_DIR}/concurrent
${CMAKE_CURRENT_SOURCE_DIR}/global
@ -293,7 +289,6 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/tools
${CMAKE_CURRENT_SOURCE_DIR}/xml
${CMAKE_CURRENT_BINARY_DIR}/animation
${CMAKE_CURRENT_BINARY_DIR}/arch
${CMAKE_CURRENT_BINARY_DIR}/codecs
${CMAKE_CURRENT_BINARY_DIR}/concurrent
${CMAKE_CURRENT_BINARY_DIR}/global

View file

@ -293,7 +293,7 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
localProgress);
qSwap(currentValue, ret);
q->updateCurrentValue(currentValue);
static QBasicAtomicInt changedSignalIndex = Q_BASIC_ATOMIC_INITIALIZER(0);
static QAtomicInt changedSignalIndex = QAtomicInt(0);
if (!changedSignalIndex) {
//we keep the mask so that we emit valueChanged only when needed (for performance reasons)
changedSignalIndex.testAndSetRelaxed(0, signalIndex("valueChanged(QVariant)"));

View file

@ -1,99 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QATOMIC_BOOTSTRAP_H
#define QATOMIC_BOOTSTRAP_H
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
inline bool QBasicAtomicInt::ref()
{
return ++_q_value != 0;
}
inline bool QBasicAtomicInt::deref()
{
return --_q_value != 0;
}
inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
{
if (_q_value == expectedValue) {
_q_value = newValue;
return true;
}
return false;
}
inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
{
return testAndSetOrdered(expectedValue, newValue);
}
inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
{
return testAndSetOrdered(expectedValue, newValue);
}
inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
{
int returnValue = _q_value;
_q_value += valueToAdd;
return returnValue;
}
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
{
if (_q_value == expectedValue) {
_q_value = newValue;
return true;
}
return false;
}
QT_END_NAMESPACE
QT_END_HEADER
#endif // QATOMIC_BOOTSTRAP_H

View file

@ -1,235 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QATOMIC_GENERIC_H
#define QATOMIC_GENERIC_H
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE
#define Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE
#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE
#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE
#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE
#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE
#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE
Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int);
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int);
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(volatile int *, int);
Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *);
Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *);
Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *, qptrdiff);
// Reference counting
inline bool QBasicAtomicInt::ref()
{
return QBasicAtomicInt_fetchAndAddOrdered(&_q_value, 1) != -1;
}
inline bool QBasicAtomicInt::deref()
{
return QBasicAtomicInt_fetchAndAddOrdered(&_q_value, -1) != 1;
}
// Test and set for integers
inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
{
return QBasicAtomicInt_testAndSetOrdered(&_q_value, expectedValue, newValue);
}
inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
{
return testAndSetOrdered(expectedValue, newValue);
}
inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
{
return testAndSetOrdered(expectedValue, newValue);
}
inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
{
return testAndSetOrdered(expectedValue, newValue);
}
// Fetch and store for integers
inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
{
return QBasicAtomicInt_fetchAndStoreOrdered(&_q_value, newValue);
}
inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
{
return fetchAndStoreOrdered(newValue);
}
inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
{
return fetchAndStoreOrdered(newValue);
}
inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
{
return fetchAndStoreOrdered(newValue);
}
// Fetch and add for integers
inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
{
return QBasicAtomicInt_fetchAndAddOrdered(&_q_value, valueToAdd);
}
inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
{
return fetchAndAddOrdered(valueToAdd);
}
inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
{
return fetchAndAddOrdered(valueToAdd);
}
inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
{
return fetchAndAddOrdered(valueToAdd);
}
// Test and set for pointers
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
{
union { T * volatile * typed; void * volatile * voidp; } pointer;
pointer.typed = &_q_value;
return QBasicAtomicPointer_testAndSetOrdered(pointer.voidp, expectedValue, newValue);
}
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
{
return testAndSetOrdered(expectedValue, newValue);
}
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
{
return testAndSetOrdered(expectedValue, newValue);
}
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
{
return testAndSetOrdered(expectedValue, newValue);
}
// Fetch and store for pointers
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
{
union { T * volatile * typed; void * volatile * voidp; } pointer;
union { T *typed; void *voidp; } returnValue;
pointer.typed = &_q_value;
returnValue.voidp = QBasicAtomicPointer_fetchAndStoreOrdered(pointer.voidp, newValue);
return returnValue.typed;
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
{
return fetchAndStoreOrdered(newValue);
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
{
return fetchAndStoreOrdered(newValue);
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
{
return fetchAndStoreOrdered(newValue);
}
// Fetch and add for pointers
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
{
union { T * volatile *typed; void * volatile *voidp; } pointer;
union { T *typed; void *voidp; } returnValue;
pointer.typed = &_q_value;
returnValue.voidp = QBasicAtomicPointer_fetchAndAddOrdered(pointer.voidp, valueToAdd * sizeof(T));
return returnValue.typed;
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
{
return fetchAndAddOrdered(valueToAdd);
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
{
return fetchAndAddOrdered(valueToAdd);
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
{
return fetchAndAddOrdered(valueToAdd);
}
QT_END_NAMESPACE
QT_END_HEADER
#endif // QATOMIC_GENERIC_H

View file

@ -1,121 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qplatformdefs.h"
#include <QtCore/qatomic.h>
QT_BEGIN_NAMESPACE
static pthread_mutex_t qAtomicMutex = PTHREAD_MUTEX_INITIALIZER;
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
{
bool returnValue = false;
pthread_mutex_lock(&qAtomicMutex);
if (*_q_value == expectedValue) {
*_q_value = newValue;
returnValue = true;
}
pthread_mutex_unlock(&qAtomicMutex);
return returnValue;
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
{
int returnValue;
pthread_mutex_lock(&qAtomicMutex);
returnValue = *_q_value;
*_q_value = newValue;
pthread_mutex_unlock(&qAtomicMutex);
return returnValue;
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
{
int returnValue;
pthread_mutex_lock(&qAtomicMutex);
returnValue = *_q_value;
*_q_value += valueToAdd;
pthread_mutex_unlock(&qAtomicMutex);
return returnValue;
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
bool returnValue = false;
pthread_mutex_lock(&qAtomicMutex);
if (*_q_value == expectedValue) {
*_q_value = newValue;
returnValue = true;
}
pthread_mutex_unlock(&qAtomicMutex);
return returnValue;
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue)
{
void *returnValue;
pthread_mutex_lock(&qAtomicMutex);
returnValue = *_q_value;
*_q_value = newValue;
pthread_mutex_unlock(&qAtomicMutex);
return returnValue;
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
{
void *returnValue;
pthread_mutex_lock(&qAtomicMutex);
returnValue = *_q_value;
*_q_value = reinterpret_cast<char *>(returnValue) + valueToAdd;
pthread_mutex_unlock(&qAtomicMutex);
return returnValue;
}
QT_END_NAMESPACE

View file

@ -50,9 +50,7 @@
#include <QtCore/qtconcurrentmedian.h>
#include <QtCore/qtconcurrentthreadengine.h>
#ifndef QT_NO_STL
# include <iterator>
#endif
#include <iterator>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@ -61,16 +59,7 @@ QT_BEGIN_NAMESPACE
namespace QtConcurrent {
#ifndef QT_NO_STL
using std::advance;
#else
template <typename It, typename T>
void advance(It &it, T value)
{
it+=value;
}
#endif
/*
The BlockSizeManager class manages how many iterations a thread should
reserve and process at a time. This is done by measuring the time spent
@ -148,7 +137,6 @@ public:
inline void * getPointer() { return 0; }
};
#ifndef QT_NO_STL
inline bool selectIteration(std::bidirectional_iterator_tag)
{
return false; // while
@ -163,14 +151,6 @@ inline bool selectIteration(std::random_access_iterator_tag)
{
return true; // for
}
#else
// no stl support, always use while iteration
template <typename T>
inline bool selectIteration(T)
{
return false; // while
}
#endif
template <typename Iterator, typename T>
class IterateKernel : public ThreadEngine<T>
@ -179,20 +159,11 @@ public:
typedef T ResultType;
IterateKernel(Iterator _begin, Iterator _end)
#if defined (QT_NO_STL)
: begin(_begin), end(_end), current(_begin), currentIndex(0),
forIteration(false), progressReportingEnabled(true)
#else
: begin(_begin), end(_end), current(_begin), currentIndex(0),
forIteration(selectIteration(typename std::iterator_traits<Iterator>::iterator_category())), progressReportingEnabled(true)
#endif
{
#if defined (QT_NO_STL)
iterationCount = 0;
#else
iterationCount = forIteration ? std::distance(_begin, _end) : 0;
#endif
}
virtual ~IterateKernel() { }

View file

@ -3,7 +3,6 @@ set(CORE_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/global/qnamespace.h
${CMAKE_CURRENT_SOURCE_DIR}/global/qendian.h
${CMAKE_CURRENT_SOURCE_DIR}/global/qnumeric.h
${CMAKE_CURRENT_SOURCE_DIR}/global/qnumeric_p.h
${CMAKE_CURRENT_SOURCE_DIR}/global/qfeatures.h
${CMAKE_CURRENT_SOURCE_DIR}/global/qlibraryinfo.h
)

View file

@ -98,7 +98,7 @@
/* Data structures */
#cmakedefine QT_NO_QUUID_STRING
#cmakedefine QT_NO_STL
#cmakedefine QT_NO_STL_WCHAR
#cmakedefine QT_NO_TEXTDATE
#cmakedefine QT_NO_DATESTRING

View file

@ -223,9 +223,6 @@
// Status Tip
//#define QT_NO_STATUSTIP
// Standard Template Library
//#define QT_NO_STL
// QMotifStyle
//#define QT_NO_STYLE_MOTIF

View file

@ -139,9 +139,7 @@
#ifdef __cplusplus
#ifndef QT_NO_STL
#include <algorithm>
#endif
#ifndef QT_NAMESPACE /* user namespace */
@ -386,34 +384,11 @@ namespace QT_NAMESPACE {}
# define __has_extension __has_feature
# endif
# endif
# ifdef __APPLE__
# define Q_NO_DEPRECATED_CONSTRUCTORS
# endif
# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7
# define Q_FULL_TEMPLATE_INSTANTIATION
# endif
/* GCC 2.95 knows "using" but does not support it correctly */
# if __GNUC__ == 2 && __GNUC_MINOR__ <= 95
# define Q_NO_USING_KEYWORD
# define QT_NO_STL_WCHAR
# endif
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
# define Q_ALIGNOF(type) __alignof__(type)
# define Q_TYPEOF(expr) __typeof__(expr)
# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
# endif
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
# endif
/* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */
# if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1
# define Q_WRONG_SB_CTYPE_MACROS
# endif
/* GCC <= 3.3 cannot handle template friends */
# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)
# define Q_NO_TEMPLATE_FRIENDS
# endif
# define Q_ALIGNOF(type) __alignof__(type)
# define Q_TYPEOF(expr) __typeof__(expr)
# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
# if (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) && !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((__packed__))
# define Q_NO_PACKED_REFERENCE
@ -753,31 +728,23 @@ namespace QT_NAMESPACE {}
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
/* C++0x features supported in GCC 4.3: */
# define Q_COMPILER_RVALUE_REFS
# define Q_COMPILER_DECLTYPE
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
/* C++0x features supported in GCC 4.4: */
# define Q_COMPILER_VARIADIC_TEMPLATES
# define Q_COMPILER_AUTO_FUNCTION
# define Q_COMPILER_AUTO_TYPE
# define Q_COMPILER_EXTERN_TEMPLATES
# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
# define Q_COMPILER_CLASS_ENUM
# define Q_COMPILER_INITIALIZER_LISTS
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
/* C++0x features supported in GCC 4.5: */
# define Q_COMPILER_LAMBDA
# define Q_COMPILER_UNICODE_STRINGS
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
/* C++0x features supported in GCC 4.6: */
# define Q_COMPILER_CONSTEXPR
# define Q_COMPILER_NULLPTR
# endif
/* C++0x features supported in GCC 4.3: */
# define Q_COMPILER_RVALUE_REFS
# define Q_COMPILER_DECLTYPE
/* C++0x features supported in GCC 4.4: */
# define Q_COMPILER_VARIADIC_TEMPLATES
# define Q_COMPILER_AUTO_FUNCTION
# define Q_COMPILER_AUTO_TYPE
# define Q_COMPILER_EXTERN_TEMPLATES
# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
# define Q_COMPILER_CLASS_ENUM
# define Q_COMPILER_INITIALIZER_LISTS
# /* C++0x features supported in GCC 4.5: */
# define Q_COMPILER_LAMBDA
# define Q_COMPILER_UNICODE_STRINGS
# /* C++0x features supported in GCC 4.6: */
# define Q_COMPILER_CONSTEXPR
# define Q_COMPILER_NULLPTR
# endif
#endif
@ -822,7 +789,7 @@ namespace QT_NAMESPACE {}
#endif
#ifndef Q_REQUIRED_RESULT
# if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
# if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
# define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result))
# else
# define Q_REQUIRED_RESULT
@ -938,7 +905,7 @@ redefine to built-in booleans to make autotests work properly */
*/
#if defined(Q_MOC_RUN)
# define Q_DECL_DEPRECATED Q_DECL_DEPRECATED
#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))
#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
#else
# define Q_DECL_DEPRECATED
@ -981,24 +948,15 @@ redefine to built-in booleans to make autotests work properly */
#ifdef QT_ASCII_CAST_WARNINGS
# define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED
# if defined(Q_CC_GNU) && __GNUC__ < 4
/* gcc < 4 doesn't like Q_DECL_DEPRECATED in front of constructors */
# define QT_ASCII_CAST_WARN_CONSTRUCTOR
# else
# define QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED
# endif
# define QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED
#else
# define QT_ASCII_CAST_WARN
# define QT_ASCII_CAST_WARN_CONSTRUCTOR
#endif
#if defined(__i386__)
# if defined(Q_CC_GNU)
#if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332)
# if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
# define QT_FASTCALL __attribute__((regparm(3)))
#else
# define QT_FASTCALL
#endif
# else
# define QT_FASTCALL
# endif
@ -1386,14 +1344,14 @@ public:
#else
// forward declaration, since qatomic.h needs qglobal.h
template <typename T> class QBasicAtomicPointer;
template <typename T> class QAtomicPointer;
// POD for Q_GLOBAL_STATIC
template <typename T>
class QGlobalStatic
{
public:
QBasicAtomicPointer<T> pointer;
QAtomicPointer<T> pointer;
bool destroyed;
};
@ -1417,7 +1375,7 @@ public:
#define Q_GLOBAL_STATIC_INIT(TYPE, NAME) \
static QGlobalStatic<TYPE > this_ ## NAME \
= { Q_BASIC_ATOMIC_INITIALIZER(0), false }
= { QAtomicPointer<TYPE>(0), false }
#define Q_GLOBAL_STATIC(TYPE, NAME) \
static TYPE *NAME() \
@ -1617,13 +1575,7 @@ Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS)
template <typename T>
inline void qSwap(T &value1, T &value2)
{
#ifdef QT_NO_STL
const T t = value1;
value1 = value2;
value2 = t;
#else
std::swap(value1, value2);
#endif
}
/*
@ -1635,23 +1587,16 @@ inline void qSwap(T &value1, T &value2)
types must declare a 'bool isDetached(void) const;' member for this
to work.
*/
#ifdef QT_NO_STL
#define Q_DECLARE_SHARED_STL(TYPE)
#else
#define Q_DECLARE_SHARED_STL(TYPE) \
#define Q_DECLARE_SHARED(TYPE) \
template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
{ qSwap(value1.data_ptr(), value2.data_ptr()); } \
QT_END_NAMESPACE \
namespace std { \
template<> inline void swap<QT_PREPEND_NAMESPACE(TYPE)>(QT_PREPEND_NAMESPACE(TYPE) &value1, QT_PREPEND_NAMESPACE(TYPE) &value2) \
{ swap(value1.data_ptr(), value2.data_ptr()); } \
} \
QT_BEGIN_NAMESPACE
#endif
#define Q_DECLARE_SHARED(TYPE) \
template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
{ qSwap(value1.data_ptr(), value2.data_ptr()); } \
Q_DECLARE_SHARED_STL(TYPE)
/*
QTypeInfo primitive specializations
@ -1960,13 +1905,6 @@ Q_CORE_EXPORT int qrand();
# define QT_NO_QFUTURE
#endif
// gcc 3 version has problems with some of the
// map/filter overloads.
#if defined(Q_CC_GNU) && (__GNUC__ < 4)
# define QT_NO_CONCURRENT_MAP
# define QT_NO_CONCURRENT_FILTER
#endif
#if defined (__ELF__)
# if defined (Q_OS_LINUX) || defined (Q_OS_SOLARIS) || defined (Q_OS_FREEBSD) || defined (Q_OS_OPENBSD) || defined (Q_OS_IRIX)
# define Q_OF_ELF

View file

@ -40,115 +40,131 @@
****************************************************************************/
#include "qnumeric.h"
#include "qnumeric_p.h"
QT_BEGIN_NAMESPACE
#if defined(QT_NO_STL)
/*!
Returns true if the double \a {d} is equivalent to infinity.
*/
Q_CORE_EXPORT bool qIsInf(double d)
{
uchar *ch = (uchar *)&d;
#ifdef QT_ARMFPA
return (ch[3] & 0x7f) == 0x7f && ch[2] == 0xf0;
#else
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
return (ch[0] & 0x7f) == 0x7f && ch[1] == 0xf0;
} else {
return (ch[7] & 0x7f) == 0x7f && ch[6] == 0xf0;
}
#endif
}
/*!
Returns true if the double \a {d} is not a number (NaN).
*/
Q_CORE_EXPORT bool qIsNaN(double d)
{
uchar *ch = (uchar *)&d;
#ifdef QT_ARMFPA
return (ch[3] & 0x7f) == 0x7f && ch[2] > 0xf0;
#else
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
return (ch[0] & 0x7f) == 0x7f && ch[1] > 0xf0;
} else {
return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0;
}
#endif
}
/*!
Returns true if the double \a {d} is a finite number.
*/
Q_CORE_EXPORT bool qIsFinite(double d)
{
uchar *ch = (uchar *)&d;
#ifdef QT_ARMFPA
return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0xf0) != 0xf0;
#else
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0xf0) != 0xf0;
} else {
return (ch[7] & 0x7f) != 0x7f || (ch[6] & 0xf0) != 0xf0;
}
#endif
}
/*!
Returns true if the float \a {f} is equivalent to infinity.
*/
Q_CORE_EXPORT bool qIsInf(float f)
{
uchar *ch = (uchar *)&f;
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
return (ch[0] & 0x7f) == 0x7f && ch[1] == 0x80;
} else {
return (ch[3] & 0x7f) == 0x7f && ch[2] == 0x80;
}
}
/*!
Returns true if the float \a {f} is not a number (NaN).
*/
Q_CORE_EXPORT bool qIsNaN(float f)
{
uchar *ch = (uchar *)&f;
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
return (ch[0] & 0x7f) == 0x7f && ch[1] > 0x80;
} else {
return (ch[3] & 0x7f) == 0x7f && ch[2] > 0x80;
}
}
/*!
Returns true if the float \a {f} is a finite number.
*/
Q_CORE_EXPORT bool qIsFinite(float f)
{
uchar *ch = (uchar *)&f;
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0x80) != 0x80;
} else {
return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0x80) != 0x80;
}
}
#endif // QT_NO_STL
/*!
Returns the bit pattern of a signalling NaN as a double.
*/
Q_CORE_EXPORT double qSNaN() { return qt_snan(); }
/*!
Returns the bit pattern of a quiet NaN as a double.
*/
Q_CORE_EXPORT double qQNaN() { return qt_qnan(); }
#if !defined(Q_CC_MIPS)
/*!
Returns the bit pattern for an infinite number as a double.
*/
Q_CORE_EXPORT double qInf() { return qt_inf(); }
static const union { unsigned char c[8]; double d; } qt_be_inf_bytes = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
static const union { unsigned char c[8]; double d; } qt_le_inf_bytes = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };
static const union { unsigned char c[8]; double d; } qt_armfpa_inf_bytes = { { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } };
Q_CORE_EXPORT double qInf()
{
#ifdef QT_ARMFPA
return qt_armfpa_inf_bytes.d;
#else
return (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_inf_bytes.d
: qt_le_inf_bytes.d);
#endif
}
/*!
Returns the bit pattern of a signalling NaN as a double.
*/
static const union { unsigned char c[8]; double d; } qt_be_snan_bytes = { { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 } };
static const union { unsigned char c[8]; double d; } qt_le_snan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } };
static const union { unsigned char c[8]; double d; } qt_armfpa_snan_bytes = { { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 } };
Q_CORE_EXPORT double qSNaN()
{
#ifdef QT_ARMFPA
return qt_armfpa_snan_bytes.d;
#else
return (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_snan_bytes.d
: qt_le_snan_bytes.d);
#endif
}
/*!
Returns the bit pattern of a quiet NaN as a double.
*/
static const union { unsigned char c[8]; double d; } qt_be_qnan_bytes = { { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 } };
static const union { unsigned char c[8]; double d; } qt_le_qnan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0xff } };
static const union { unsigned char c[8]; double d; } qt_armfpa_qnan_bytes = { { 0, 0, 0xf8, 0xff, 0, 0, 0, 0 } };
Q_CORE_EXPORT double qQNaN()
{
#ifdef QT_ARMFPA
return qt_armfpa_qnan_bytes.d;
#else
return (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_qnan_bytes.d
: qt_le_qnan_bytes.d);
#endif
}
#else // Q_CC_MIPS
/*!
Returns the bit pattern for an infinite number as a double.
*/
static const unsigned char qt_be_inf_bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
static const unsigned char qt_le_inf_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
static const unsigned char qt_armfpa_inf_bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
Q_CORE_EXPORT double qInf()
{
const unsigned char *bytes;
#ifdef QT_ARMFPA
bytes = qt_armfpa_inf_bytes;
#else
bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_inf_bytes
: qt_le_inf_bytes);
#endif
union { unsigned char c[8]; double d; } returnValue;
memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
/*!
Returns the bit pattern of a signalling NaN as a double.
*/
static const unsigned char qt_be_snan_bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
static const unsigned char qt_le_snan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
static const unsigned char qt_armfpa_snan_bytes[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 };
Q_CORE_EXPORT double qSNaN()
{
const unsigned char *bytes;
#ifdef QT_ARMFPA
bytes = qt_armfpa_snan_bytes;
#else
bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_snan_bytes
: qt_le_snan_bytes);
#endif
union { unsigned char c[8]; double d; } returnValue;
memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
/*!
Returns the bit pattern of a quiet NaN as a double.
*/
static const unsigned char qt_be_qnan_bytes[] = { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 };
static const unsigned char qt_le_qnan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0xff };
static const unsigned char qt_armfpa_qnan_bytes[] = { 0, 0, 0xf8, 0xff, 0, 0, 0, 0 };
Q_CORE_EXPORT double qQNaN()
{
const unsigned char *bytes;
#ifdef QT_ARMFPA
bytes = qt_armfpa_qnan_bytes;
#else
bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_qnan_bytes
: qt_le_qnan_bytes);
#endif
union { unsigned char c[8]; double d; } returnValue;
memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
#endif // Q_CC_MIPS
QT_END_NAMESPACE

View file

@ -44,29 +44,18 @@
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STL)
#include <math.h>
#endif
#include <cmath>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#if !defined(QT_NO_STL)
Q_CORE_EXPORT_INLINE bool qIsInf(double d) { return isinf(d); }
Q_CORE_EXPORT_INLINE bool qIsNaN(double d) { return isnan(d); }
Q_CORE_EXPORT_INLINE bool qIsFinite(double d) { return isfinite(d); }
Q_CORE_EXPORT_INLINE bool qIsInf(float f) { return isinf(f); }
Q_CORE_EXPORT_INLINE bool qIsNaN(float f) { return isnan(f); }
Q_CORE_EXPORT_INLINE bool qIsFinite(float f) { return isfinite(f); }
#else
Q_CORE_EXPORT bool qIsInf(double d);
Q_CORE_EXPORT bool qIsNaN(double d);
Q_CORE_EXPORT bool qIsFinite(double d);
Q_CORE_EXPORT bool qIsInf(float f);
Q_CORE_EXPORT bool qIsNaN(float f);
Q_CORE_EXPORT bool qIsFinite(float f);
#endif
inline bool qIsInf(double d) { return std::isinf(d); }
inline bool qIsNaN(double d) { return std::isnan(d); }
inline bool qIsFinite(double d) { return std::isfinite(d); }
inline bool qIsInf(float f) { return std::isinf(f); }
inline bool qIsNaN(float f) { return std::isnan(f); }
inline bool qIsFinite(float f) { return std::isfinite(f); }
Q_CORE_EXPORT double qSNaN();
Q_CORE_EXPORT double qQNaN();

View file

@ -1,171 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNUMERIC_P_H
#define QNUMERIC_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "QtCore/qglobal.h"
QT_BEGIN_NAMESPACE
#if !defined(Q_CC_MIPS)
static const union { unsigned char c[8]; double d; } qt_be_inf_bytes = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
static const union { unsigned char c[8]; double d; } qt_le_inf_bytes = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };
static const union { unsigned char c[8]; double d; } qt_armfpa_inf_bytes = { { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } };
static inline double qt_inf()
{
#ifdef QT_ARMFPA
return qt_armfpa_inf_bytes.d;
#else
return (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_inf_bytes.d
: qt_le_inf_bytes.d);
#endif
}
// Signaling NAN
static const union { unsigned char c[8]; double d; } qt_be_snan_bytes = { { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 } };
static const union { unsigned char c[8]; double d; } qt_le_snan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } };
static const union { unsigned char c[8]; double d; } qt_armfpa_snan_bytes = { { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 } };
static inline double qt_snan()
{
#ifdef QT_ARMFPA
return qt_armfpa_snan_bytes.d;
#else
return (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_snan_bytes.d
: qt_le_snan_bytes.d);
#endif
}
// Quiet NAN
static const union { unsigned char c[8]; double d; } qt_be_qnan_bytes = { { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 } };
static const union { unsigned char c[8]; double d; } qt_le_qnan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0xff } };
static const union { unsigned char c[8]; double d; } qt_armfpa_qnan_bytes = { { 0, 0, 0xf8, 0xff, 0, 0, 0, 0 } };
static inline double qt_qnan()
{
#ifdef QT_ARMFPA
return qt_armfpa_qnan_bytes.d;
#else
return (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_qnan_bytes.d
: qt_le_qnan_bytes.d);
#endif
}
#else // Q_CC_MIPS
static const unsigned char qt_be_inf_bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
static const unsigned char qt_le_inf_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
static const unsigned char qt_armfpa_inf_bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
static inline double qt_inf()
{
const unsigned char *bytes;
#ifdef QT_ARMFPA
bytes = qt_armfpa_inf_bytes;
#else
bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_inf_bytes
: qt_le_inf_bytes);
#endif
union { unsigned char c[8]; double d; } returnValue;
memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
// Signaling NAN
static const unsigned char qt_be_snan_bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
static const unsigned char qt_le_snan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
static const unsigned char qt_armfpa_snan_bytes[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 };
static inline double qt_snan()
{
const unsigned char *bytes;
#ifdef QT_ARMFPA
bytes = qt_armfpa_snan_bytes;
#else
bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_snan_bytes
: qt_le_snan_bytes);
#endif
union { unsigned char c[8]; double d; } returnValue;
memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
// Quiet NAN
static const unsigned char qt_be_qnan_bytes[] = { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 };
static const unsigned char qt_le_qnan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0xff };
static const unsigned char qt_armfpa_qnan_bytes[] = { 0, 0, 0xf8, 0xff, 0, 0, 0, 0 };
static inline double qt_qnan()
{
const unsigned char *bytes;
#ifdef QT_ARMFPA
bytes = qt_armfpa_qnan_bytes;
#else
bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian
? qt_be_qnan_bytes
: qt_le_qnan_bytes);
#endif
union { unsigned char c[8]; double d; } returnValue;
memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
#endif // Q_CC_MIPS
QT_END_NAMESPACE
#endif // QNUMERIC_P_H

View file

@ -306,7 +306,7 @@ void QProcessManager::catchDeadChildren()
}
}
static QBasicAtomicInt idCounter = Q_BASIC_ATOMIC_INITIALIZER(1);
static QAtomicInt idCounter = QAtomicInt(1);
void QProcessManager::add(pid_t pid, QProcess *process)
{

View file

@ -88,13 +88,13 @@ static const int BucketOffset[] = {
FourthBucketOffset, FifthBucketOffset, SixthBucketOffset
};
static QBasicAtomicPointer<int> timerIds[] =
{ Q_BASIC_ATOMIC_INITIALIZER(FirstBucket),
Q_BASIC_ATOMIC_INITIALIZER(0),
Q_BASIC_ATOMIC_INITIALIZER(0),
Q_BASIC_ATOMIC_INITIALIZER(0),
Q_BASIC_ATOMIC_INITIALIZER(0),
Q_BASIC_ATOMIC_INITIALIZER(0) };
static QAtomicPointer<int> timerIds[] =
{ QAtomicPointer<int>(FirstBucket),
QAtomicPointer<int>(0),
QAtomicPointer<int>(0),
QAtomicPointer<int>(0),
QAtomicPointer<int>(0),
QAtomicPointer<int>(0) };
static void timerIdsDestructorFunction()
{
@ -104,7 +104,7 @@ static void timerIdsDestructorFunction()
}
Q_DESTRUCTOR_FUNCTION(timerIdsDestructorFunction)
static QBasicAtomicInt nextFreeTimerId = Q_BASIC_ATOMIC_INITIALIZER(1);
static QAtomicInt nextFreeTimerId = QAtomicInt(1);
// avoid the ABA-problem by using 7 of the top 8 bits of the timerId as a serial number
static inline int prepareNewValueWithSerialNumber(int oldId, int newId)

View file

@ -149,7 +149,7 @@ inline void qt_ignore_sigpipe()
{
#ifndef Q_NO_POSIX_SIGNALS
// Set to ignore SIGPIPE once only.
static QBasicAtomicInt atom = Q_BASIC_ATOMIC_INITIALIZER(0);
static QAtomicInt atom = QAtomicInt(0);
if (!atom) {
// More than one thread could turn off SIGPIPE at the same time
// But that's acceptable because they all would be doing the same

View file

@ -256,7 +256,7 @@ inline int qRegisterMetaTypeStreamOperators()
enum { Defined = 1 }; \
static int qt_metatype_id() \
{ \
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
static QAtomicInt metatype_id = QAtomicInt(0); \
if (!metatype_id) \
metatype_id = qRegisterMetaType< TYPE >(#TYPE, \
reinterpret_cast< TYPE *>(quintptr(-1))); \

View file

@ -94,8 +94,8 @@ static int *queuedConnectionTypes(const QList<QByteArray> &typeNames)
return types;
}
static QBasicAtomicPointer<QMutexPool> signalSlotMutexes = Q_BASIC_ATOMIC_INITIALIZER(0);
static QBasicAtomicInt objectCount = Q_BASIC_ATOMIC_INITIALIZER(0);
static QAtomicPointer<QMutexPool> signalSlotMutexes = QAtomicPointer<QMutexPool>(0);
static QAtomicInt objectCount = QAtomicInt(0);
/** \internal
* mutex to be locked when accessing the connectionlists or the senders list
@ -111,19 +111,6 @@ static inline QMutex *signalSlotLock(const QObject *o)
return signalSlotMutexes->get(o);
}
extern "C" Q_CORE_EXPORT void qt_addObject(QObject *)
{
objectCount.ref();
}
extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
{
if(!objectCount.deref()) {
QMutexPool *old = signalSlotMutexes.fetchAndStoreAcquire(0);
delete old;
}
}
void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0;
void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0;
void (*QAbstractDeclarativeData::objectNameChanged)(QAbstractDeclarativeData *, QObject *) = 0;
@ -167,11 +154,14 @@ QObjectPrivate::~QObjectPrivate()
if (threadData)
threadData->deref();
delete static_cast<QAbstractDynamicMetaObject*>(metaObject);
QAbstractDynamicMetaObject* mobject = static_cast<QAbstractDynamicMetaObject*>(metaObject);
if (mobject)
delete mobject;
#ifndef QT_NO_USERDATA
if (extraData)
if (extraData) {
qDeleteAll(extraData->userData);
delete extraData;
delete extraData;
}
#endif
}
@ -610,7 +600,7 @@ QObject::QObject(QObject *parent)
QT_RETHROW;
}
}
qt_addObject(this);
objectCount.ref();
}
@ -641,7 +631,7 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent)
QT_RETHROW;
}
}
qt_addObject(this);
objectCount.ref();
}
/*!
@ -774,7 +764,10 @@ QObject::~QObject()
if (!d->children.isEmpty())
d->deleteChildren();
qt_removeObject(this);
if(!objectCount.deref()) {
QMutexPool *old = signalSlotMutexes.fetchAndStoreAcquire(0);
delete old;
}
if (d->parent) // remove it from parent object
d->setParent_helper(0);
@ -2737,7 +2730,7 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index,
c->method_relative = method_index;
c->method_offset = method_offset;
c->connectionType = type;
c->argumentTypes = types;
c->argumentTypes = QAtomicPointer<int>(types);
c->nextConnectionList = 0;
c->callFunction = callFunction;

View file

@ -118,7 +118,7 @@ public:
//senders linked list
Connection *next;
Connection **prev;
QBasicAtomicPointer<int> argumentTypes;
QAtomicPointer<int> argumentTypes;
ushort method_offset;
ushort method_relative;
ushort connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking

View file

@ -833,7 +833,7 @@ QUuid QUuid::createUuid()
static QThreadStorage<int *> uuidseed;
if (!uuidseed.hasLocalData()) {
int *pseed = new int;
static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2);
static QAtomicInt serial = QAtomicInt(2);
qsrand(*pseed = QDateTime::currentDateTime().toTime_t()
+ quintptr(&pseed)
+ serial.fetchAndAddRelaxed(1));

View file

@ -25,4 +25,10 @@ namespace {
}
#endif
static void report_error(int code, const char *where, const char *what)
{
if (code != 0)
qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
}
#endif // QCORECOMMON_P_H

View file

@ -1,118 +1,314 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
/***********************************************************************
*
* Copyright (c) 2012-2016 Barbara Geller
* Copyright (c) 2012-2016 Ansel Sermersheim
* Copyright (c) 2012-2014 Digia Plc and/or its subsidiary(-ies).
* Copyright (c) 2008-2012 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
*
* This file is part of CopperSpice.
*
* CopperSpice is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* CopperSpice is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with CopperSpice. If not, see
* <http://www.gnu.org/licenses/>.
*
***********************************************************************/
#ifndef QATOMIC_H
#define QATOMIC_H
#include <QtCore/qbasicatomic.h>
#include "QtCore/qglobal.h"
QT_BEGIN_HEADER
#include <atomic>
#include <cstddef>
#ifndef ATOMIC_INT_LOCK_FREE
#define ATOMIC_INT_LOCK_FREE 0
#endif
#ifndef ATOMIC_POINTER_LOCK_FREE
#define ATOMIC_POINTER_LOCK_FREE 0
#endif
QT_BEGIN_NAMESPACE
QT_BEGIN_HEADER
// High-level atomic integer operations
class Q_CORE_EXPORT QAtomicInt : public QBasicAtomicInt
{
public:
inline QAtomicInt(int value = 0)
{
#ifdef QT_ARCH_PARISC
this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1;
#endif
_q_value = value;
}
inline QAtomicInt(const QAtomicInt &other)
{
#ifdef QT_ARCH_PARISC
this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1;
#endif
_q_value = other._q_value;
}
class QAtomicInt
{
public:
inline QAtomicInt() : m_data(0) {
}
inline QAtomicInt &operator=(int value)
{
(void) QBasicAtomicInt::operator=(value);
return *this;
}
inline QAtomicInt(int value) : m_data(value) {
}
inline QAtomicInt &operator=(const QAtomicInt &other)
{
(void) QBasicAtomicInt::operator=(other);
return *this;
}
inline QAtomicInt(const QAtomicInt &other) {
int data = other.load();
store(data);
}
inline QAtomicInt &operator=(const QAtomicInt &other) {
int data = other.load();
store(data);
return *this;
}
inline QAtomicInt &operator=(int data) {
store(data);
return *this;
}
int load() const {
return m_data.load();
}
int loadAcquire() {
return m_data.load(std::memory_order_acquire);
}
void store(int newValue) {
m_data.store(newValue);
}
void storeRelease(int newValue) {
m_data.store(newValue, std::memory_order_release);
}
//
static bool isReferenceCountingNative() {
return ATOMIC_INT_LOCK_FREE == 2;
}
static bool isReferenceCountingWaitFree() {
return ATOMIC_INT_LOCK_FREE == 2;
}
bool ref() {
int newValue = ++m_data;
return newValue != 0;
}
bool deref() {
int newValue = --m_data;
return newValue != 0;
}
//
static bool isTestAndSetNative() {
return ATOMIC_INT_LOCK_FREE == 2;
}
static bool isTestAndSetWaitFree() {
return ATOMIC_INT_LOCK_FREE == 2;
}
bool testAndSetRelaxed(int expectedValue, int newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
}
bool testAndSetAcquire(int expectedValue, int newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire);
}
bool testAndSetRelease(int expectedValue, int newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_release);
}
bool testAndSetOrdered(int expectedValue, int newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_seq_cst);
}
//
static bool isFetchAndStoreNative() {
return ATOMIC_INT_LOCK_FREE == 2;
}
static bool isFetchAndStoreWaitFree() {
return ATOMIC_INT_LOCK_FREE == 2;
}
int fetchAndStoreRelaxed(int newValue) {
return m_data.exchange(newValue, std::memory_order_relaxed);
}
int fetchAndStoreAcquire(int newValue) {
return m_data.exchange(newValue, std::memory_order_acquire);
}
int fetchAndStoreRelease(int newValue) {
return m_data.exchange(newValue, std::memory_order_release);
}
int fetchAndStoreOrdered(int newValue) {
return m_data.exchange(newValue, std::memory_order_seq_cst);
}
//
static bool isFetchAndAddNative() {
return ATOMIC_INT_LOCK_FREE == 2;
}
static bool isFetchAndAddWaitFree() {
return ATOMIC_INT_LOCK_FREE == 2;
}
int fetchAndAddRelaxed(int valueToAdd) {
return m_data.fetch_add(valueToAdd, std::memory_order_relaxed);
}
int fetchAndAddAcquire(int valueToAdd) {
return m_data.fetch_add(valueToAdd, std::memory_order_acquire);
}
int fetchAndAddRelease(int valueToAdd) {
return m_data.fetch_add(valueToAdd, std::memory_order_release);
}
int fetchAndAddOrdered(int valueToAdd) {
return m_data.fetch_add(valueToAdd, std::memory_order_seq_cst);
}
inline operator int() const
{ return load(); }
private:
std::atomic<int> m_data;
};
// High-level atomic pointer operations
template <typename T>
class QAtomicPointer : public QBasicAtomicPointer<T>
class QAtomicPointer
{
public:
inline QAtomicPointer(T *value = 0)
{
#ifdef QT_ARCH_PARISC
this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1;
#endif
QBasicAtomicPointer<T>::_q_value = value;
}
inline QAtomicPointer(const QAtomicPointer<T> &other)
{
#ifdef QT_ARCH_PARISC
this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1;
#endif
QBasicAtomicPointer<T>::_q_value = other._q_value;
}
public:
QAtomicPointer(T *value = 0) : m_data(value) {
}
inline QAtomicPointer<T> &operator=(T *value)
{
(void) QBasicAtomicPointer<T>::operator=(value);
return *this;
}
QAtomicPointer(const QAtomicPointer<T> &other) {
T *data = other.load();
store(data);
}
inline QAtomicPointer<T> &operator=(const QAtomicPointer<T> &other)
{
(void) QBasicAtomicPointer<T>::operator=(other);
return *this;
}
QAtomicPointer<T> &operator=(const QAtomicPointer<T> &other) {
T *data = other.load();
store(data);
return *this;
}
QAtomicPointer<T> &operator=(T *data) {
store(data);
return *this;
}
T *load() const {
return m_data.load();
}
T *loadAcquire() {
return m_data.load(std::memory_order_acquire);
}
void store(T *newValue) {
m_data.store(newValue);
}
void storeRelease(T *newValue) {
m_data.store(newValue, std::memory_order_release);
}
//
static bool isTestAndSetNative() {
return ATOMIC_POINTER_LOCK_FREE == 2;
}
static bool isTestAndSetWaitFree() {
return ATOMIC_POINTER_LOCK_FREE == 2;
}
bool testAndSetRelaxed(T *expectedValue, T *newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
}
bool testAndSetAcquire(T *expectedValue, T *newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire);
}
bool testAndSetRelease(T *expectedValue, T *newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_release);
}
bool testAndSetOrdered(T *expectedValue, T *newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_seq_cst);
}
//
static bool isFetchAndStoreNative() {
return ATOMIC_POINTER_LOCK_FREE == 2;
}
static bool isFetchAndStoreWaitFree() {
return ATOMIC_POINTER_LOCK_FREE == 2;
}
T *fetchAndStoreRelaxed(T *newValue) {
return m_data.exchange(newValue, std::memory_order_relaxed);
}
T *fetchAndStoreAcquire(T *newValue) {
return m_data.exchange(newValue, std::memory_order_acquire);
}
T *fetchAndStoreRelease(T *newValue) {
return m_data.exchange(newValue, std::memory_order_release);
}
T *fetchAndStoreOrdered(T *newValue) {
return m_data.exchange(newValue, std::memory_order_seq_cst);
}
//
static bool isFetchAndAddNative() {
return ATOMIC_POINTER_LOCK_FREE == 2;
}
static bool isFetchAndAddWaitFree() {
return ATOMIC_POINTER_LOCK_FREE == 2;
}
T *fetchAndAddRelaxed(std::ptrdiff_t valueToAdd) {
return m_data.fetch_add(valueToAdd, std::memory_order_relaxed);
}
T *fetchAndAddAcquire(std::ptrdiff_t valueToAdd) {
return m_data.fetch_add(valueToAdd, std::memory_order_acquire);
}
T *fetchAndAddRelease(std::ptrdiff_t valueToAdd){
return m_data.fetch_add(valueToAdd, std::memory_order_release);
}
T *fetchAndAddOrdered(std::ptrdiff_t valueToAdd){
return m_data.fetch_add(valueToAdd, std::memory_order_seq_cst);
}
inline operator T *() const
{ return load(); }
inline T *operator->() const
{ return load(); }
private:
std::atomic<T *> m_data;
};
/*!
@ -124,12 +320,16 @@ public:
template <typename T>
inline void qAtomicAssign(T *&d, T *x)
{
if (d == x)
return;
x->ref.ref();
if (!d->ref.deref())
delete d;
d = x;
if (d == x) {
return;
}
x->ref.ref();
if (! d->ref.deref()) {
delete d;
}
d = x;
}
/*!
@ -143,12 +343,16 @@ inline void qAtomicAssign(T *&d, T *x)
template <typename T>
inline void qAtomicDetach(T *&d)
{
if (d->ref == 1)
return;
T *x = d;
d = new T(*d);
if (!x->ref.deref())
delete x;
if (d->ref.load() == 1) {
return;
}
T *x = d;
d = new T(*d);
if (! x->ref.deref()) {
delete x;
}
}
QT_END_NAMESPACE

View file

@ -1,186 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBASICATOMIC_H
#define QBASICATOMIC_H
#include <QtCore/qglobal.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QBasicAtomicInt
{
public:
#ifdef QT_ARCH_PARISC
int _q_lock[4];
#endif
volatile int _q_value;
// Non-atomic API
inline bool operator==(int value) const
{
return _q_value == value;
}
inline bool operator!=(int value) const
{
return _q_value != value;
}
inline bool operator!() const
{
return _q_value == 0;
}
inline operator int() const
{
return _q_value;
}
inline QBasicAtomicInt &operator=(int value)
{
#ifdef QT_ARCH_PARISC
this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1;
#endif
_q_value = value;
return *this;
}
// Atomic API, implemented in qatomic_generic.h
bool ref();
bool deref();
bool testAndSetRelaxed(int expectedValue, int newValue);
bool testAndSetAcquire(int expectedValue, int newValue);
bool testAndSetRelease(int expectedValue, int newValue);
bool testAndSetOrdered(int expectedValue, int newValue);
int fetchAndStoreRelaxed(int newValue);
int fetchAndStoreAcquire(int newValue);
int fetchAndStoreRelease(int newValue);
int fetchAndStoreOrdered(int newValue);
int fetchAndAddRelaxed(int valueToAdd);
int fetchAndAddAcquire(int valueToAdd);
int fetchAndAddRelease(int valueToAdd);
int fetchAndAddOrdered(int valueToAdd);
};
template <typename T>
class QBasicAtomicPointer
{
public:
#ifdef QT_ARCH_PARISC
int _q_lock[4];
#endif
T * volatile _q_value;
// Non-atomic API
inline bool operator==(T *value) const
{
return _q_value == value;
}
inline bool operator!=(T *value) const
{
return !operator==(value);
}
inline bool operator!() const
{
return operator==(0);
}
inline operator T *() const
{
return _q_value;
}
inline T *operator->() const
{
return _q_value;
}
inline QBasicAtomicPointer<T> &operator=(T *value)
{
#ifdef QT_ARCH_PARISC
this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1;
#endif
_q_value = value;
return *this;
}
// Atomic API, implemented in qatomic_generic.h
bool testAndSetRelaxed(T *expectedValue, T *newValue);
bool testAndSetAcquire(T *expectedValue, T *newValue);
bool testAndSetRelease(T *expectedValue, T *newValue);
bool testAndSetOrdered(T *expectedValue, T *newValue);
T *fetchAndStoreRelaxed(T *newValue);
T *fetchAndStoreAcquire(T *newValue);
T *fetchAndStoreRelease(T *newValue);
T *fetchAndStoreOrdered(T *newValue);
T *fetchAndAddRelaxed(qptrdiff valueToAdd);
T *fetchAndAddAcquire(qptrdiff valueToAdd);
T *fetchAndAddRelease(qptrdiff valueToAdd);
T *fetchAndAddOrdered(qptrdiff valueToAdd);
};
#ifdef QT_ARCH_PARISC
# define Q_BASIC_ATOMIC_INITIALIZER(a) {{-1,-1,-1,-1},(a)}
#else
# define Q_BASIC_ATOMIC_INITIALIZER(a) { (a) }
#endif
QT_END_NAMESPACE
#if defined(QT_BOOTSTRAPPED)
# include <qatomic_bootstrap.h>
#else
# include "QtCore/qatomic_generic.h"
#endif
QT_END_HEADER
#endif // QBASIC_ATOMIC

View file

@ -76,11 +76,9 @@ public:
const uint recursive : 1;
QAtomicInt contenders;
#if !defined(Q_OS_LINUX) || defined(QT_LINUXBASE)
volatile bool wakeup;
pthread_mutex_t mutex;
pthread_cond_t cond;
#endif
};
QT_END_NAMESPACE

View file

@ -46,6 +46,7 @@
#ifndef QT_NO_THREAD
#include "qatomic.h"
#include "qmutex_p.h"
#include "qcorecommon_p.h"
#include <errno.h>
@ -53,91 +54,22 @@
#undef wakeup
#endif
#if defined(Q_OS_MAC)
# include <mach/mach.h>
# include <mach/task.h>
#elif defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
# include <linux/futex.h>
# include <sys/syscall.h>
# include <unistd.h>
# include <QtCore/qelapsedtimer.h>
#endif
QT_BEGIN_NAMESPACE
#if !defined(Q_OS_LINUX) || defined(QT_LINUXBASE)
static void report_error(int code, const char *where, const char *what)
{
if (code != 0)
qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
}
#endif
QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
: maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0), recursive(mode == QMutex::Recursive)
{
#if !defined(Q_OS_LINUX) || defined(QT_LINUXBASE)
wakeup = false;
report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
#endif
}
QMutexPrivate::~QMutexPrivate()
{
#if !defined(Q_OS_LINUX) || defined(QT_LINUXBASE)
report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
#endif
}
#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
static inline int _q_futex(volatile int *addr, int op, int val, const struct timespec *timeout, int *addr2, int val2)
{
return syscall(SYS_futex, addr, op, val, timeout, addr2, val2);
}
bool QMutexPrivate::wait(int timeout)
{
struct timespec ts, *pts = 0;
QElapsedTimer timer;
if (timeout >= 0) {
ts.tv_nsec = ((timeout % 1000) * 1000) * 1000;
ts.tv_sec = (timeout / 1000);
pts = &ts;
timer.start();
}
while (contenders.fetchAndStoreAcquire(2) > 0) {
int r = _q_futex(&contenders._q_value, FUTEX_WAIT, 2, pts, 0, 0);
if (r != 0 && errno == ETIMEDOUT)
return false;
if (pts) {
// recalculate the timeout
qint64 xtimeout = timeout * 1000 * 1000;
xtimeout -= timer.nsecsElapsed();
if (xtimeout < 0) {
// timer expired after we returned
return false;
}
ts.tv_sec = xtimeout / Q_INT64_C(1000) / 1000 / 1000;
ts.tv_nsec = xtimeout % (Q_INT64_C(1000) * 1000 * 1000);
}
}
return true;
}
void QMutexPrivate::wakeUp()
{
(void) contenders.fetchAndStoreRelease(0);
(void) _q_futex(&contenders._q_value, FUTEX_WAKE, 1, 0, 0, 0);
}
#else // !Q_OS_LINUX || QT_LINUXBASE
bool QMutexPrivate::wait(int timeout)
{
if (contenders.fetchAndAddAcquire(1) == 0) {
@ -183,8 +115,6 @@ void QMutexPrivate::wakeUp()
report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock");
}
#endif // !Q_OS_LINUX || QT_LINUXBASE
QT_END_NAMESPACE
#endif // QT_NO_THREAD

View file

@ -48,6 +48,7 @@
#include "qmutex_p.h"
#include "qreadwritelock_p.h"
#include "qcorecommon_p.h"
#include <errno.h>
@ -55,12 +56,6 @@
QT_BEGIN_NAMESPACE
static void report_error(int code, const char *where, const char *what)
{
if (code != 0)
qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
}
class QWaitConditionPrivate {
public:
pthread_mutex_t mutex;

View file

@ -13,8 +13,6 @@ set(CORE_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/thread/qorderedmutexlocker_p.h
${CMAKE_CURRENT_SOURCE_DIR}/thread/qreadwritelock_p.h
${CMAKE_CURRENT_SOURCE_DIR}/thread/qthread_p.h
${CMAKE_CURRENT_SOURCE_DIR}/thread/qbasicatomic.h
)
set(CORE_SOURCES

View file

@ -54,20 +54,6 @@ QT_BEGIN_NAMESPACE
*/
namespace QAlgorithmsPrivate {
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan);
template <typename RandomAccessIterator, typename T>
inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy);
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan);
template <typename RandomAccessIterator, typename T>
inline void qStableSortHelper(RandomAccessIterator, RandomAccessIterator, const T &);
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
@ -76,71 +62,37 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator
template <typename InputIterator, typename OutputIterator>
inline OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest)
{
#ifndef QT_NO_STL
return std::copy(begin, end, dest);
#else
while (begin != end)
*dest++ = *begin++;
return dest;
#endif
}
template <typename BiIterator1, typename BiIterator2>
inline BiIterator2 qCopyBackward(BiIterator1 begin, BiIterator1 end, BiIterator2 dest)
{
#ifndef QT_NO_STL
return std::copy_backward(begin, end, dest);
#else
while (begin != end)
*--dest = *--end;
return dest;
#endif
}
template <typename InputIterator1, typename InputIterator2>
inline bool qEqual(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
{
#ifndef QT_NO_STL
return std::equal(first1, last1, first2);
#else
for (; first1 != last1; ++first1, ++first2)
if (!(*first1 == *first2))
return false;
return true;
#endif
}
template <typename ForwardIterator, typename T>
inline void qFill(ForwardIterator first, ForwardIterator last, const T &val)
{
#ifndef QT_NO_STL
return std::fill(first, last, val);
#else
for (; first != last; ++first)
*first = val;
#endif
}
template <typename Container, typename T>
inline void qFill(Container &container, const T &val)
{
#ifndef QT_NO_STL
return std::fill_n(container, val);
#else
qFill(container.begin(), container.end(), val);
#endif
}
template <typename InputIterator, typename T>
inline InputIterator qFind(InputIterator first, InputIterator last, const T &val)
{
#ifndef QT_NO_STL
return std::find(first, last, val);
#else
while (first != last && !(*first == val))
++first;
return first;
#endif
}
template <typename Container, typename T>
@ -152,13 +104,7 @@ inline typename Container::const_iterator qFind(const Container &container, cons
template <typename InputIterator, typename T, typename Size>
inline void qCount(InputIterator first, InputIterator last, const T &value, Size &n)
{
#ifndef QT_NO_STL
return std::count(first, last, n);
#else
for (; first != last; ++first)
if (*first == value)
++n;
#endif
}
template <typename Container, typename T, typename Size>
@ -191,14 +137,14 @@ template <typename RandomAccessIterator>
inline void qSort(RandomAccessIterator start, RandomAccessIterator end)
{
if (start != end)
QAlgorithmsPrivate::qSortHelper(start, end, *start);
std::sort(start, end);
}
template <typename RandomAccessIterator, typename LessThan>
inline void qSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
{
if (start != end)
QAlgorithmsPrivate::qSortHelper(start, end, *start, lessThan);
std::sort(start, end, lessThan);
}
template<typename Container>
@ -209,21 +155,21 @@ inline void qSort(Container &c)
c.detach();
#endif
if (!c.empty())
QAlgorithmsPrivate::qSortHelper(c.begin(), c.end(), *c.begin());
std::sort(c.begin(), c.end());
}
template <typename RandomAccessIterator>
inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end)
{
if (start != end)
QAlgorithmsPrivate::qStableSortHelper(start, end, *start);
std::stable_sort(start, end);
}
template <typename RandomAccessIterator, typename LessThan>
inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
{
if (start != end)
QAlgorithmsPrivate::qStableSortHelper(start, end, *start, lessThan);
std::stable_sort(start, end, lessThan);
}
template<typename Container>
@ -234,7 +180,7 @@ inline void qStableSort(Container &c)
c.detach();
#endif
if (!c.empty())
QAlgorithmsPrivate::qStableSortHelper(c.begin(), c.end(), *c.begin());
std::stable_sort(c.begin(), c.end());
}
template <typename RandomAccessIterator, typename T>
@ -261,15 +207,15 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin
}
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
inline RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
return QAlgorithmsPrivate::qLowerBoundHelper(begin, end, value, lessThan);
return std::lower_bound(begin, end, value, lessThan);
}
template <typename Container, typename T>
Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qLowerBound(const Container &container, const T &value)
inline typename Container::const_iterator qLowerBound(const Container &container, const T &value)
{
return QAlgorithmsPrivate::qLowerBoundHelper(container.constBegin(), container.constEnd(), value, qLess<T>());
return std::lower_bound(container.constBegin(), container.constEnd(), value, qLess<T>());
}
template <typename RandomAccessIterator, typename T>
@ -294,15 +240,15 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin
}
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
inline RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
return QAlgorithmsPrivate::qUpperBoundHelper(begin, end, value, lessThan);
return std::upper_bound(begin, end, value, lessThan);
}
template <typename Container, typename T>
Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qUpperBound(const Container &container, const T &value)
inline typename Container::const_iterator qUpperBound(const Container &container, const T &value)
{
return QAlgorithmsPrivate::qUpperBoundHelper(container.constBegin(), container.constEnd(), value, qLess<T>());
return std::upper_bound(container.constBegin(), container.constEnd(), value, qLess<T>());
}
template <typename RandomAccessIterator, typename T>
@ -350,70 +296,6 @@ inline void qDeleteAll(const Container &c)
*/
namespace QAlgorithmsPrivate {
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
{
#ifndef QT_NO_STL
Q_UNUSED(t);
std::sort(start, end, lessThan);
#else
top:
int span = int(end - start);
if (span < 2)
return;
--end;
RandomAccessIterator low = start, high = end - 1;
RandomAccessIterator pivot = start + span / 2;
if (lessThan(*end, *start))
qSwap(*end, *start);
if (span == 2)
return;
if (lessThan(*pivot, *start))
qSwap(*pivot, *start);
if (lessThan(*end, *pivot))
qSwap(*end, *pivot);
if (span == 3)
return;
qSwap(*pivot, *end);
while (low < high) {
while (low < high && lessThan(*low, *end))
++low;
while (high > low && lessThan(*end, *high))
--high;
if (low < high) {
qSwap(*low, *high);
++low;
--high;
} else {
break;
}
}
if (lessThan(*low, *end))
++low;
qSwap(*end, *low);
qSortHelper(start, low, t, lessThan);
start = low + 1;
++end;
goto top;
#endif
}
template <typename RandomAccessIterator, typename T>
inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy)
{
qSortHelper(begin, end, dummy, qLess<T>());
}
template <typename RandomAccessIterator>
Q_OUTOFLINE_TEMPLATE void qReverse(RandomAccessIterator begin, RandomAccessIterator end)
{
@ -465,86 +347,10 @@ Q_OUTOFLINE_TEMPLATE void qMerge(RandomAccessIterator begin, RandomAccessIterato
qMerge(newPivot, secondCut, end, t, lessThan);
}
template <typename RandomAccessIterator, typename T, typename LessThan>
#ifndef QT_NO_STL
Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T & , LessThan lessThan)
#else
Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &t, LessThan lessThan)
#endif
{
#ifndef QT_NO_STL
std::stable_sort(begin, end, lessThan);
#else
const int span = end - begin;
if (span < 2)
return;
const RandomAccessIterator middle = begin + span / 2;
qStableSortHelper(begin, middle, t, lessThan);
qStableSortHelper(middle, end, t, lessThan);
qMerge(begin, middle, end, t, lessThan);
#endif
}
template <typename RandomAccessIterator, typename T>
inline void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy)
{
qStableSortHelper(begin, end, dummy, qLess<T>());
}
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
#ifndef QT_NO_STL
return std::lower_bound(begin, end, value, lessThan);
#else
RandomAccessIterator middle;
int n = int(end - begin);
int half;
while (n > 0) {
half = n >> 1;
middle = begin + half;
if (lessThan(*middle, value)) {
begin = middle + 1;
n -= half + 1;
} else {
n = half;
}
}
return begin;
#endif
}
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
#ifndef QT_NO_STL
return std::upper_bound(begin, end, value, lessThan);
#else
RandomAccessIterator middle;
int n = end - begin;
int half;
while (n > 0) {
half = n >> 1;
middle = begin + half;
if (lessThan(value, *middle)) {
n = half;
} else {
begin = middle + 1;
n -= half + 1;
}
}
return begin;
#endif
}
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
RandomAccessIterator it = qLowerBoundHelper(begin, end, value, lessThan);
RandomAccessIterator it = qLowerBound(begin, end, value, lessThan);
if (it == end || lessThan(value, *it))
return end;

View file

@ -589,9 +589,9 @@ QByteArray qUncompress(const uchar* data, int nbytes)
}
#endif
QByteArray::Data QByteArray::shared_null = {Q_BASIC_ATOMIC_INITIALIZER(1),
0, 0, shared_null.array, {0} };
QByteArray::Data QByteArray::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1),
QByteArray::Data QByteArray::shared_null = { QAtomicInt(1),
0, 0, shared_null.array, {0} };
QByteArray::Data QByteArray::shared_empty = { QAtomicInt(1),
0, 0, shared_empty.array, {0} };
/*!

View file

@ -47,27 +47,12 @@
#include <string.h>
#include <stdarg.h>
#ifndef QT_NO_STL
# include <string>
#endif
#include <string>
#ifdef truncate
#error qbytearray.h must be included before any header file that defines truncate
#endif
#if defined(Q_CC_GNU) && (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
//There is a bug in GCC 4.0 that tries to instantiate template of annonymous enum
# ifdef QT_USE_FAST_OPERATOR_PLUS
# undef QT_USE_FAST_OPERATOR_PLUS
# endif
# ifdef QT_USE_QSTRINGBUILDER
# undef QT_USE_QSTRINGBUILDER
# endif
#endif
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@ -126,7 +111,7 @@ class Q_CORE_EXPORT QByteArray
{
private:
struct Data {
QBasicAtomicInt ref;
QAtomicInt ref;
int alloc, size;
char *data;
char array[1];
@ -327,10 +312,8 @@ public:
void push_front(const char *c);
void push_front(const QByteArray &a);
#ifndef QT_NO_STL
static inline QByteArray fromStdString(const std::string &s);
inline std::string toStdString() const;
#endif
inline int count() const { return d->size; }
int length() const { return d->size; }
@ -532,13 +515,11 @@ inline QByteArray &QByteArray::setNum(uint n, int base)
inline QByteArray &QByteArray::setNum(float n, char f, int prec)
{ return setNum(double(n),f,prec); }
#ifndef QT_NO_STL
inline std::string QByteArray::toStdString() const
{ return std::string(constData(), length()); }
inline QByteArray QByteArray::fromStdString(const std::string &s)
{ return QByteArray(s.data(), int(s.size())); }
#endif
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QByteArray &);

View file

@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
struct Q_CORE_EXPORT QContiguousCacheData
{
QBasicAtomicInt ref;
QAtomicInt ref;
int alloc;
int count;
int start;

View file

@ -166,7 +166,7 @@ static int countBits(int hint)
const int MinNumBits = 4;
QHashData QHashData::shared_null = {
0, 0, Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, MinNumBits, 0, 0, true
0, 0, QAtomicInt(1), 0, 0, MinNumBits, 0, 0, true
};
QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),

View file

@ -106,7 +106,7 @@ struct Q_CORE_EXPORT QHashData
Node *fakeNext;
Node **buckets;
QBasicAtomicInt ref;
QAtomicInt ref;
int size;
int nodeSize;
short userNumBits;

View file

@ -46,36 +46,6 @@
QT_BEGIN_HEADER
#ifdef QT_NO_STL
# include <new> // No-op, indirectly include additional configuration headers.
# if defined(_LIBCPP_VERSION)
// libc++ may declare these structs in an inline namespace. Forward-declare
// these iterators in the same namespace so that we do not shadow the original
// declarations.
// Tell clang not to warn about the use of inline namespaces when not building
// in C++11 mode.
# if defined(Q_CC_CLANG)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wc++11-extensions"
# endif
_LIBCPP_BEGIN_NAMESPACE_STD
struct bidirectional_iterator_tag;
struct random_access_iterator_tag;
_LIBCPP_END_NAMESPACE_STD
# if defined(Q_CC_CLANG)
# pragma GCC diagnostic pop
# endif
# else
namespace std {
struct bidirectional_iterator_tag;
struct random_access_iterator_tag;
}
# endif
#endif
QT_BEGIN_NAMESPACE

View file

@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
QLinkedListData QLinkedListData::shared_null = {
&QLinkedListData::shared_null, &QLinkedListData::shared_null,
Q_BASIC_ATOMIC_INITIALIZER(1), 0, true
QAtomicInt(1), 0, true
};
/*! \class QLinkedList

View file

@ -45,10 +45,8 @@
#include <QtCore/qiterator.h>
#include <QtCore/qatomic.h>
#ifndef QT_NO_STL
#include <iterator>
#include <list>
#endif
QT_BEGIN_HEADER
@ -58,7 +56,7 @@ QT_BEGIN_NAMESPACE
struct Q_CORE_EXPORT QLinkedListData
{
QLinkedListData *n, *p;
QBasicAtomicInt ref;
QAtomicInt ref;
int size;
uint sharable : 1;
@ -219,12 +217,10 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
#ifndef QT_NO_STL
static inline QLinkedList<T> fromStdList(const std::list<T> &list)
{ QLinkedList<T> tmp; qCopy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; }
inline std::list<T> toStdList() const
{ std::list<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
#endif
// comfort

View file

@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
the number of elements in the list.
*/
QListData::Data QListData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, true, { 0 } };
QListData::Data QListData::shared_null = { QAtomicInt(1), 0, 0, 0, true, { 0 } };
static int grow(int size)
{

View file

@ -46,10 +46,8 @@
#include <QtCore/qatomic.h>
#include <QtCore/qalgorithms.h>
#ifndef QT_NO_STL
#include <iterator>
#include <list>
#endif
#ifdef Q_COMPILER_INITIALIZER_LISTS
#include <iterator>
#include <initializer_list>
@ -69,7 +67,7 @@ template <typename T> class QSet;
struct Q_CORE_EXPORT QListData {
struct Data {
QBasicAtomicInt ref;
QAtomicInt ref;
int alloc, begin, end;
uint sharable : 1;
void *array[1];
@ -324,12 +322,10 @@ public:
static QList<T> fromVector(const QVector<T> &vector);
static QList<T> fromSet(const QSet<T> &set);
#ifndef QT_NO_STL
static inline QList<T> fromStdList(const std::list<T> &list)
{ QList<T> tmp; qCopy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; }
inline std::list<T> toStdList() const
{ std::list<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
#endif
private:
Node *detach_helper_grow(int i, int n);

View file

@ -60,7 +60,6 @@
#include "qvariant.h"
#include "qstringbuilder.h"
#include "qnumeric.h"
#include "qnumeric_p.h"
QT_BEGIN_NAMESPACE
@ -2973,13 +2972,13 @@ double QLocalePrivate::bytearrayToDouble(const char *num, bool *ok, bool *overfl
}
if (qstrcmp(num, "nan") == 0)
return qt_snan();
return qSNaN();
if (qstrcmp(num, "+inf") == 0 || qstrcmp(num, "inf") == 0)
return qt_inf();
return qInf();
if (qstrcmp(num, "-inf") == 0)
return -qt_inf();
return -qInf();
bool _ok;
const char *endptr;

View file

@ -68,8 +68,8 @@
QT_BEGIN_NAMESPACE
#ifndef QT_QLOCALE_USES_FCVT
static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt,
int *sign, char **rve, char **digits_str);
static char *_qdtoa( double d, int mode, int ndigits, int *decpt,
int *sign, char **rve, char **digits_str);
#endif
QString qulltoa(qulonglong l, int base, const QChar _zero)
@ -597,9 +597,9 @@ QT_END_INCLUDE_NAMESPACE
#error Exactly one of IEEE_BIG_OR_LITTLE_ENDIAN, VAX, or IBM should be defined.
#endif
static inline ULong _getWord0(const NEEDS_VOLATILE double x)
static inline ULong _getWord0(const double x)
{
const NEEDS_VOLATILE uchar *ptr = reinterpret_cast<const NEEDS_VOLATILE uchar *>(&x);
const uchar *ptr = reinterpret_cast<const uchar *>(&x);
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3];
} else {
@ -607,9 +607,9 @@ static inline ULong _getWord0(const NEEDS_VOLATILE double x)
}
}
static inline void _setWord0(NEEDS_VOLATILE double *x, ULong l)
static inline void _setWord0(double *x, ULong l)
{
NEEDS_VOLATILE uchar *ptr = reinterpret_cast<NEEDS_VOLATILE uchar *>(x);
uchar *ptr = reinterpret_cast<uchar *>(x);
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
ptr[0] = uchar(l>>24);
ptr[1] = uchar(l>>16);
@ -623,18 +623,18 @@ static inline void _setWord0(NEEDS_VOLATILE double *x, ULong l)
}
}
static inline ULong _getWord1(const NEEDS_VOLATILE double x)
static inline ULong _getWord1(const double x)
{
const NEEDS_VOLATILE uchar *ptr = reinterpret_cast<const NEEDS_VOLATILE uchar *>(&x);
const uchar *ptr = reinterpret_cast<const uchar *>(&x);
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
return (ptr[4]<<24) + (ptr[5]<<16) + (ptr[6]<<8) + ptr[7];
} else {
return (ptr[3]<<24) + (ptr[2]<<16) + (ptr[1]<<8) + ptr[0];
}
}
static inline void _setWord1(NEEDS_VOLATILE double *x, ULong l)
static inline void _setWord1(double *x, ULong l)
{
NEEDS_VOLATILE uchar *ptr = reinterpret_cast<uchar NEEDS_VOLATILE *>(x);
uchar *ptr = reinterpret_cast<uchar *>(x);
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
ptr[4] = uchar(l>>24);
ptr[5] = uchar(l>>16);
@ -648,7 +648,7 @@ static inline void _setWord1(NEEDS_VOLATILE double *x, ULong l)
}
}
static inline ULong getWord0(const NEEDS_VOLATILE double x)
static inline ULong getWord0(const double x)
{
#ifdef QT_ARMFPA
return _getWord1(x);
@ -657,7 +657,7 @@ static inline ULong getWord0(const NEEDS_VOLATILE double x)
#endif
}
static inline void setWord0(NEEDS_VOLATILE double *x, ULong l)
static inline void setWord0(double *x, ULong l)
{
#ifdef QT_ARMFPA
_setWord1(x, l);
@ -666,7 +666,7 @@ static inline void setWord0(NEEDS_VOLATILE double *x, ULong l)
#endif
}
static inline ULong getWord1(const NEEDS_VOLATILE double x)
static inline ULong getWord1(const double x)
{
#ifdef QT_ARMFPA
return _getWord0(x);
@ -675,7 +675,7 @@ static inline ULong getWord1(const NEEDS_VOLATILE double x)
#endif
}
static inline void setWord1(NEEDS_VOLATILE double *x, ULong l)
static inline void setWord1(double *x, ULong l)
{
#ifdef QT_ARMFPA
_setWord0(x, l);
@ -2265,7 +2265,7 @@ Q_CORE_EXPORT char *qdtoa ( double d, int mode, int ndigits, int *decpt, int *si
return s;
}
static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp)
static char *_qdtoa( double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp)
{
/*
Arguments ndigits, decpt, sign are similar to those

View file

@ -56,18 +56,6 @@
#include "qlocale_p.h"
#include "qstring.h"
#if !defined(QT_QLOCALE_NEEDS_VOLATILE)
# if defined(Q_CC_GNU) && __GNUC__ == 4
# define QT_QLOCALE_NEEDS_VOLATILE
# endif
#endif
#if defined(QT_QLOCALE_NEEDS_VOLATILE)
# define NEEDS_VOLATILE volatile
#else
# define NEEDS_VOLATILE
#endif
QT_BEGIN_NAMESPACE
QString qulltoa(qulonglong l, int base, const QChar _zero);

View file

@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
QMapData QMapData::shared_null = {
&shared_null,
{ &shared_null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, false, true
QAtomicInt(1), 0, 0, 0, false, true
};
QMapData *QMapData::createData()

View file

@ -46,10 +46,7 @@
#include <QtCore/qiterator.h>
#include <QtCore/qlist.h>
#ifndef QT_NO_STL
#include <map>
#endif
#include <new>
QT_BEGIN_HEADER
@ -67,7 +64,7 @@ struct Q_CORE_EXPORT QMapData
QMapData *backward;
QMapData *forward[QMapData::LastLevel + 1];
QBasicAtomicInt ref;
QAtomicInt ref;
int topLevel;
int size;
uint randomBits;
@ -178,10 +175,8 @@ public:
{ qSwap(d, other.d); return *this; }
#endif
inline void swap(QMap<Key, T> &other) { qSwap(d, other.d); }
#ifndef QT_NO_STL
explicit QMap(const typename std::map<Key, T> &other);
std::map<Key, T> toStdMap() const;
#endif
bool operator==(const QMap<Key, T> &other) const;
inline bool operator!=(const QMap<Key, T> &other) const { return !(*this == other); }
@ -882,7 +877,6 @@ Q_OUTOFLINE_TEMPLATE bool QMap<Key, T>::operator==(const QMap<Key, T> &other) co
return true;
}
#ifndef QT_NO_STL
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QMap<Key, T>::QMap(const std::map<Key, T> &other)
{
@ -908,8 +902,6 @@ Q_OUTOFLINE_TEMPLATE std::map<Key, T> QMap<Key, T>::toStdMap() const
return map;
}
#endif // QT_NO_STL
template <class Key, class T>
class QMultiMap : public QMap<Key, T>
{

View file

@ -178,7 +178,6 @@ template <class T, class Cleanup>
Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2)
{ p1.swap(p2); }
#ifndef QT_NO_STL
QT_END_NAMESPACE
namespace std {
template <class T, class Cleanup>
@ -186,8 +185,6 @@ namespace std {
{ p1.swap(p2); }
}
QT_BEGIN_NAMESPACE
#endif
namespace QtPrivate {

View file

@ -263,8 +263,8 @@ template <class T>
Q_INLINE_TEMPLATE void qSwap(QExplicitlySharedDataPointer<T> &p1, QExplicitlySharedDataPointer<T> &p2)
{ p1.swap(p2); }
#ifndef QT_NO_STL
QT_END_NAMESPACE
namespace std {
template <class T>
Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p2)
@ -274,10 +274,6 @@ namespace std {
Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p2)
{ p1.swap(p2); }
}
QT_BEGIN_NAMESPACE
#endif
QT_END_NAMESPACE
QT_END_HEADER

View file

@ -156,8 +156,8 @@ namespace QtSharedPointer {
// the ExternalRefCountData object.
struct ExternalRefCountData
{
QBasicAtomicInt weakref;
QBasicAtomicInt strongref;
QAtomicInt weakref;
QAtomicInt strongref;
inline ExternalRefCountData()
{
@ -740,7 +740,6 @@ inline void qSwap(QSharedPointer<T> &p1, QSharedPointer<T> &p2)
p1.swap(p2);
}
#ifndef QT_NO_STL
QT_END_NAMESPACE
namespace std {
template <class T>
@ -748,7 +747,6 @@ namespace std {
{ p1.swap(p2); }
}
QT_BEGIN_NAMESPACE
#endif
namespace QtSharedPointer {
// helper functions:

View file

@ -723,9 +723,9 @@ const QString::Null QString::null = { };
\sa split()
*/
QString::Data QString::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1),
QString::Data QString::shared_null = { QAtomicInt(1),
0, 0, shared_null.array, 0, {0} };
QString::Data QString::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1),
QString::Data QString::shared_empty = { QAtomicInt(1),
0, 0, shared_empty.array, 0, {0} };
int QString::grow(int size)

View file

@ -47,15 +47,11 @@
#include <QtCore/qatomic.h>
#include <QtCore/qnamespace.h>
#ifndef QT_NO_STL
# include <string>
# ifndef QT_NO_STL_WCHAR
#include <string>
#ifndef QT_NO_STL_WCHAR
// workaround for some headers not typedef'ing std::wstring
typedef std::basic_string<wchar_t> QStdWString;
# endif // QT_NO_STL_WCHAR
#endif // QT_NO_STL
#endif // QT_NO_STL_WCHAR
#include <stdarg.h>
@ -473,14 +469,12 @@ public:
inline void push_front(QChar c) { prepend(c); }
inline void push_front(const QString &s) { prepend(s); }
#ifndef QT_NO_STL
static inline QString fromStdString(const std::string &s);
inline std::string toStdString() const;
# ifndef QT_NO_STL_WCHAR
#ifndef QT_NO_STL_WCHAR
static inline QString fromStdWString(const QStdWString &s);
inline QStdWString toStdWString() const;
# endif // QT_NO_STL_WCHAR
#endif
#endif // QT_NO_STL_WCHAR
// compatibility
struct Null { };
@ -506,7 +500,7 @@ private:
#endif
struct Data {
QBasicAtomicInt ref;
QAtomicInt ref;
int alloc, size;
ushort *data;
ushort capacity : 1;
@ -908,14 +902,13 @@ inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, const QByteA
# endif // QT_NO_CAST_FROM_ASCII
#endif // QT_USE_QSTRINGBUILDER
#ifndef QT_NO_STL
inline std::string QString::toStdString() const
{ return toAscii().toStdString(); }
inline QString QString::fromStdString(const std::string &s)
{ return fromAscii(s.data(), int(s.size())); }
# ifndef QT_NO_STL_WCHAR
#ifndef QT_NO_STL_WCHAR
inline QStdWString QString::toStdWString() const
{
QStdWString str;
@ -924,7 +917,6 @@ inline QStdWString QString::toStdWString() const
}
inline QString QString::fromStdWString(const QStdWString &s)
{ return fromWCharArray(s.data(), int(s.size())); }
# endif
#endif

View file

@ -45,12 +45,6 @@
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
# include <QtCore/qmap.h>
# endif
#endif
#include <string.h>
QT_BEGIN_HEADER

View file

@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false };
QVectorData QVectorData::shared_null = { QAtomicInt(1), 0, 0, true, false };
QVectorData *QVectorData::allocate(int size)
{

View file

@ -44,9 +44,7 @@
#include <QtCore/qlist.h>
#ifndef QT_NO_STL
#include <vector>
#endif
QT_BEGIN_HEADER
@ -54,7 +52,7 @@ QT_BEGIN_NAMESPACE
struct Q_CORE_EXPORT QVectorData
{
QBasicAtomicInt ref;
QAtomicInt ref;
int alloc;
int size;
uint sharable : 1;
@ -281,12 +279,10 @@ public:
static QVector<T> fromList(const QList<T> &list);
#ifndef QT_NO_STL
static inline QVector<T> fromStdVector(const std::vector<T> &vector)
{ QVector<T> tmp; tmp.reserve(int(vector.size())); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
inline std::vector<T> toStdVector() const
{ std::vector<T> tmp; tmp.reserve(size()); qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
#endif
private:
friend class QRegion; // Optimization for QRegion::rects()

View file

@ -70,7 +70,7 @@
QT_BEGIN_NAMESPACE
static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1);
static QAtomicInt isDebugging = QAtomicInt(-1);
#define qDBusDebug if (::isDebugging == 0); else qDebug
static const QString orgFreedesktopDBusString = QLatin1String(DBUS_SERVICE_DBUS);

View file

@ -55,14 +55,6 @@
#include <QtCore/qvarlengtharray.h>
#include <QtScript/qscriptcontextinfo.h>
#if defined(__GNUC__)
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
// The code in this file does not violate strict aliasing, but GCC thinks it does
// so turn off the warnings for us to have a clean build
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
# endif
#endif
QT_BEGIN_NAMESPACE
struct ObjectData : public QScriptDeclarativeClass::Object {

View file

@ -59,18 +59,7 @@
#include <qapplication.h>
#include <qstylepainter.h>
#include <qfileiconprovider_p.h>
#if !defined(Q_WS_WINCE)
#include "ui_qfiledialog.h"
#else
#define Q_EMBEDDED_SMALLSCREEN
#include "ui_qfiledialog_embedded.h"
#if defined(Q_OS_WINCE)
extern bool qt_priv_ptr_valid;
#endif
#if defined(Q_OS_UNIX)
#include <pwd.h>
#endif
#endif
QT_BEGIN_NAMESPACE
@ -2160,12 +2149,6 @@ void QFileDialogPrivate::init(const QString &directory, const QString &nameFilte
q->restoreState(settings.value(QLatin1String("filedialog")).toByteArray());
#endif
#if defined(Q_EMBEDDED_SMALLSCREEN)
qFileDialogUi->lookInLabel->setVisible(false);
qFileDialogUi->fileNameLabel->setVisible(false);
qFileDialogUi->fileTypeLabel->setVisible(false);
qFileDialogUi->sidebar->hide();
#endif
// Default case
if (!nameFilter.isEmpty())
q->setNameFilter(nameFilter);

View file

@ -1,340 +0,0 @@
<ui version="4.0" >
<comment>*********************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
*********************************************************************</comment>
<class>QFileDialog</class>
<widget class="QDialog" name="QFileDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>320</height>
</rect>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QFileDialogComboBox" name="lookInCombo" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QToolButton" name="backButton" >
<property name="toolTip" >
<string>Back</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="forwardButton" >
<property name="toolTip" >
<string>Forward</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toParentButton" >
<property name="toolTip" >
<string>Parent Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="newFolderButton" >
<property name="toolTip" >
<string>Create New Folder</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="listModeButton" >
<property name="toolTip" >
<string>List View</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="detailModeButton" >
<property name="toolTip" >
<string>Detail View</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<widget class="QSidebar" name="sidebar" />
<widget class="QFrame" name="frame" >
<property name="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stackedWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="page" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>108</width>
<height>164</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QFileDialogListView" name="listView" />
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QFileDialogTreeView" name="treeView" />
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QFileDialogLineEdit" name="fileNameEdit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item rowspan="2" row="0" column="1" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QComboBox" name="fileTypeCombo" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="fileNameLabel" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fileTypeLabel" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>Files of type:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lookInLabel" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>Look in:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QFileDialogTreeView</class>
<extends>QTreeView</extends>
<header>qfiledialog_p.h</header>
</customwidget>
<customwidget>
<class>QFileDialogListView</class>
<extends>QListView</extends>
<header>qfiledialog_p.h</header>
</customwidget>
<customwidget>
<class>QSidebar</class>
<extends>QListWidget</extends>
<header>qsidebar_p.h</header>
</customwidget>
<customwidget>
<class>QFileDialogLineEdit</class>
<extends>QLineEdit</extends>
<header>qfiledialog_p.h</header>
</customwidget>
<customwidget>
<class>QFileDialogComboBox</class>
<extends>QComboBox</extends>
<header>qfiledialog_p.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>lookInCombo</tabstop>
<tabstop>backButton</tabstop>
<tabstop>forwardButton</tabstop>
<tabstop>toParentButton</tabstop>
<tabstop>newFolderButton</tabstop>
<tabstop>listModeButton</tabstop>
<tabstop>detailModeButton</tabstop>
<tabstop>sidebar</tabstop>
<tabstop>listView</tabstop>
<tabstop>fileNameEdit</tabstop>
<tabstop>fileTypeCombo</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>treeView</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View file

@ -249,7 +249,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
#endif
#endif
if (m_resolveSymlinks && info.isSymLink(/* ignoreNtfsSymLinks = */ true)) {
if (m_resolveSymlinks && info.isSymLink()) {
QFileInfo resolvedInfo(fileInfo.readLink());
resolvedInfo = resolvedInfo.canonicalFilePath();
if (resolvedInfo.exists()) {
@ -261,16 +261,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
QString QFileInfoGatherer::translateDriveName(const QFileInfo &drive) const
{
QString driveName = drive.absoluteFilePath();
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (driveName.startsWith(QLatin1Char('/'))) // UNC host
return drive.fileName();
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (driveName.endsWith(QLatin1Char('/')))
driveName.chop(1);
#endif
return driveName;
return drive.absoluteFilePath();
}
/*

View file

@ -108,15 +108,8 @@ public:
return QExtendedInformation::System;
}
bool isSymLink(bool ignoreNtfsSymLinks = false) const
bool isSymLink() const
{
#ifdef Q_WS_WIN
if (ignoreNtfsSymLinks) {
return !mFileInfo.suffix().compare(QLatin1String("lnk"), Qt::CaseInsensitive);
}
#else
Q_UNUSED(ignoreNtfsSymLinks);
#endif
return mFileInfo.isSymLink();
}
@ -202,10 +195,8 @@ private:
bool m_resolveSymlinks;
QFileIconProvider *m_iconProvider;
QFileIconProvider defaultProvider;
#ifndef Q_OS_WIN
uint userId;
uint groupId;
#endif
};
#endif // QT_NO_FILESYSTEMMODEL

View file

@ -802,7 +802,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
return QString();
QFileSystemNode *dirNode = node(index);
if (fileInfoGatherer.resolveSymlinks() && !resolvedSymLinks.isEmpty() &&
dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
dirNode->isSymLink()) {
QString fullPath = QDir::fromNativeSeparators(filePath(index));
if (resolvedSymLinks.contains(fullPath))
return resolvedSymLinks[fullPath];

View file

@ -115,7 +115,7 @@ public:
inline bool isFile() const { if (info) return info->isFile(); return true; }
inline bool isSystem() const { if (info) return info->isSystem(); return true; }
inline bool isHidden() const { if (info) return info->isHidden(); return false; }
inline bool isSymLink(bool ignoreNtfsSymLinks = false) const { return info && info->isSymLink(ignoreNtfsSymLinks); }
inline bool isSymLink() const { return info && info->isSymLink(); }
inline bool caseSensitive() const { if (info) return info->isCaseSensitive(); return false; }
inline QIcon icon() const { if (info) return info->icon; return QIcon(); }

View file

@ -72,12 +72,12 @@ public:
static bool displayOpened() { return displayOpen; }
private:
static QBasicAtomicInt contexts;
static QBasicAtomicInt displayOpen;
static QAtomicInt contexts;
static QAtomicInt displayOpen;
};
QBasicAtomicInt QEglContextTracker::contexts = Q_BASIC_ATOMIC_INITIALIZER(0);
QBasicAtomicInt QEglContextTracker::displayOpen = Q_BASIC_ATOMIC_INITIALIZER(0);
QAtomicInt QEglContextTracker::contexts = QAtomicInt(0);
QAtomicInt QEglContextTracker::displayOpen = QAtomicInt(0);
// Current GL and VG contexts. These are used to determine if
// we can avoid an eglMakeCurrent() after a call to lazyDoneCurrent().

View file

@ -639,7 +639,7 @@ bool qt_write_dib(QDataStream &s, QImage image)
uchar *buf = new uchar[bpl_bmp];
uchar *b, *end;
register uchar *p;
uchar *p;
memset(buf, 0, bpl_bmp);
for (y=image.height()-1; y>=0; y--) { // write the image bits

View file

@ -105,7 +105,7 @@ QT_BEGIN_NAMESPACE
\value On Display the pixmap when the widget is in an "on" state
*/
static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1);
static QAtomicInt serialNumCounter = QAtomicInt(1);
static void qt_cleanup_icon_cache();
typedef QCache<QString, QIcon> IconCache;

View file

@ -108,7 +108,7 @@ static QImage rotated90(const QImage &src);
static QImage rotated180(const QImage &src);
static QImage rotated270(const QImage &src);
QBasicAtomicInt qimage_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
QAtomicInt qimage_serial_number = QAtomicInt(1);
QImageData::QImageData()
: ref(0), width(0), height(0), depth(0), nbytes(0), data(0),

View file

@ -308,7 +308,7 @@ static int defaultScreen = -1;
QPixmap member functions
*****************************************************************************/
QBasicAtomicInt qt_pixmap_serial = Q_BASIC_ATOMIC_INITIALIZER(0);
QAtomicInt qt_pixmap_serial = QAtomicInt(0);
int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0;
QX11PixmapData::QX11PixmapData(PixelType type)
@ -1749,7 +1749,7 @@ QImage QX11PixmapData::toImage(const QXImageWrapper &xiWrapper, const QRect &rec
image.setColor(0, qRgb(255,255,255));
image.setColor(1, qRgb(0,0,0));
} else if (!trucol) { // pixmap with colormap
register uchar *p;
uchar *p;
uchar *end;
uchar use[256]; // pixel-in-use table
uchar pix[256]; // pixel translation table
@ -2150,8 +2150,8 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const XWindowAttributes &a);
qt_x11_getX11InfoForWindow(&data->xinfo,window_attr);
extern void qt_x11_getX11InfoForWindow(QX11Info *xinfo, const void *a);
qt_x11_getX11InfoForWindow(&data->xinfo, static_cast<const void*>(&window_attr));
data->resize(w, h);

View file

@ -91,11 +91,7 @@ QT_BEGIN_NAMESPACE
\sa QCache, QPixmap
*/
#if defined(Q_WS_WINCE)
static int cache_limit = 2048; // 2048 KB cache limit for embedded
#else
static int cache_limit = 10240; // 10 MB cache limit for desktop
#endif
/*!
\class QPixmapCache::Key

View file

@ -153,9 +153,6 @@ private:
# define QT_XFORM_TYPE_MSBFIRST 0
# define QT_XFORM_TYPE_LSBFIRST 1
# if defined(Q_WS_WIN)
# define QT_XFORM_TYPE_WINDOWSPIXMAP 2
# endif
extern bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int);
QT_END_NAMESPACE

View file

@ -59,11 +59,6 @@ public:
QFileIconProviderPrivate();
void setUseCustomDirectoryIcons(bool enable);
QIcon getIcon(QStyle::StandardPixmap name) const;
#ifdef Q_WS_WIN
QIcon getWinIcon(const QFileInfo &fi) const;
#elif defined(Q_WS_MAC)
QIcon getMacIcon(const QFileInfo &fi) const;
#endif
QFileIconProvider * q_ptr;
const QString homePath;

View file

@ -932,7 +932,7 @@ QApplication::~QApplication()
QWidgetSet *mySet = QWidgetPrivate::allWidgets;
QWidgetPrivate::allWidgets = 0;
for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
register QWidget *w = *it;
QWidget *w = *it;
if (!w->parent()) // window
w->destroy(true, true);
}
@ -1306,8 +1306,7 @@ void QApplication::setStyle(QStyle *style)
// clean up the old style
if (QApplicationPrivate::app_style) {
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
register QWidget *w = *it;
foreach (QWidget *w, all) {
if (!(w->windowType() == Qt::Desktop) && // except desktop
w->testAttribute(Qt::WA_WState_Polished)) { // has been polished
QApplicationPrivate::app_style->unpolish(w);
@ -1347,24 +1346,22 @@ void QApplication::setStyle(QStyle *style)
// re-polish existing widgets if necessary
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) {
register QWidget *w = *it1;
if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
if (w->style() == QApplicationPrivate::app_style)
QApplicationPrivate::app_style->polish(w); // repolish
foreach (QWidget *it1, all) {
if (it1->windowType() != Qt::Desktop && it1->testAttribute(Qt::WA_WState_Polished)) {
if (it1->style() == QApplicationPrivate::app_style)
QApplicationPrivate::app_style->polish(it1); // repolish
#ifndef QT_NO_STYLE_STYLESHEET
else
w->setStyleSheet(w->styleSheet()); // touch
it1->setStyleSheet(it1->styleSheet()); // touch
#endif
}
}
for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) {
register QWidget *w = *it2;
if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) {
foreach (QWidget *it2, all) {
if (it2->windowType() != Qt::Desktop && !it2->testAttribute(Qt::WA_SetStyle)) {
QEvent e(QEvent::StyleChange);
QApplication::sendEvent(w, &e);
w->update();
QApplication::sendEvent(it2, &e);
it2->update();
}
}
}
@ -1564,9 +1561,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
QEvent e(QEvent::ApplicationPaletteChange);
QApplication::sendEvent(QApplication::instance(), &e);
QWidgetList wids = QApplication::allWidgets();
for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
register QWidget *w = *it;
foreach (QWidget *w, QApplication::allWidgets()) {
if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
QApplication::sendEvent(w, &e);
}
@ -1743,9 +1738,7 @@ void QApplication::setFont(const QFont &font, const char *className)
QEvent e(QEvent::ApplicationFontChange);
QApplication::sendEvent(QApplication::instance(), &e);
QWidgetList wids = QApplication::allWidgets();
for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
register QWidget *w = *it;
foreach (QWidget *w, QApplication::allWidgets()) {
if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
sendEvent(w, &e);
}
@ -1805,9 +1798,7 @@ void QApplication::setWindowIcon(const QIcon &icon)
*QApplicationPrivate::app_icon = icon;
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
QEvent e(QEvent::ApplicationWindowIconChange);
QWidgetList all = QApplication::allWidgets();
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
register QWidget *w = *it;
foreach (QWidget *w, QApplication::allWidgets()) {
if (w->isWindow())
sendEvent(w, &e);
}
@ -1829,10 +1820,8 @@ void QApplication::setWindowIcon(const QIcon &icon)
QWidgetList QApplication::topLevelWidgets()
{
QWidgetList list;
QWidgetList all = allWidgets();
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
QWidget *w = *it;
foreach (QWidget *w, QApplication::allWidgets()) {
if (w->isWindow() && w->windowType() != Qt::Desktop)
list.append(w);
}
@ -3651,7 +3640,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
&& mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
// but still send them through all application event filters (normally done by notify_helper)
for (int i = 0; i < d->eventFilters.size(); ++i) {
register QObject *obj = d->eventFilters.at(i);
QObject *obj = d->eventFilters.at(i);
if (!obj)
continue;
if (obj->d_func()->threadData != w->d_func()->threadData) {

View file

@ -2772,10 +2772,9 @@ void QApplication::setOverrideCursor(const QCursor &cursor)
qApp->d_func()->cursor_list.prepend(cursor);
QWidgetList all = allWidgets();
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
register QWidget *w = *it;
if ((w->testAttribute(Qt::WA_SetCursor) || w->isWindow()) && (w->windowType() != Qt::Desktop))
qt_x11_enforce_cursor(w);
foreach (QWidget *it, all) {
if ((it->testAttribute(Qt::WA_SetCursor) || it->isWindow()) && (it->windowType() != Qt::Desktop))
qt_x11_enforce_cursor(it);
}
XFlush(X11->display); // make X execute it NOW
}
@ -2787,11 +2786,9 @@ void QApplication::restoreOverrideCursor()
qApp->d_func()->cursor_list.removeFirst();
if (QWidgetPrivate::mapper != 0 && !closingDown()) {
QWidgetList all = allWidgets();
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
register QWidget *w = *it;
if ((w->testAttribute(Qt::WA_SetCursor) || w->isWindow()) && (w->windowType() != Qt::Desktop))
qt_x11_enforce_cursor(w);
foreach (QWidget *it, allWidgets()) {
if ((it->testAttribute(Qt::WA_SetCursor) || it->isWindow()) && (it->windowType() != Qt::Desktop))
qt_x11_enforce_cursor(it);
}
XFlush(X11->display);
}

View file

@ -92,73 +92,6 @@ protected:
virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0;
};
#ifdef Q_WS_WIN
class QOleDataObject : public IDataObject
{
public:
explicit QOleDataObject(QMimeData *mimeData);
virtual ~QOleDataObject();
void releaseQt();
const QMimeData *mimeData() const;
DWORD reportedPerformedEffect() const;
// IUnknown methods
STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
STDMETHOD_(ULONG,AddRef)(void);
STDMETHOD_(ULONG,Release)(void);
// IDataObject methods
STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
STDMETHOD(GetDataHere)(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium);
STDMETHOD(QueryGetData)(LPFORMATETC pformatetc);
STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pformatetc, LPFORMATETC pformatetcOut);
STDMETHOD(SetData)(LPFORMATETC pformatetc, STGMEDIUM FAR * pmedium,
BOOL fRelease);
STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC FAR* ppenumFormatEtc);
STDMETHOD(DAdvise)(FORMATETC FAR* pFormatetc, DWORD advf,
LPADVISESINK pAdvSink, DWORD FAR* pdwConnection);
STDMETHOD(DUnadvise)(DWORD dwConnection);
STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR* ppenumAdvise);
private:
ULONG m_refs;
QPointer<QMimeData> data;
int CF_PERFORMEDDROPEFFECT;
DWORD performedEffect;
};
class QOleEnumFmtEtc : public IEnumFORMATETC
{
public:
explicit QOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs);
explicit QOleEnumFmtEtc(const QVector<LPFORMATETC> &lpfmtetcs);
virtual ~QOleEnumFmtEtc();
bool isNull() const;
// IUnknown methods
STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
STDMETHOD_(ULONG,AddRef)(void);
STDMETHOD_(ULONG,Release)(void);
// IEnumFORMATETC methods
STDMETHOD(Next)(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetched);
STDMETHOD(Skip)(ULONG celt);
STDMETHOD(Reset)(void);
STDMETHOD(Clone)(LPENUMFORMATETC FAR* newEnum);
private:
bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const;
ULONG m_dwRefs;
ULONG m_nIndex;
QVector<LPFORMATETC> m_lpfmtetcs;
bool m_isNull;
};
#endif
#endif //QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
#ifndef QT_NO_DRAGANDDROP
@ -188,11 +121,6 @@ protected:
bool hasFormat_sys(const QString &mimeType) const;
QStringList formats_sys() const;
QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
#if defined(Q_WS_WIN)
public:
LPDATAOBJECT currentDataObject;
#endif
};
class QDragManager: public QObject {
@ -205,9 +133,6 @@ class QDragManager: public QObject {
friend class QDragMoveEvent;
friend class QDropEvent;
friend class QApplication;
#ifdef Q_WS_MAC
friend class QWidgetPrivate; //dnd is implemented here
#endif
bool eventFilter(QObject *, QEvent *);
void timerEvent(QTimerEvent*);
@ -259,59 +184,6 @@ private:
Q_DISABLE_COPY(QDragManager)
};
#if defined(Q_WS_WIN)
class QOleDropTarget : public IDropTarget
{
public:
QOleDropTarget(QWidget* w);
virtual ~QOleDropTarget() {}
void releaseQt();
// IUnknown methods
STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
STDMETHOD_(ULONG, AddRef)(void);
STDMETHOD_(ULONG, Release)(void);
// IDropTarget methods
STDMETHOD(DragEnter)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
STDMETHOD(DragLeave)();
STDMETHOD(Drop)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
private:
ULONG m_refs;
QWidget* widget;
QPointer<QWidget> currentWidget;
QRect answerRect;
QPoint lastPoint;
DWORD chosenEffect;
DWORD lastKeyState;
void sendDragEnterEvent(QWidget *to, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
};
#endif
#if defined (Q_WS_MAC)
class QCocoaDropData : public QInternalMimeData
{
Q_OBJECT
public:
QCocoaDropData(CFStringRef pasteboard);
~QCocoaDropData();
protected:
bool hasFormat_sys(const QString &mimeType) const;
QStringList formats_sys() const;
QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
public:
CFStringRef dropPasteboard;
};
#endif
#endif // !QT_NO_DRAGANDDROP

View file

@ -119,9 +119,6 @@ public:
QNativeGestureEvent()
: QEvent(QEvent::NativeGesture), gestureType(None), percentage(0)
#ifdef Q_WS_WIN
, sequenceId(0), argument(0)
#endif
{
}
@ -129,10 +126,6 @@ public:
float percentage;
QPoint position;
float angle;
#ifdef Q_WS_WIN
ulong sequenceId;
quint64 argument;
#endif
};
class QGestureEventPrivate

View file

@ -50,14 +50,6 @@
#include "qplatformdefs.h"
#include "qicon.h"
#ifdef Q_WS_WINCE
#include "qguifunctions_wince.h"
extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp
extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp
extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
#endif
#if defined(Q_WS_X11)
#include <qkde_p.h>
#include <qgtkstyle_p.h>
@ -130,26 +122,10 @@ QGuiPlatformPlugin::~QGuiPlatformPlugin() {}
/* return the string key to be used by default the application */
QString QGuiPlatformPlugin::styleName()
{
#if defined(Q_WS_WIN) && defined(Q_WS_WINCE)
if (qt_wince_is_smartphone() || qt_wince_is_pocket_pc())
return QLatin1String("WindowsMobile");
else
return QLatin1String("WindowsCE");
#elif defined(Q_WS_WIN)
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
&& (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)))
return QLatin1String("WindowsVista");
else if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)))
return QLatin1String("WindowsXP");
else
return QLatin1String("Windows"); // default styles for Windows
#elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS)
#if defined(Q_WS_X11) && defined(Q_OS_SOLARIS)
return QLatin1String("CDE"); // default style for X11 on Solaris
#elif defined(Q_WS_X11) && defined(Q_OS_IRIX)
return QLatin1String("SGI"); // default style for X11 on IRIX
#elif defined(Q_WS_MAC)
return QLatin1String("Macintosh"); // default style for all Mac's
#elif defined(Q_WS_X11)
QString stylename;
switch(X11->desktopEnvironment) {
@ -246,11 +222,6 @@ QStringList QGuiPlatformPlugin::iconThemeSearchPaths()
paths.prepend(homeDir.path());
#endif
#if defined(Q_WS_WIN)
paths.append(qApp->applicationDirPath() + QLatin1String("/icons"));
#elif defined(Q_WS_MAC)
paths.append(qApp->applicationDirPath() + QLatin1String("/../Resources/icons"));
#endif
return paths;
}

View file

@ -184,7 +184,7 @@ qt_XTranslateKey(register QXCoreDesc *dpy,
KeySym *keysym_return)
{
int per;
register KeySym *syms;
KeySym *syms;
KeySym sym, lsym, usym;
if (! dpy->keysyms)

View file

@ -1,85 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*
* This is a precompiled header file for use in Xcode / Mac GCC /
* GCC >= 3.4 / VC to greatly speed the building of Qt. It may also be
* of use to people developing their own project, but it is probably
* better to define your own header. Use of this header is currently
* UNSUPPORTED.
*/
// from corelib/global/qt_pch.h
#if defined __cplusplus
#include <qglobal.h>
#ifdef Q_WS_WIN
# define _POSIX_
# include <limits.h>
# undef _POSIX_
#endif
#include <qcoreapplication.h>
#include <qlist.h>
#include <qvariant.h> // All moc genereated code has this include
#include <qobject.h>
#include <qregexp.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qtextcodec.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qcursor.h>
#include <qdesktopwidget.h>
#include <qevent.h>
#include <qimage.h>
#include <qlayout.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qstyle.h>
#include <qtimer.h>
#include <qwidget.h>
#include <stdlib.h>
#endif

View file

@ -367,9 +367,7 @@ class QWhatsThisPrivate : public QObject
void QWhatsThisPrivate::notifyToplevels(QEvent *e)
{
QWidgetList toplevels = QApplication::topLevelWidgets();
for (int i = 0; i < toplevels.count(); ++i) {
register QWidget *w = toplevels.at(i);
foreach (QWidget *w, QApplication::topLevelWidgets()) {
QApplication::sendEvent(w, e);
}
}

View file

@ -5841,11 +5841,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
f = f->d_func()->extra->focus_proxy;
if (QApplication::focusWidget() == f
#if defined(Q_WS_WIN)
&& GetFocus() == f->internalWinId()
#endif
)
if (QApplication::focusWidget() == f)
return;
#ifndef QT_NO_GRAPHICSVIEW
@ -5970,16 +5966,9 @@ void QWidget::clearFocus()
if (hasFocus()) {
// Update proxy state
QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
#if defined(Q_WS_WIN)
if (!(windowType() == Qt::Popup) && GetFocus() == internalWinId())
SetFocus(0);
else
#endif
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(this, 0, QAccessible::Focus);
QAccessible::updateAccessibility(this, 0, QAccessible::Focus);
#endif
}
}
}
@ -6132,14 +6121,7 @@ bool QWidget::isActiveWindow() const
return true;
}
}
#if defined(Q_WS_WIN32)
HWND active = GetActiveWindow();
if (!tlw->testAttribute(Qt::WA_WState_Created))
return false;
return active == tlw->internalWinId() || ::IsChild(active, tlw->internalWinId());
#else
return false;
#endif
}
/*!
@ -6548,24 +6530,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
// set geomerty before setting the window state to make
// sure the window is maximized to the right screen.
Qt::WindowStates ws = windowState();
#ifndef Q_WS_WIN
setGeometry(restoredNormalGeometry);
#else
if (ws & Qt::WindowFullScreen) {
// Full screen is not a real window state on Windows.
move(availableGeometry.topLeft());
} else if (ws & Qt::WindowMaximized) {
// Setting a geometry on an already maximized window causes this to be
// restored into a broken, half-maximized state, non-resizable state (QTBUG-4397).
// Move the window in normal state if needed.
if (restoredScreenNumber != desktop->screenNumber(this)) {
setWindowState(Qt::WindowNoState);
setGeometry(restoredNormalGeometry);
}
} else {
setGeometry(restoredNormalGeometry);
}
#endif // Q_WS_WIN
if (maximized)
ws |= Qt::WindowMaximized;
if (fullScreen)
@ -6955,14 +6920,6 @@ void QWidgetPrivate::show_helper()
Q_UNUSED(isEmbedded);
#endif
// On Windows, show the popup now so that our own focus handling
// stores the correct old focus widget even if it's stolen in the
// showevent
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
if (!isEmbedded && q->windowType() == Qt::Popup)
qApp->d_func()->openPopup(q);
#endif
// send the show event before showing the window
QShowEvent showEvent;
QApplication::sendEvent(q, &showEvent);
@ -6975,10 +6932,8 @@ void QWidgetPrivate::show_helper()
show_sys();
#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
if (!isEmbedded && q->windowType() == Qt::Popup)
qApp->d_func()->openPopup(q);
#endif
#ifndef QT_NO_ACCESSIBILITY
if (q->windowType() != Qt::ToolTip) // Tooltips are read aloud twice in MS narrator.
@ -7034,12 +6989,6 @@ void QWidgetPrivate::hide_helper()
if (!isEmbedded && q->isModal() && q->isWindow())
QApplicationPrivate::leaveModal(q);
#if defined(Q_WS_WIN)
if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget()
&& !q->parentWidget()->isHidden() && q->isActiveWindow())
q->parentWidget()->activateWindow(); // Activate parent
#endif
q->setAttribute(Qt::WA_Mapped, false);
hide_sys();
@ -7057,7 +7006,7 @@ void QWidgetPrivate::hide_helper()
// next bit tries to move the focus if the focus widget is now
// hidden.
if (wasVisible) {
#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_WS_X11)
qApp->d_func()->sendSyntheticEnterLeave(q);
#endif
@ -7183,7 +7132,7 @@ void QWidget::setVisible(bool visible)
d->show_helper();
#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_WS_X11)
qApp->d_func()->sendSyntheticEnterLeave(this);
#endif
}
@ -7193,16 +7142,6 @@ void QWidget::setVisible(bool visible)
} else { // hide
if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
return;
#if defined(Q_WS_WIN)
// reset WS_DISABLED style in a Blocked window
if(isWindow() && testAttribute(Qt::WA_WState_Created)
&& QApplicationPrivate::isBlockedByModal(this))
{
LONG dwStyle = GetWindowLong(winId(), GWL_STYLE);
dwStyle &= ~WS_DISABLED;
SetWindowLong(winId(), GWL_STYLE, dwStyle);
}
#endif
if (QApplicationPrivate::hidden_focus_widget == this)
QApplicationPrivate::hidden_focus_widget = 0;
@ -7633,26 +7572,6 @@ bool QWidget::isAncestorOf(const QWidget *child) const
return false;
}
#if defined(Q_WS_WIN)
inline void setDisabledStyle(QWidget *w, bool setStyle)
{
// set/reset WS_DISABLED style.
if(w && w->isWindow() && w->isVisible() && w->isEnabled()) {
LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE);
LONG newStyle = dwStyle;
if (setStyle)
newStyle |= WS_DISABLED;
else
newStyle &= ~WS_DISABLED;
if (newStyle != dwStyle) {
SetWindowLong(w->winId(), GWL_STYLE, newStyle);
// we might need to repaint in some situations (eg. menu)
w->repaint();
}
}
}
#endif
/*****************************************************************************
QWidget event handling
*****************************************************************************/
@ -8028,9 +7947,6 @@ bool QWidget::event(QEvent *event)
QApplication::sendEvent(o, event);
}
}
#if defined(Q_WS_WIN)
setDisabledStyle(this, (event->type() == QEvent::WindowBlocked));
#endif
}
break;
#ifndef QT_NO_TOOLTIP
@ -8078,7 +7994,7 @@ bool QWidget::event(QEvent *event)
case QEvent::EmbeddingControl:
d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
data->fstrut_dirty = false;
#if defined(Q_WS_WIN) || defined(Q_WS_X11)
#if defined(Q_WS_X11)
d->topData()->embedded = 1;
#endif
break;
@ -8929,31 +8845,7 @@ bool QWidget::macEvent(EventHandlerCallRef, EventRef)
}
#endif
#if defined(Q_WS_WIN)
/*!
This special event handler can be reimplemented in a subclass to
receive native Windows events which are passed in the \a message
parameter.
In your reimplementation of this function, if you want to stop the
event being handled by Qt, return true and set \a result to the value
that the window procedure should return. If you return false, this
native event is passed back to Qt, which translates the event into
a Qt event and sends it to the widget.
\warning This function is not portable.
\sa QApplication::winEventFilter()
*/
bool QWidget::winEvent(MSG *message, long *result)
{
Q_UNUSED(message);
Q_UNUSED(result);
return false;
}
#endif
#if defined(Q_WS_X11)
/*!
@ -9280,8 +9172,7 @@ QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChil
}
// Map the point 'p' from parent coordinates to child coordinates.
QPoint childPoint = p;
childPoint -= child->data->crect.topLeft();
const QPoint childPoint = p - child->data->crect.topLeft();
// Check if the point hits the child.
if (!child->d_func()->pointInsideRectAndMask(childPoint))
@ -9529,7 +9420,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
// (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all
// platforms).
if (newParent
#if defined(Q_WS_WIN) || defined(QT_OPENGL_ES)
#if defined(QT_OPENGL_ES)
|| (f & Qt::MSWindowsOwnDC)
#endif
) {
@ -9880,15 +9771,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
"QWidget::setAttribute(WidgetAttribute, bool)",
"QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
#ifdef Q_WS_WIN
// ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0
if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) {
// see qwidget_win.cpp, ::paintEngine for details
paintEngine();
if (d->noPaintOnScreen)
return;
}
#endif
setAttribute_internal(attribute, on, data, d);
@ -10015,7 +9897,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
case Qt::WA_PaintOnScreen:
d->updateIsOpaque();
#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_WS_X11)
// Recreate the widget if it's already created as an alien widget and
// WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
// So must their children.
@ -10121,10 +10003,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
break;
case Qt::WA_AcceptTouchEvents:
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
if (on)
d->registerTouchWindow();
#endif
break;
case Qt::WA_LockPortraitOrientation:
case Qt::WA_LockLandscapeOrientation:
@ -10516,39 +10394,6 @@ void QWidget::updateMicroFocus()
#endif
}
#if defined (Q_WS_WIN)
/*!
Returns the window system handle of the widget, for low-level
access. Using this function is not portable.
An HDC acquired with getDC() has to be released with releaseDC().
\warning Using this function is not portable.
*/
HDC QWidget::getDC() const
{
Q_D(const QWidget);
if (d->hd)
return (HDC) d->hd;
return GetDC(winId());
}
/*!
Releases the HDC \a hdc acquired by a previous call to getDC().
\warning Using this function is not portable.
*/
void QWidget::releaseDC(HDC hdc) const
{
Q_D(const QWidget);
// If its the widgets own dc, it will be released elsewhere. If
// its a different HDC we release it and issue a warning if it
// fails.
if (hdc != d->hd && !ReleaseDC(winId(), hdc))
qErrnoWarning("QWidget::releaseDC(): failed to release HDC");
}
#else
/*!
Returns the window system handle of the widget, for low-level
access. Using this function is not portable.
@ -10563,7 +10408,6 @@ Qt::HANDLE QWidget::handle() const
(void)winId(); // enforce native window
return d->hd;
}
#endif
/*!
@ -11143,10 +10987,8 @@ QRect QWidgetPrivate::frameStrut() const
}
if (data.fstrut_dirty
#ifndef Q_WS_WIN
// ### Fix properly for 4.3
&& q->isVisible()
#endif
&& q->testAttribute(Qt::WA_WState_Created))
const_cast<QWidgetPrivate *>(this)->updateFrameStrut();

View file

@ -577,25 +577,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
else
q->setAttribute(Qt::WA_WState_Visible);
QX11InfoData* xd = xinfo.getX11Data(true);
// find which screen the window is on...
xd->screen = QX11Info::appScreen(); // by default, use the default :)
int i;
for (i = 0; i < ScreenCount(X11->display); i++) {
if (RootWindow(X11->display, i) == a.root) {
xd->screen = i;
break;
}
}
xd->depth = a.depth;
xd->cells = DisplayCells(X11->display, xd->screen);
xd->visual = a.visual;
xd->defaultVisual = (XVisualIDFromVisual((Visual *) a.visual) ==
XVisualIDFromVisual((Visual *) QX11Info::appVisual(scr)));
xd->colormap = a.colormap;
xd->defaultColormap = (a.colormap == QX11Info::appColormap(scr));
xinfo.setX11Data(xd);
qt_x11_getX11InfoForWindow(&xinfo, static_cast<const void*>(&a));
} else if (desktop) { // desktop widget
#ifdef QWIDGET_EXTRA_DEBUG
@ -1060,7 +1042,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
setAttribute(Qt::WA_WState_Created, false);
QObjectList childList = children();
for (int i = 0; i < childList.size(); ++i) { // destroy all widget children
register QObject *obj = childList.at(i);
QObject *obj = childList.at(i);
if (obj->isWidgetType())
static_cast<QWidget*>(obj)->destroy(destroySubWindows,
destroySubWindows);
@ -2753,7 +2735,7 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
if (!valid_rect && !children.isEmpty()) { // scroll children
QPoint pd(dx, dy);
for (int i = 0; i < children.size(); ++i) { // move all children
register QObject *object = children.at(i);
QObject *object = children.at(i);
if (object->isWidgetType()) {
QWidget *w = static_cast<QWidget *>(object);
if (!w->isWindow())
@ -3045,6 +3027,7 @@ XRenderColor QX11Data::preMultiply(const QColor &c)
color.blue = (B | B << 8) * color.alpha / 0x10000;
return color;
}
Picture QX11Data::getSolidFill(int screen, const QColor &c)
{
if (!X11->use_xrender)
@ -3084,6 +3067,30 @@ Picture QX11Data::getSolidFill(int screen, const QColor &c)
}
#endif
void qt_x11_getX11InfoForWindow(QX11Info *xinfo, const void *att)
{
QX11InfoData* xd = xinfo->getX11Data(true);
const XWindowAttributes *a = static_cast<const XWindowAttributes*>(att);
// find which screen the window is on...
xd->screen = QX11Info::appScreen(); // by default, use the default :)
int i;
for (i = 0; i < ScreenCount(X11->display); i++) {
if (RootWindow(X11->display, i) == a->root) {
xd->screen = i;
break;
}
}
xd->depth = a->depth;
xd->cells = DisplayCells(X11->display, xd->screen);
xd->visual = a->visual;
xd->defaultVisual = (XVisualIDFromVisual((Visual *) a->visual) ==
XVisualIDFromVisual((Visual *) QX11Info::appVisual(xinfo->screen())));
xd->colormap = a->colormap;
xd->defaultColormap = (a->colormap == QX11Info::appColormap(xinfo->screen()));
xinfo->setX11Data(xd);
}
void QWidgetPrivate::updateX11AcceptFocus()
{
Q_Q(QWidget);

View file

@ -110,6 +110,7 @@ protected:
friend void qt_init(QApplicationPrivate *priv, int, Display *display, Qt::HANDLE visual,
Qt::HANDLE colormap);
friend void qt_cleanup();
friend void qt_x11_getX11InfoForWindow(QX11Info *xinfo, const void *att);
};
QT_END_NAMESPACE

View file

@ -48,7 +48,6 @@
#include <qlist.h>
#include <qmath.h>
#include <qnumeric_p.h>
#include <qmath_p.h>
QT_BEGIN_NAMESPACE

View file

@ -6019,12 +6019,7 @@ static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int
int dg = qGreen(*dst);
int db = qBlue(*dst);
if (da != 255
#if defined (Q_WS_WIN)
// Work around GDI messing up alpha channel
&& qRed(*dst) <= da && qBlue(*dst) <= da && qGreen(*dst) <= da
#endif
) {
if (da != 255) {
int a = qGray(coverage);
sr = qt_div_255(qt_pow_rgb_invgamma[sr] * a);
@ -6409,39 +6404,18 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
void qInitDrawhelperAsm()
{
qreal smoothing = qreal(1.7);
#ifdef Q_WS_MAC
// decided by testing a few things on an iMac, should probably get this from the
// system...
smoothing = qreal(2.0);
#endif
#ifdef Q_WS_WIN
extern qreal qt_fontsmoothing_gamma; // qapplication_win.cpp
smoothing = qt_fontsmoothing_gamma;
#endif
#ifdef Q_WS_X11
Q_UNUSED(smoothing);
for (int i=0; i<256; ++i) {
qt_pow_rgb_gamma[i] = uchar(i);
qt_pow_rgb_invgamma[i] = uchar(i);
}
#else
const qreal smoothing = qreal(1.7);
for (int i=0; i<256; ++i) {
qt_pow_rgb_gamma[i] = uchar(qRound(qPow(i / qreal(255.0), smoothing) * 255));
qt_pow_rgb_invgamma[i] = uchar(qRound(qPow(i / qreal(255.), 1 / smoothing) * 255));
}
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
const qreal gray_gamma = 2.31;
for (int i=0; i<256; ++i)
qt_pow_gamma[i] = uint(qRound(qPow(i / qreal(255.), gray_gamma) * 2047));
for (int i=0; i<2048; ++i)
qt_pow_invgamma[i] = uchar(qRound(qPow(i / qreal(2047.0), 1 / gray_gamma) * 255));
#endif
}
QT_END_NAMESPACE

Some files were not shown because too many files have changed in this diff Show more