Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev

bb10
Frederik Gladhorn 2015-03-09 09:23:55 +00:00 committed by The Qt Project
commit 4dc459837b
234 changed files with 2847 additions and 1124 deletions

View File

@ -0,0 +1,45 @@
/****************************************************************************
**
** 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:LGPL21$
** 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.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <bcm_host.h>
int main(int, char **)
{
EGLDisplay dpy = 0;
EGLContext ctx = 0;
eglDestroyContext(dpy, ctx);
vc_dispmanx_display_open(0);
return 0;
}

View File

@ -0,0 +1,9 @@
SOURCES = eglfs-brcm.cpp
CONFIG -= qt
INCLUDEPATH += $$[QT_SYSROOT]/opt/vc/include \
$$[QT_SYSROOT]/opt/vc/include/interface/vcos/pthreads \
$$[QT_SYSROOT]/opt/vc/include/interface/vmcs_host/linux
LIBS += -L$$[QT_SYSROOT]/opt/vc/lib -lEGL -lGLESv2 -lbcm_host

View File

@ -0,0 +1,45 @@
/****************************************************************************
**
** 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:LGPL21$
** 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.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <EGL/fbdev_window.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h>
int main(int, char **)
{
EGLDisplay dpy = 0;
EGLContext ctx = 0;
fbdev_window *w = 0;
eglDestroyContext(dpy, ctx);
return 0;
}

View File

@ -0,0 +1,5 @@
SOURCES = eglfs-mali.cpp
CONFIG -= qt
LIBS += -lEGL -lGLESv2

View File

@ -0,0 +1,42 @@
/****************************************************************************
**
** 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:LGPL21$
** 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.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <EGL/egl.h>
#include <EGL/eglvivante.h>
#include <GLES2/gl2.h>
int main(int, char **)
{
fbGetDisplayByIndex(0);
return 0;
}

View File

@ -0,0 +1,6 @@
SOURCES = eglfs-viv.cpp
DEFINES += LINUX=1 EGL_API_FB=1
CONFIG -= qt
LIBS += -lEGL -lGLESv2 -lGAL

34
configure vendored
View File

@ -5283,6 +5283,8 @@ if [ "$CFG_LIBINPUT" != "no" ] && [ "$CFG_LIBUDEV" != "no" ]; then
else
CFG_LIBINPUT=no
fi
else
CFG_LIBINPUT=no
fi
if [ "$CFG_LIBINPUT" = "no" ]; then
QMakeVar add DEFINES QT_NO_LIBINPUT
@ -5551,6 +5553,22 @@ fi
if [ "$CFG_EGLFS" != "no" ]; then
if [ "$XPLATFORM_QNX" = "no" ] && [ "$CFG_OPENGL" != "no" ]; then
CFG_EGLFS="$CFG_EGL"
# Detect eglfs backends.
if compileTest qpa/eglfs-brcm "eglfs-brcm"; then
CFG_EGLFS_BRCM=yes
else
CFG_EGLFS_BRCM=no
fi
if compileTest qpa/eglfs-mali "eglfs-mali"; then
CFG_EGLFS_MALI=yes
else
CFG_EGLFS_MALI=no
fi
if compileTest qpa/eglfs-viv "eglfs-viv"; then
CFG_EGLFS_VIV=yes
else
CFG_EGLFS_VIV=no
fi
else
CFG_EGLFS="no"
fi
@ -5962,6 +5980,16 @@ if [ "$CFG_EGLFS" = "yes" ]; then
else
QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EGLFS"
fi
# eglfs backends
if [ "$CFG_EGLFS_BRCM" = "yes" ]; then
QT_CONFIG="$QT_CONFIG eglfs_brcm"
fi
if [ "$CFG_EGLFS_MALI" = "yes" ]; then
QT_CONFIG="$QT_CONFIG eglfs_mali"
fi
if [ "$CFG_EGLFS_VIV" = "yes" ]; then
QT_CONFIG="$QT_CONFIG eglfs_viv"
fi
# enable openvg
if [ "$CFG_OPENVG" = "no" ]; then
@ -6996,7 +7024,11 @@ report_support " PulseAudio ............." "$CFG_PULSEAUDIO"
report_support " QPA backends:"
report_support " DirectFB ............." "$CFG_DIRECTFB"
report_support " EGLFS ................" "$CFG_EGLFS"
report_support " KMS .................." "$CFG_KMS"
report_support " EGLFS i.MX6....... ." "$CFG_EGLFS_VIV"
report_support " EGLFS KMS .........." "$CFG_KMS"
report_support " EGLFS Mali ........." "$CFG_EGLFS_MALI"
report_support " EGLFS Raspberry Pi ." "$CFG_EGLFS_BRCM"
report_support " EGLFS X11 .........." "$CFG_EGL_X"
report_support " LinuxFB .............." "$CFG_LINUXFB"
report_support " XCB .................." "$CFG_XCB" system "system library" qt "bundled copy"
if [ "$CFG_XCB" != "no" ]; then

View File

@ -39,25 +39,45 @@
****************************************************************************/
#include <QApplication>
#include <QDesktopWidget>
#include <QFileSystemModel>
#include <QTreeView>
#include <QCommandLineParser>
#include <QCommandLineOption>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
QCommandLineParser parser;
parser.setApplicationDescription("Qt Dir View Example");
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("directory", "The directory to start in.");
parser.process(app);
const QString rootPath = parser.positionalArguments().isEmpty()
? QString() : parser.positionalArguments().first();
QFileSystemModel model;
model.setRootPath("");
QTreeView tree;
tree.setModel(&model);
if (!rootPath.isEmpty()) {
const QModelIndex rootIndex = model.index(QDir::cleanPath(rootPath));
if (rootIndex.isValid())
tree.setRootIndex(rootIndex);
}
// Demonstrating look and feel features
tree.setAnimated(false);
tree.setIndentation(20);
tree.setSortingEnabled(true);
const QSize availableSize = QApplication::desktop()->availableGeometry(&tree).size();
tree.resize(availableSize / 2);
tree.setColumnWidth(0, tree.width() / 3);
tree.setWindowTitle(QObject::tr("Dir View"));
tree.resize(640, 480);
tree.show();
return app.exec();

View File

@ -10,30 +10,6 @@ include(../common/gcc-base-unix.conf)
load(device_config)
# Passing in -win32 to qmake (from NQTC) causes this condition to pass, however
# qmake complains that -win32 is deprecated; should find another way, Q_OS_WIN
# should really be all QMAKE_HOST.os needs to depend on?
contains(QMAKE_HOST.os,Windows) {
# Not having sh.exe in your path causes this condition to pass
# To build Android Qt on Windows, this block must not be evaluated.
isEmpty(QMAKE_SH) {
# Override values from previously loaded shell-unix.conf
# (via unix.conf, via linux.conf).
include(../common/shell-win32.conf)
QMAKE_DEL_TREE = rmdir /s /q
QMAKE_INSTALL_FILE = copy /y
QMAKE_INSTALL_PROGRAM = copy /y
} else {
MINGW_IN_SHELL = 1
QMAKE_DIR_SEP = /
QMAKE_DIRLIST_SEP = :
# Because install's ability to set permissions is not relevant on Windows,
# and git's msys does not provide it to start with.
QMAKE_INSTALL_FILE = cp -f
QMAKE_INSTALL_PROGRAM = cp -f
}
}
NDK_ROOT = $$(ANDROID_NDK_ROOT)
!exists($$NDK_ROOT) {
NDK_ROOT = $$DEFAULT_ANDROID_NDK_ROOT

View File

@ -20,10 +20,12 @@ QMAKE_CFLAGS_ISYSTEM = -isystem
QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_USE_PRECOMPILE = -Xclang -include-pch -Xclang ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_LTCG = -flto
QMAKE_CFLAGS_DISABLE_LTCG = -fno-lto
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_CXXFLAGS_DISABLE_LTCG = $$QMAKE_CFLAGS_DISABLE_LTCG
QMAKE_CXXFLAGS_CXX11 = -std=c++11
QMAKE_LFLAGS_CXX11 =

View File

@ -10,7 +10,7 @@
include(gcc-base.conf)
QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__=4
QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__=4 __APPLE_CC__
QMAKE_OBJECTIVE_CFLAGS = $$QMAKE_CFLAGS
QMAKE_OBJECTIVE_CFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON

View File

@ -50,6 +50,7 @@ QMAKE_CFLAGS_EXCEPTIONS_OFF += -fno-exceptions
QMAKE_CFLAGS_SPLIT_SECTIONS += -ffunction-sections
QMAKE_CFLAGS_LTCG = -flto -fno-fat-lto-objects
QMAKE_CFLAGS_LTCG_FATOBJECTS = -ffat-lto-objects
QMAKE_CFLAGS_DISABLE_LTCG = -fno-lto
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS
@ -66,6 +67,7 @@ QMAKE_CXXFLAGS_EXCEPTIONS_OFF += $$QMAKE_CFLAGS_EXCEPTIONS_OFF
QMAKE_CXXFLAGS_SPLIT_SECTIONS += $$QMAKE_CFLAGS_SPLIT_SECTIONS
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS
QMAKE_CXXFLAGS_DISABLE_LTCG = $$QMAKE_CFLAGS_DISABLE_LTCG
QMAKE_LFLAGS +=
QMAKE_LFLAGS_DEBUG +=

View File

@ -51,7 +51,5 @@ QMAKE_RANLIB =
QMAKE_STRIP = strip
QMAKE_STRIPFLAGS_LIB += --strip-unneeded
QMAKE_INSTALL_FILE = install -m 644 -p
QMAKE_INSTALL_PROGRAM = install -m 755 -p
include(unix.conf)

View File

@ -1,14 +1 @@
QMAKE_TAR = tar -cf
QMAKE_GZIP = gzip -9f
QMAKE_COPY = cp -f
QMAKE_COPY_FILE = $$QMAKE_COPY
QMAKE_COPY_DIR = $$QMAKE_COPY -R
QMAKE_MOVE = mv -f
QMAKE_DEL_FILE = rm -f
QMAKE_DEL_DIR = rmdir
QMAKE_CHK_EXISTS = test -e %1 ||
QMAKE_CHK_DIR_EXISTS = test -d # legacy
QMAKE_MKDIR = mkdir -p # legacy
QMAKE_MKDIR_CMD = test -d %1 || mkdir -p %1
QMAKE_STREAM_EDITOR = sed
warning("shell-unix.conf is deprecated and has no effect.")

View File

@ -1,17 +1 @@
QMAKE_ZIP = zip -r -9
QMAKE_COPY = copy /y
QMAKE_COPY_DIR = xcopy /s /q /y /i
QMAKE_MOVE = move
QMAKE_DEL_FILE = del
QMAKE_DEL_DIR = rmdir
QMAKE_CHK_EXISTS = if not exist %1
QMAKE_CHK_DIR_EXISTS = if not exist # legacy
QMAKE_MKDIR = mkdir # legacy
QMAKE_MKDIR_CMD = if not exist %1 mkdir %1 & if not exist %1 exit 1
# Ugly hack to support cross-building for unix (android).
QMAKE_SYMBOLIC_LINK = $$QMAKE_COPY
QMAKE_LN_SHLIB = $$QMAKE_SYMBOLIC_LINK
# xcopy copies the contained files if source is a directory. Deal with it.
CONFIG += copy_dir_files
QMAKE_STREAM_EDITOR = $(QMAKE) -install sed
warning("shell-win32.conf is deprecated and has no effect.")

View File

@ -14,5 +14,3 @@ QMAKE_YACC_SOURCE = $base.tab.c
QMAKE_PREFIX_SHLIB = lib
QMAKE_PREFIX_STATICLIB = lib
QMAKE_EXTENSION_STATICLIB = a
include(shell-unix.conf)

View File

@ -73,8 +73,6 @@ QMAKE_IDL = midl
QMAKE_LIB = lib
QMAKE_RC = rc
include(../shell-win32.conf)
VCPROJ_EXTENSION = .vcproj
VCSOLUTION_EXTENSION = .sln
VCPROJ_KEYWORD = Qt4VSv1.0

View File

@ -85,8 +85,6 @@ QMAKE_IDL = midl
QMAKE_LIB = lib /NOLOGO
QMAKE_RC = rc
include(../shell-win32.conf)
VCPROJ_EXTENSION = .vcxproj
VCSOLUTION_EXTENSION = .sln
VCPROJ_KEYWORD = Qt4VSv1.0

View File

@ -73,5 +73,4 @@ QMAKE_OBJCOPY = objcopy
QMAKE_NM = nm -P
QMAKE_RANLIB =
include(../common/shell-unix.conf)
load(qt_config)

View File

@ -18,7 +18,6 @@
# -prefix /home/abc/project/sysbase/qt_install
include(../common/linux_device_pre.conf)
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_hix5hd2.cpp
QMAKE_INCDIR += /usr/arm-linux-gnueabihf/include
QMAKE_LIBDIR += /usr/arm-linux-gnueabihf/lib
@ -39,6 +38,9 @@ DISTRO_OPTS += hard-float
QMAKE_CFLAGS +=-march=armv7-a -mcpu=cortex-a9 -mfpu=vfpv3-d16
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
# Preferred eglfs backend
EGLFS_DEVICE_INTEGRATION = eglfs_mali
include(../common/linux_arm_device_post.conf)
load(qt_config)

View File

@ -4,8 +4,6 @@
include(../common/linux_device_pre.conf)
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_imx6.cpp
QMAKE_INCDIR += $$[QT_SYSROOT]/usr/include
QMAKE_LIBDIR += $$[QT_SYSROOT]/usr/lib
@ -21,6 +19,9 @@ QMAKE_CXXFLAGS += $$IMX6_CFLAGS
DISTRO_OPTS += hard-float
# Preferred eglfs backend
EGLFS_DEVICE_INTEGRATION = eglfs_viv
include(../common/linux_arm_device_post.conf)
load(qt_config)

View File

@ -36,8 +36,8 @@ QMAKE_CFLAGS += \
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_pi.cpp
EGLFS_PLATFORM_HOOKS_LIBS = -lbcm_host
# Preferred eglfs backend
EGLFS_DEVICE_INTEGRATION = eglfs_brcm
include(../common/linux_arm_device_post.conf)

View File

@ -0,0 +1,26 @@
# qmake configuration for the Raspberry Pi 2
include(../common/linux_device_pre.conf)
QMAKE_LFLAGS += -Wl,-rpath-link,$$[QT_SYSROOT]/opt/vc/lib
QMAKE_LIBDIR_OPENGL_ES2 = $$[QT_SYSROOT]/opt/vc/lib
QMAKE_LIBDIR_EGL = $$QMAKE_LIBDIR_OPENGL_ES2
QMAKE_INCDIR_EGL = $$[QT_SYSROOT]/opt/vc/include \
$$[QT_SYSROOT]/opt/vc/include/interface/vcos/pthreads \
$$[QT_SYSROOT]/opt/vc/include/interface/vmcs_host/linux
QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL}
QMAKE_LIBS_EGL = -lEGL -lGLESv2
QMAKE_CFLAGS += -march=armv7-a -marm -mthumb-interwork -mfpu=neon-vfpv4 -mtune=cortex-a7 -mabi=aapcs-linux
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
DISTRO_OPTS += hard-float
# Preferred eglfs backend
EGLFS_DEVICE_INTEGRATION = eglfs_brcm
include(../common/linux_arm_device_post.conf)
load(qt_config)

View File

@ -0,0 +1,34 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the qmake spec of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "../../linux-g++/qplatformdefs.h"

View File

@ -13,6 +13,14 @@ isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path) {
QMAKE_MAC_SDK_PATH = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path)
}
isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_path) {
QMAKE_MAC_SDK_PLATFORM_PATH = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version PlatformPath 2>/dev/null")
isEmpty(QMAKE_MAC_SDK_PLATFORM_PATH): error("Could not resolve SDK platform path for \'$$QMAKE_MAC_SDK\'")
cache(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_path, set stash, QMAKE_MAC_SDK_PLATFORM_PATH)
} else {
QMAKE_MAC_SDK_PLATFORM_PATH = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_path)
}
isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.version) {
QMAKE_MAC_SDK_VERSION = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version SDKVersion 2>/dev/null")
isEmpty(QMAKE_MAC_SDK_VERSION): error("Could not resolve SDK version for \'$$QMAKE_MAC_SDK\'")

View File

@ -27,6 +27,7 @@ defineTest(addSimdCompiler) {
CONFIG($$1) {
cflags = $$eval(QMAKE_CFLAGS_$${upname})
ltcg: cflags += $$QMAKE_CFLAGS_DISABLE_LTCG
contains(QT_CPU_FEATURES, $$name) {
# Default compiler settings include this feature, so just add to SOURCES
SOURCES += $$eval($$sources_var)

View File

@ -54,3 +54,65 @@ isEmpty(QMAKE_COMPILER) {
warning("qmake spec does not announce the compiler family. Guessed $${QMAKE_COMPILER}.")
}
CONFIG += $$QMAKE_COMPILER
equals(MAKEFILE_GENERATOR, MSBUILD) \
|equals(MAKEFILE_GENERATOR, MSVC.NET) \
|isEmpty(QMAKE_SH) {
QMAKE_ZIP = zip -r -9
QMAKE_COPY = copy /y
QMAKE_COPY_FILE = $$QMAKE_COPY
QMAKE_COPY_DIR = xcopy /s /q /y /i
# xcopy copies the contained files if source is a directory. Deal with it.
CONFIG += copy_dir_files
QMAKE_MOVE = move
QMAKE_DEL_FILE = del
QMAKE_DEL_DIR = rmdir
QMAKE_DEL_TREE = rmdir /s /q
QMAKE_CHK_EXISTS = if not exist %1
QMAKE_CHK_DIR_EXISTS = if not exist # legacy
QMAKE_MKDIR = mkdir # legacy
QMAKE_MKDIR_CMD = if not exist %1 mkdir %1 & if not exist %1 exit 1
QMAKE_STREAM_EDITOR = $(QMAKE) -install sed
QMAKE_INSTALL_FILE = copy /y
QMAKE_INSTALL_PROGRAM = copy /y
} else {
QMAKE_TAR = tar -cf
QMAKE_GZIP = gzip -9f
QMAKE_COPY = cp -f
QMAKE_COPY_FILE = $$QMAKE_COPY
QMAKE_COPY_DIR = $$QMAKE_COPY -R
QMAKE_MOVE = mv -f
QMAKE_DEL_FILE = rm -f
QMAKE_DEL_DIR = rmdir
QMAKE_DEL_TREE = rm -rf
QMAKE_CHK_EXISTS = test -e %1 ||
QMAKE_CHK_DIR_EXISTS = test -d # legacy
QMAKE_MKDIR = mkdir -p # legacy
QMAKE_MKDIR_CMD = test -d %1 || mkdir -p %1
QMAKE_STREAM_EDITOR = sed
equals(QMAKE_HOST.os, Windows) {
MINGW_IN_SHELL = 1 # legacy
# Override built-ins.
QMAKE_DIR_SEP = /
QMAKE_DIRLIST_SEP = :
# Because install's ability to set permissions is not relevant on Windows,
# and git's msys does not provide it to start with.
QMAKE_INSTALL_FILE = cp -f
QMAKE_INSTALL_PROGRAM = cp -f
} else {
QMAKE_INSTALL_FILE = install -m 644 -p
QMAKE_INSTALL_PROGRAM = install -m 755 -p
}
}
QMAKE_INSTALL_DIR = $$QMAKE_COPY_DIR
equals(QMAKE_HOST.os, Windows) {
# Ugly (and broken for relative paths) hack to support cross-building for Unix.
QMAKE_SYMBOLIC_LINK = $$QMAKE_COPY
QMAKE_LN_SHLIB = $$QMAKE_SYMBOLIC_LINK
} else {
QMAKE_SYMBOLIC_LINK = ln -f -s
QMAKE_LN_SHLIB = ln -s
}

View File

@ -187,5 +187,11 @@ contains(INSTALLS, target) {
}
}
macx-xcode:bundle:isEmpty(QMAKE_BUNDLE_EXTENSION) {
QMAKE_PBX_PRODUCT_TYPE = com.apple.product-type.bundle.unit-test
QMAKE_PBX_BUNDLE_TYPE = wrapper.cfbundle
QMAKE_BUNDLE_EXTENSION = .xctest
}
} # have_target

View File

@ -45,8 +45,6 @@ QMAKE_RANLIB =
QMAKE_STRIP = strip
QMAKE_STRIPFLAGS_LIB += --strip-unneeded
QMAKE_INSTALL_FILE = install -m 644 -p
QMAKE_INSTALL_PROGRAM = install -m 755 -p
include(../common/unix.conf)
include(../common/gcc-base-unix.conf)

View File

@ -1,14 +1,5 @@
# In case the user sets the SDK manually
contains(QMAKE_MAC_SDK, ^iphonesimulator.*) {
iphonesimulator_and_iphoneos: \
error("iOS simulator is handled automatically for iphonesimulator_and_iphoneos")
CONFIG += iphonesimulator
}
iphonesimulator_and_iphoneos:iphonesimulator: \
QMAKE_MAC_SDK ~= s,^iphoneos,iphonesimulator,
load(sdk)
# Resolve config so we don't need to use CONFIG() later on
CONFIG(iphonesimulator, iphonesimulator|iphoneos) {
@ -76,8 +67,8 @@ equals(TEMPLATE, app) {
args += $$system_quote($$arg)
system("cd $$system_quote($$OUT_PWD) && $$QMAKE_QMAKE $$args $$system_quote($$_PRO_FILE_) -spec macx-xcode")
check.commands = "$(MAKE) -f $(MAKEFILE).ReleaseSimulator xcode_build_check"
QMAKE_EXTRA_TARGETS += check
# We have a target, even though our template is aux
CONFIG += have_target
} else {
load(resolve_config)
@ -92,10 +83,13 @@ equals(TEMPLATE, app) {
else: \
cfg = release
for(action, $$list(build install clean)) {
for(action, $$list(build install clean test)) {
equals(action, build) {
action_target_suffix =
action_target = all
} else: equals(action, test) {
action_target_suffix = -check
action_target = check
} else {
action_target_suffix = -$$action
action_target = $$action
@ -103,7 +97,7 @@ equals(TEMPLATE, app) {
target = $${sdk}-$${cfg}$${action_target_suffix}
$${target}.commands = "@bash -o pipefail -c 'xcodebuild $$action -sdk $$sdk -configuration $$title($$cfg) | grep -v setenv'"
$${target}.commands = "@bash -o pipefail -c 'xcodebuild $$action -scheme $(TARGET) -sdk $$sdk -configuration $$title($$cfg) | grep -v setenv'"
QMAKE_EXTRA_TARGETS += $$target
$${action_target}.depends += $$target
@ -115,12 +109,7 @@ equals(TEMPLATE, app) {
QMAKE_EXTRA_TARGETS += xcode_build_dir_distclean
distclean.depends = xcode_build_dir_distclean
QMAKE_EXTRA_TARGETS += distclean
xcode_build_check.commands = "$(TESTRUNNER) $$title($$cfg)-$${sdk}/$(TARGET).app $(TESTARGS)"
QMAKE_EXTRA_TARGETS += xcode_build_check
}
CONFIG =
}
}
} else: equals(TEMPLATE, lib) {

View File

@ -1,5 +1,6 @@
equals(TEMPLATE, app):contains(QT, gui(-private)?) {
qt_depends = $$resolve_depends(QT, "QT.")
equals(TEMPLATE, app):contains(qt_depends, gui(-private)?) {
LIBS *= -L$$[QT_INSTALL_PLUGINS/get]/platforms
lib_name = qios

View File

@ -1,4 +1,33 @@
# In case the user sets the SDK manually
contains(QMAKE_MAC_SDK, ^iphonesimulator.*) {
iphonesimulator_and_iphoneos: \
error("iOS simulator is handled automatically for iphonesimulator_and_iphoneos")
CONFIG += iphonesimulator
}
iphonesimulator_and_iphoneos:iphonesimulator: \
QMAKE_MAC_SDK ~= s,^iphoneos,iphonesimulator,
load(sdk)
lessThan(QMAKE_MAC_SDK_VERSION, "8.0"): \
error("Current $$QMAKE_MAC_SDK SDK version ($$QMAKE_MAC_SDK_VERSION) is too old. Please upgrade Xcode.")
macx-xcode {
sdk_path_iphoneos.name = "QMAKE_MAC_SDK_PATH[sdk=iphoneos*]"
sdk_path_iphoneos.value = $$QMAKE_MAC_SDK_PATH
QMAKE_MAC_SDK_PATH ~= s,iPhoneOS,iPhoneSimulator,
sdk_path_iphonesimulator.name = "QMAKE_MAC_SDK_PATH[sdk=iphonesimulator*]"
sdk_path_iphonesimulator.value = $$QMAKE_MAC_SDK_PATH
QMAKE_MAC_XCODE_SETTINGS += sdk_path_iphoneos sdk_path_iphonesimulator
QMAKE_MAC_SDK_PATH = "$(QMAKE_MAC_SDK_PATH)"
sdk_platform_path_iphoneos.name = "QMAKE_MAC_SDK_PLATFORM_PATH[sdk=iphoneos*]"
sdk_platform_path_iphoneos.value = $$QMAKE_MAC_SDK_PLATFORM_PATH
QMAKE_MAC_SDK_PLATFORM_PATH ~= s,iPhoneOS,iPhoneSimulator,
sdk_platform_path_iphonesimulator.name = "QMAKE_MAC_SDK_PLATFORM_PATH[sdk=iphonesimulator*]"
sdk_platform_path_iphonesimulator.value = $$QMAKE_MAC_SDK_PLATFORM_PATH
QMAKE_MAC_XCODE_SETTINGS += sdk_platform_path_iphoneos sdk_platform_path_iphonesimulator
QMAKE_MAC_SDK_PLATFORM_PATH = "$(QMAKE_MAC_SDK_PLATFORM_PATH)"
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -6,6 +6,8 @@
QMAKESPEC = $$dirname(PWD)/$$[QMAKE_XSPEC]
QMAKE_XCODE_SPECDIR = $$PWD
include($$QMAKESPEC/qmake.conf)
MAKEFILE_GENERATOR = XCODE

View File

@ -109,8 +109,6 @@ QMAKE_RANLIB =
QMAKE_STRIP = host-strip
QMAKE_STRIPFLAGS_LIB += --strip-unneeded
QMAKE_INSTALL_FILE = install -m 644 -p
QMAKE_INSTALL_PROGRAM = install -m 755 -p
include(../../common/unix.conf)
load(qt_config)

View File

@ -87,8 +87,6 @@ QMAKE_RANLIB =
QMAKE_STRIP = strip
QMAKE_STRIPFLAGS_LIB += --strip-unneeded
QMAKE_INSTALL_FILE = install -m 644 -p
QMAKE_INSTALL_PROGRAM = install -m 755 -p
include(../../common/unix.conf)
load(qt_config)

View File

@ -86,8 +86,6 @@ QMAKE_RANLIB =
QMAKE_STRIP = strip
QMAKE_STRIPFLAGS_LIB += --strip-unneeded
QMAKE_INSTALL_FILE = install -m 644 -p
QMAKE_INSTALL_PROGRAM = install -m 755 -p
include(../../common/unix.conf)
load(qt_config)

View File

@ -93,19 +93,6 @@ QMAKE_LIBS_OPENGL_ES2_DEBUG = -llibEGLd -llibGLESv2d -lgdi32 -luser32
QMAKE_LIBS_COMPAT = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32
QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain
!isEmpty(QMAKE_SH) {
MINGW_IN_SHELL = 1
QMAKE_DIR_SEP = /
QMAKE_DIRLIST_SEP = :
include(../common/shell-unix.conf)
# Because install's ability to set permissions is not relevant on Windows,
# and git's msys does not provide it to start with.
QMAKE_INSTALL_FILE = cp -f
QMAKE_INSTALL_PROGRAM = cp -f
} else {
include(../common/shell-win32.conf)
}
QMAKE_IDL = midl
QMAKE_LIB = $${CROSS_COMPILE}ar -ru
QMAKE_RC = $${CROSS_COMPILE}windres

View File

@ -79,7 +79,5 @@ QMAKE_IDL = midl
QMAKE_LIB = xilib /NOLOGO
QMAKE_RC = rc
include(../common/shell-win32.conf)
DSP_EXTENSION = .dsp
load(qt_config)

View File

@ -7,5 +7,4 @@
MSC_VER = 1400
MSVC_VER = 8.0
include(../common/msvc-desktop.conf)
include(../common/shell-win32.conf)
load(qt_config)

View File

@ -7,5 +7,4 @@
MSC_VER = 1500
MSVC_VER = 9.0
include(../common/msvc-desktop.conf)
include(../common/shell-win32.conf)
load(qt_config)

View File

@ -7,5 +7,4 @@
MSC_VER = 1600
MSVC_VER = 10.0
include(../common/msvc-desktop.conf)
include(../common/shell-win32.conf)
load(qt_config)

View File

@ -7,5 +7,4 @@
MSC_VER = 1700
MSVC_VER = 11.0
include(../common/msvc-desktop.conf)
include(../common/shell-win32.conf)
load(qt_config)

View File

@ -7,5 +7,4 @@
MSC_VER = 1800
MSVC_VER = 12.0
include(../common/msvc-desktop.conf)
include(../common/shell-win32.conf)
load(qt_config)

View File

@ -7,5 +7,4 @@
MSC_VER = 1900
MSVC_VER = 14.0
include(../common/msvc-desktop.conf)
include(../common/shell-win32.conf)
load(qt_config)

View File

@ -2555,18 +2555,64 @@
\li identity
\li The unique ID of the app. Defaults to reusing the existing generated
manifest's UUID, or generates a new UUID if none is present.
\row
\li logo_30x30
\li Logo image file of size 30x30 pixels. This is not supported on Windows Phone.
\row
\li logo_41x41
\li Logo image file of size 41x41 pixels. This is only supported on Windows Phone.
\row
\li logo_70x70
\li Logo image file of size 70x70 pixels. This is not supported on Windows Phone.
\row
\li logo_71x71
\li Logo image file of size 71x71 pixels. This is only supported on Windows Phone.
\row
\li logo_150x150
\li Logo image file of size 150x150 pixels. This is supported on all Windows
Store App platforms.
\row
\li logo_310x150
\li Logo image file of size 310x150 pixels. This is supported on all Windows
Store App platforms.
\row
\li logo_310x310
\li Logo image file of size 310x310 pixels. This is supported on all Windows
Store App platforms.
\row
\li logo_620x300
\li Splash screen image file of size 620x300 pixels. This is not supported on
Windows Phone.
\row
\li logo_480x800
\li Splash sceen image file of size 480x800 pixels. This is only supported on
Windows Phone.
\row
\li logo_large
\li Large logo image file. Default provided by the mkspec.
\li Large logo image file. This has to be 150x150 pixels. Supported on all
Windows Store App platforms. Default provided by the mkspec.
\row
\li logo_medium
\li Medium logo image file. Default provided by the mkspec.
\li Medium logo image file. For Windows Phone the image must have a pixel size
of 71x71, for other Windows Store App platforms 70x70. Default provided by
the mkspec.
\row
\li logo_small
\li Small logo image file. Default provided by the mkspec.
\li Small logo image file. For Windows Phone the image must have a pixel size
of 44x44, for other Windows Store App platforms 30x30. Default provided by
the mkspec.
\row
\li logo_splash
\li Splash screen image file. For Windows Phone the image must have a pixel size
of 480x800, for other Windows Store App platforms 620x300. Default provided
by the mkspec.
\row
\li logo_store
\li Logo image file for Windows Store. Default provided by the mkspec.
\row
\li logo_wide
\li Wide logo image file. This has to be 310x150 pixels. Supported on all
Windows Store App platforms. Default provided by the mkspec.
\row
\li name
\li The name of the package as displayed to the user. Defaults to TARGET.
@ -2582,9 +2628,6 @@
\row
\li publisher_id
\li The publisher's distinguished name (default: \c{CN=MyCN}).
\row
\li splash_screen
\li Splash screen image file. Default provided by the mkspec.
\row
\li target
\li The name of the target (.exe). Defaults to TARGET.
@ -2612,6 +2655,10 @@
WINRT_MANIFEST = someManifest.xml.in
\endcode
\note The required image sizes of \e logo_small, \e logo_medium, and \e logo_large
depend on the target platform. The general descriptions are overwritten if a
description that specifies the size is provided.
\target YACCSOURCES
\section1 YACCSOURCES

View File

@ -1573,6 +1573,52 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
}
}
// Scheme
{
QString xcodeSpecDir = project->first("QMAKE_XCODE_SPECDIR").toQString();
bool wroteCustomScheme = false;
QString projectSharedSchemesPath = pbx_dir + "/xcshareddata/xcschemes";
if (mkdir(projectSharedSchemesPath)) {
QString target = project->first("QMAKE_ORIG_TARGET").toQString();
QFile defaultSchemeFile(xcodeSpecDir + "/default.xcscheme");
QFile outputSchemeFile(projectSharedSchemesPath + Option::dir_sep + target + ".xcscheme");
if (defaultSchemeFile.open(QIODevice::ReadOnly)
&& outputSchemeFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream defaultSchemeStream(&defaultSchemeFile);
QString schemeData = defaultSchemeStream.readAll();
schemeData.replace("@QMAKE_ORIG_TARGET@", target);
schemeData.replace("@TARGET_PBX_KEY@", keyFor(pbx_dir + "QMAKE_PBX_TARGET"));
QTextStream outputSchemeStream(&outputSchemeFile);
outputSchemeStream << schemeData;
wroteCustomScheme = true;
}
}
if (wroteCustomScheme) {
// Prevent Xcode from auto-generating schemes
QString workspaceSettingsFilename("WorkspaceSettings.xcsettings");
QString workspaceSharedDataPath = pbx_dir + "/project.xcworkspace/xcshareddata";
if (mkdir(workspaceSharedDataPath)) {
QFile::copy(xcodeSpecDir + Option::dir_sep + workspaceSettingsFilename,
workspaceSharedDataPath + Option::dir_sep + workspaceSettingsFilename);
} else {
wroteCustomScheme = false;
}
}
if (!wroteCustomScheme)
warn_msg(WarnLogic, "Failed to generate schemes in '%s', " \
"falling back to Xcode auto-generated schemes", qPrintable(projectSharedSchemesPath));
}
qmake_setpwd(input_dir);
return true;

View File

@ -58,22 +58,8 @@ UnixMakefileGenerator::init()
project->values("ICON") = project->values("RC_FILE");
if(project->isEmpty("QMAKE_EXTENSION_PLUGIN"))
project->values("QMAKE_EXTENSION_PLUGIN").append(project->first("QMAKE_EXTENSION_SHLIB"));
if(project->isEmpty("QMAKE_COPY_FILE"))
project->values("QMAKE_COPY_FILE").append("$(COPY)");
if(project->isEmpty("QMAKE_STREAM_EDITOR"))
project->values("QMAKE_STREAM_EDITOR").append("sed");
if(project->isEmpty("QMAKE_COPY_DIR"))
project->values("QMAKE_COPY_DIR").append("$(COPY) -R");
if(project->isEmpty("QMAKE_INSTALL_FILE"))
project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
if(project->isEmpty("QMAKE_INSTALL_DIR"))
project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)");
if(project->isEmpty("QMAKE_INSTALL_PROGRAM"))
project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)");
if(project->isEmpty("QMAKE_LIBTOOL"))
project->values("QMAKE_LIBTOOL").append("libtool --silent");
if(project->isEmpty("QMAKE_SYMBOLIC_LINK"))
project->values("QMAKE_SYMBOLIC_LINK").append("ln -f -s");
project->values("QMAKE_ORIG_TARGET") = project->values("TARGET");

View File

@ -1298,8 +1298,6 @@ void UnixMakefileGenerator::init2()
else
project->values("TARGET") = project->values("TARGET_x.y.z");
}
if(project->isEmpty("QMAKE_LN_SHLIB"))
project->values("QMAKE_LN_SHLIB").append("ln -s");
if (!project->values("QMAKE_LFLAGS_SONAME").isEmpty()) {
ProString soname;
if(project->isActiveConfig("plugin")) {

View File

@ -232,16 +232,6 @@ void MingwMakefileGenerator::init()
project->values("QMAKE_LIB_FLAG").append("1");
else if(project->first("TEMPLATE") == "subdirs") {
MakefileGenerator::init();
if(project->isEmpty("QMAKE_COPY_FILE"))
project->values("QMAKE_COPY_FILE").append("$(COPY)");
if(project->isEmpty("QMAKE_COPY_DIR"))
project->values("QMAKE_COPY_DIR").append("xcopy /s /q /y /i");
if(project->isEmpty("QMAKE_INSTALL_FILE"))
project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
if(project->isEmpty("QMAKE_INSTALL_PROGRAM"))
project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)");
if(project->isEmpty("QMAKE_INSTALL_DIR"))
project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)");
if(project->values("MAKEFILE").isEmpty())
project->values("MAKEFILE").append("Makefile");
return;

View File

@ -340,16 +340,6 @@ void NmakeMakefileGenerator::init()
MakefileGenerator::init();
if(project->values("MAKEFILE").isEmpty())
project->values("MAKEFILE").append("Makefile");
if(project->isEmpty("QMAKE_COPY_FILE"))
project->values("QMAKE_COPY_FILE").append("$(COPY)");
if(project->isEmpty("QMAKE_COPY_DIR"))
project->values("QMAKE_COPY_DIR").append("xcopy /s /q /y /i");
if(project->isEmpty("QMAKE_INSTALL_FILE"))
project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
if(project->isEmpty("QMAKE_INSTALL_PROGRAM"))
project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)");
if(project->isEmpty("QMAKE_INSTALL_DIR"))
project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)");
return;
}

View File

@ -280,19 +280,6 @@ void Win32MakefileGenerator::processVars()
&& !project->values("VER_MAJ").isEmpty())
project->values("TARGET_VERSION_EXT").append(project->first("VER_MAJ"));
if(project->isEmpty("QMAKE_COPY_FILE"))
project->values("QMAKE_COPY_FILE").append("$(COPY)");
if(project->isEmpty("QMAKE_COPY_DIR"))
project->values("QMAKE_COPY_DIR").append("xcopy /s /q /y /i");
if (project->isEmpty("QMAKE_STREAM_EDITOR"))
project->values("QMAKE_STREAM_EDITOR").append("$(QMAKE) -install sed");
if(project->isEmpty("QMAKE_INSTALL_FILE"))
project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
if(project->isEmpty("QMAKE_INSTALL_PROGRAM"))
project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)");
if(project->isEmpty("QMAKE_INSTALL_DIR"))
project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)");
fixTargetExt();
processRcFileVar();

View File

@ -866,8 +866,8 @@ public class QtActivityDelegate
while (itr.hasNext())
m_activity.runOnUiThread(itr.next());
QtNative.updateApplicationState(ApplicationActive);
if (m_started) {
QtNative.updateApplicationState(ApplicationActive);
QtNative.clearLostActions();
QtNative.updateWindow();
updateFullScreen(); // Suspending the app clears the immersive mode, so we need to set it again.

View File

@ -50,25 +50,25 @@
\list
\li QtConcurrent::map() applies a function to every item in a container,
\li \l {QtConcurrent::map}{QtConcurrent::map()} applies a function to every item in a container,
modifying the items in-place.
\li QtConcurrent::mapped() is like map(), except that it returns a new
\li \l {QtConcurrent::mapped}{QtConcurrent::mapped()} is like map(), except that it returns a new
container with the modifications.
\li QtConcurrent::mappedReduced() is like mapped(), except that the
\li \l {QtConcurrent::mappedReduced}{QtConcurrent::mappedReduced()} is like mapped(), except that the
modified results are reduced or folded into a single result.
\li QtConcurrent::filter() removes all items from a container based on the
\li \l {QtConcurrent::filter}{QtConcurrent::filter()} removes all items from a container based on the
result of a filter function.
\li QtConcurrent::filtered() is like filter(), except that it returns a new
\li \l {QtConcurrent::filtered}{QtConcurrent::filtered()} is like filter(), except that it returns a new
container with the filtered results.
\li QtConcurrent::filteredReduced() is like filtered(), except that the
\li \l {QtConcurrent::filteredReduced}{QtConcurrent::filteredReduced()} is like filtered(), except that the
filtered results are reduced or folded into a single result.
\li QtConcurrent::run() runs a function in another thread.
\li \l {QtConcurrent::run}{QtConcurrent::run()} runs a function in another thread.
\li QFuture represents the result of an asynchronous computation.

View File

@ -230,6 +230,102 @@ template <typename X> struct QAtomicOps
{
return _q_value.fetch_add(valueToAdd, std::memory_order_acq_rel);
}
template <typename T> static inline
T fetchAndSubRelaxed(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_sub(valueToAdd, std::memory_order_relaxed);
}
template <typename T> static inline
T fetchAndSubAcquire(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_sub(valueToAdd, std::memory_order_acquire);
}
template <typename T> static inline
T fetchAndSubRelease(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_sub(valueToAdd, std::memory_order_release);
}
template <typename T> static inline
T fetchAndSubOrdered(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_sub(valueToAdd, std::memory_order_acq_rel);
}
template <typename T> static inline
T fetchAndAndRelaxed(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_and(valueToAdd, std::memory_order_relaxed);
}
template <typename T> static inline
T fetchAndAndAcquire(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_and(valueToAdd, std::memory_order_acquire);
}
template <typename T> static inline
T fetchAndAndRelease(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_and(valueToAdd, std::memory_order_release);
}
template <typename T> static inline
T fetchAndAndOrdered(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_and(valueToAdd, std::memory_order_acq_rel);
}
template <typename T> static inline
T fetchAndOrRelaxed(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_or(valueToAdd, std::memory_order_relaxed);
}
template <typename T> static inline
T fetchAndOrAcquire(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_or(valueToAdd, std::memory_order_acquire);
}
template <typename T> static inline
T fetchAndOrRelease(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_or(valueToAdd, std::memory_order_release);
}
template <typename T> static inline
T fetchAndOrOrdered(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_or(valueToAdd, std::memory_order_acq_rel);
}
template <typename T> static inline
T fetchAndXorRelaxed(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_xor(valueToAdd, std::memory_order_relaxed);
}
template <typename T> static inline
T fetchAndXorAcquire(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_xor(valueToAdd, std::memory_order_acquire);
}
template <typename T> static inline
T fetchAndXorRelease(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_xor(valueToAdd, std::memory_order_release);
}
template <typename T> static inline
T fetchAndXorOrdered(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return _q_value.fetch_xor(valueToAdd, std::memory_order_acq_rel);
}
};
#ifdef ATOMIC_VAR_INIT

View File

@ -585,6 +585,10 @@ class QDataStream;
# define QT_NO_SOCKS5
#endif
#if defined(Q_OS_IOS)
# define QT_NO_PROCESS
#endif
inline void qt_noop(void) {}
/* These wrap try/catch so we can switch off exceptions later.
@ -660,7 +664,7 @@ Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line)
#if !defined(Q_ASSERT)
# if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
# define Q_ASSERT(cond) do { } while (false && (cond))
# define Q_ASSERT(cond) do { } while ((false) && (cond))
# else
# define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
# endif

View File

@ -1663,6 +1663,7 @@ public:
QT_Q_ENUM(ItemSelectionOperation)
QT_Q_FLAG(ItemFlags)
QT_Q_ENUM(CheckState)
QT_Q_ENUM(ItemDataRole)
QT_Q_ENUM(SortOrder)
QT_Q_ENUM(CaseSensitivity)
QT_Q_FLAG(MatchFlags)

View File

@ -157,13 +157,17 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
if (!setNativeLocks(fd))
qWarning() << "setNativeLocks failed:" << strerror(errno);
if (qt_write_loop(fd, fileData.constData(), fileData.size()) < fileData.size()) {
close(fd);
if (!QFile::remove(fileName))
qWarning("QLockFile: Could not remove our own lock file %s.", qPrintable(fileName));
return QLockFile::UnknownError; // partition full
}
// We hold the lock, continue.
fileHandle = fd;
QLockFile::LockError error = QLockFile::NoError;
if (qt_write_loop(fd, fileData.constData(), fileData.size()) < fileData.size())
error = QLockFile::UnknownError; // partition full
return error;
return QLockFile::NoError;
}
bool QLockFilePrivate::removeStaleLock()

View File

@ -164,20 +164,20 @@ public:
explicit QAbstractItemModel(QObject *parent = 0);
virtual ~QAbstractItemModel();
bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const;
virtual QModelIndex index(int row, int column,
Q_INVOKABLE bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const;
Q_INVOKABLE virtual QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const = 0;
virtual QModelIndex parent(const QModelIndex &child) const = 0;
Q_INVOKABLE virtual QModelIndex parent(const QModelIndex &child) const = 0;
virtual QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
Q_INVOKABLE virtual QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
Q_INVOKABLE virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
Q_INVOKABLE virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
Q_INVOKABLE virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
Q_INVOKABLE virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual QVariant headerData(int section, Qt::Orientation orientation,
Q_INVOKABLE virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
int role = Qt::EditRole);
@ -217,9 +217,9 @@ public:
inline bool moveColumn(const QModelIndex &sourceParent, int sourceColumn,
const QModelIndex &destinationParent, int destinationChild);
virtual void fetchMore(const QModelIndex &parent);
virtual bool canFetchMore(const QModelIndex &parent) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
Q_INVOKABLE virtual void fetchMore(const QModelIndex &parent);
Q_INVOKABLE virtual bool canFetchMore(const QModelIndex &parent) const;
Q_INVOKABLE virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
virtual QModelIndex buddy(const QModelIndex &index) const;
virtual QModelIndexList match(const QModelIndex &start, int role,
@ -484,6 +484,5 @@ inline uint qHash(const QModelIndex &index) Q_DECL_NOTHROW
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QModelIndexList)
Q_DECLARE_METATYPE(QPersistentModelIndex)
#endif // QABSTRACTITEMMODEL_H

View File

@ -146,6 +146,7 @@ class Q_CORE_EXPORT QItemSelectionModel : public QObject
Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged)
Q_PROPERTY(bool hasSelection READ hasSelection NOTIFY selectionChanged STORED false DESIGNABLE false)
Q_PROPERTY(QModelIndex currentIndex READ currentIndex NOTIFY currentChanged STORED false DESIGNABLE false)
Q_PROPERTY(QItemSelection selection READ selection NOTIFY selectionChanged STORED false DESIGNABLE false)
Q_DECLARE_PRIVATE(QItemSelectionModel)
@ -186,7 +187,7 @@ public:
Q_INVOKABLE QModelIndexList selectedIndexes() const;
Q_INVOKABLE QModelIndexList selectedRows(int column = 0) const;
Q_INVOKABLE QModelIndexList selectedColumns(int row = 0) const;
Q_INVOKABLE const QItemSelection selection() const;
const QItemSelection selection() const;
// ### Qt 6: Merge these two as "QAbstractItemModel *model() const"
const QAbstractItemModel *model() const;

View File

@ -368,7 +368,9 @@ struct QCoreApplicationData {
}
#endif
QString orgName, orgDomain, application;
QString orgName, orgDomain;
QString application; // application name, initially from argv[0], can then be modified.
QString applicationNameCompat; // for QDesktopServices. Only set explicitly.
QString applicationVersion;
#ifndef QT_NO_LIBRARY
@ -750,6 +752,9 @@ void QCoreApplication::init()
Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object");
QCoreApplication::self = this;
// Store app name (so it's still available after QCoreApplication is destroyed)
coreappdata()->application = d_func()->appName();
QLoggingRegistry::instance()->init();
#ifndef QT_NO_QOBJECT
@ -2345,9 +2350,13 @@ QString QCoreApplication::organizationDomain()
*/
void QCoreApplication::setApplicationName(const QString &application)
{
if (coreappdata()->application == application)
QString newAppName = application;
if (newAppName.isEmpty() && QCoreApplication::self)
newAppName = QCoreApplication::self->d_func()->appName();
if (coreappdata()->application == newAppName)
return;
coreappdata()->application = application;
coreappdata()->application = newAppName;
coreappdata()->applicationNameCompat = newAppName;
#ifndef QT_NO_QOBJECT
if (QCoreApplication::self)
emit QCoreApplication::self->applicationNameChanged();
@ -2359,16 +2368,13 @@ QString QCoreApplication::applicationName()
#ifdef Q_OS_BLACKBERRY
coreappdata()->loadManifest();
#endif
QString appname = coreappdata() ? coreappdata()->application : QString();
if (appname.isEmpty() && QCoreApplication::self)
appname = QCoreApplication::self->d_func()->appName();
return appname;
return coreappdata() ? coreappdata()->application : QString();
}
// Exported for QDesktopServices (Qt4 behavior compatibility)
Q_CORE_EXPORT QString qt_applicationName_noFallback()
{
return coreappdata()->application;
return coreappdata()->applicationNameCompat;
}
/*!

View File

@ -277,6 +277,7 @@ struct DefinedTypesFilter {
\value QJsonArray QJsonArray
\value QJsonDocument QJsonDocument
\value QModelIndex QModelIndex
\value QPersistentModelIndex QPersistentModelIndex (since 5.5)
\value QUuid QUuid
\value QByteArrayList QByteArrayList
@ -1209,6 +1210,7 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::VoidStar:
case QMetaType::QObjectStar:
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
case QMetaType::QJsonValue:
case QMetaType::QJsonObject:
case QMetaType::QJsonArray:
@ -1429,6 +1431,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::VoidStar:
case QMetaType::QObjectStar:
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
case QMetaType::QJsonValue:
case QMetaType::QJsonObject:
case QMetaType::QJsonArray:

View File

@ -113,6 +113,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(QJsonObject, 46, QJsonObject) \
F(QJsonArray, 47, QJsonArray) \
F(QJsonDocument, 48, QJsonDocument) \
F(QPersistentModelIndex, 50, QPersistentModelIndex) \
#define QT_FOR_EACH_STATIC_CORE_POINTER(F)\
F(QObjectStar, 39, QObject*)
@ -407,7 +408,7 @@ public:
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
FirstCoreType = Bool,
LastCoreType = QByteArrayList,
LastCoreType = QPersistentModelIndex,
FirstGuiType = QFont,
LastGuiType = QPolygonF,
FirstWidgetsType = QSizePolicy,
@ -431,7 +432,7 @@ public:
QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
QEasingCurve = 29, QUuid = 30, QVariant = 41, QModelIndex = 42,
QRegularExpression = 44,
QPersistentModelIndex = 50, QRegularExpression = 44,
QJsonValue = 45, QJsonObject = 46, QJsonArray = 47, QJsonDocument = 48,
QByteArrayList = 49, QObjectStar = 39, SChar = 40,
Void = 43,

View File

@ -192,6 +192,7 @@ template<> struct TypeDefinition<QJsonDocument> { static const bool IsAvailable
template<> struct TypeDefinition<QJsonObject> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QJsonValue> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QModelIndex> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QPersistentModelIndex> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QUrl> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QByteArrayList> { static const bool IsAvailable = false; };
#endif

View File

@ -390,7 +390,25 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return false;
}
break;
#endif
case QVariant::ModelIndex:
switch (d->type) {
case QVariant::PersistentModelIndex:
*static_cast<QModelIndex *>(result) = QModelIndex(*v_cast<QPersistentModelIndex>(d));
break;
default:
return false;
}
break;
case QVariant::PersistentModelIndex:
switch (d->type) {
case QVariant::ModelIndex:
*static_cast<QPersistentModelIndex *>(result) = QPersistentModelIndex(*v_cast<QModelIndex>(d));
break;
default:
return false;
}
break;
#endif // QT_BOOTSTRAPPED
case QVariant::String: {
QString *str = static_cast<QString *>(result);
switch (d->type) {
@ -1208,6 +1226,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names
\value EasingCurve a QEasingCurve
\value Uuid a QUuid
\value ModelIndex a QModelIndex
\value PersistentModelIndex a QPersistentModelIndex (since 5.5)
\value Font a QFont
\value Hash a QVariantHash
\value Icon a QIcon
@ -1455,7 +1474,14 @@ QVariant::QVariant(const char *val)
\since 5.0
\fn QVariant::QVariant(const QModelIndex &val)
Constructs a new variant with an modelIndex value, \a val.
Constructs a new variant with a QModelIndex value, \a val.
*/
/*!
\since 5.5
\fn QVariant::QVariant(const QPersistentModelIndex &val)
Constructs a new variant with a QPersistentModelIndex value, \a val.
*/
/*!
@ -1763,6 +1789,9 @@ QVariant::QVariant(const QUuid &uuid)
QVariant::QVariant(const QModelIndex &modelIndex)
: d(ModelIndex)
{ v_construct<QModelIndex>(&d, modelIndex); }
QVariant::QVariant(const QPersistentModelIndex &modelIndex)
: d(PersistentModelIndex)
{ v_construct<QPersistentModelIndex>(&d, modelIndex); }
QVariant::QVariant(const QJsonValue &jsonValue)
: d(QMetaType::QJsonValue)
{ v_construct<QJsonValue>(&d, jsonValue); }
@ -2492,13 +2521,26 @@ QUuid QVariant::toUuid() const
Returns the variant as a QModelIndex if the variant has userType() \l
QModelIndex; otherwise returns a default constructed QModelIndex.
\sa canConvert(), convert()
\sa canConvert(), convert(), toPersistentModelIndex()
*/
QModelIndex QVariant::toModelIndex() const
{
return qVariantToHelper<QModelIndex>(d, handlerManager);
}
/*!
\since 5.5
Returns the variant as a QPersistentModelIndex if the variant has userType() \l
QPersistentModelIndex; otherwise returns a default constructed QPersistentModelIndex.
\sa canConvert(), convert(), toModelIndex()
*/
QModelIndex QVariant::toPersistentModelIndex() const
{
return qVariantToHelper<QPersistentModelIndex>(d, handlerManager);
}
/*!
\since 5.0
@ -2966,6 +3008,10 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject)
*/
bool QVariant::canConvert(int targetTypeId) const
{
if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex)
|| (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex))
return true;
if (targetTypeId == QMetaType::QVariantList
&& (d.type == QMetaType::QVariantList
|| d.type == QMetaType::QStringList

View File

@ -156,6 +156,7 @@ class Q_CORE_EXPORT QVariant
EasingCurve = QMetaType::QEasingCurve,
Uuid = QMetaType::QUuid,
ModelIndex = QMetaType::QModelIndex,
PersistentModelIndex = QMetaType::QPersistentModelIndex,
LastCoreType = QMetaType::LastCoreType,
Font = QMetaType::QFont,
@ -245,6 +246,7 @@ class Q_CORE_EXPORT QVariant
QVariant(const QEasingCurve &easing);
QVariant(const QUuid &uuid);
QVariant(const QModelIndex &modelIndex);
QVariant(const QPersistentModelIndex &modelIndex);
QVariant(const QJsonValue &jsonValue);
QVariant(const QJsonObject &jsonObject);
QVariant(const QJsonArray &jsonArray);
@ -318,6 +320,7 @@ class Q_CORE_EXPORT QVariant
QEasingCurve toEasingCurve() const;
QUuid toUuid() const;
QModelIndex toModelIndex() const;
QModelIndex toPersistentModelIndex() const;
QJsonValue toJsonValue() const;
QJsonObject toJsonObject() const;
QJsonArray toJsonArray() const;

View File

@ -39,6 +39,14 @@
#if defined(QT_BOOTSTRAPPED)
# include <QtCore/qatomic_bootstrap.h>
// The following two are used for testing only.
// Note that we don't check the compiler support -- you had better
// know what you're doing if you set them
#elif defined(QT_ATOMIC_FORCE_CXX11)
# include <QtCore/qatomic_cxx11.h>
#elif defined(QT_ATOMIC_FORCE_GCC)
# include <QtCore/qatomic_gcc.h>
// Compiler dependent implementation
#elif defined(Q_CC_MSVC)
# include <QtCore/qatomic_msvc.h>

View File

@ -2607,7 +2607,6 @@ QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime,
void QDateTimePrivate::setTimeSpec(Qt::TimeSpec spec, int offsetSeconds)
{
clearValidDateTime();
clearTimeZoneCached();
clearSetToDaylightStatus();
#ifndef QT_BOOTSTRAPPED
@ -2707,27 +2706,44 @@ QDateTimePrivate::DaylightStatus QDateTimePrivate::daylightStatus() const
return UnknownDaylightTime;
}
qint64 QDateTimePrivate::toMSecsSinceEpoch() const
{
switch (m_spec) {
case Qt::OffsetFromUTC:
case Qt::UTC:
return (m_msecs - (m_offsetFromUtc * 1000));
case Qt::LocalTime:
// recalculate the local timezone
return localMSecsToEpochMSecs(m_msecs);
case Qt::TimeZone:
#ifndef QT_BOOTSTRAPPED
return zoneMSecsToEpochMSecs(m_msecs, m_timeZone);
#endif
break;
}
Q_UNREACHABLE();
return 0;
}
// Check the UTC / offsetFromUTC validity
void QDateTimePrivate::checkValidDateTime()
{
switch (m_spec) {
case Qt::OffsetFromUTC:
case Qt::UTC:
// for these, a valid date and a valid time imply a valid QDateTime
if (isValidDate() && isValidTime())
setValidDateTime();
else
clearValidDateTime();
break;
case Qt::TimeZone:
// Defer checking until required as can be expensive
clearValidDateTime();
clearTimeZoneCached();
m_offsetFromUtc = 0;
break;
case Qt::LocalTime:
// Defer checking until required as can be expensive
clearValidDateTime();
m_offsetFromUtc = 0;
// for these, we need to check whether the timezone is valid and whether
// the time is valid in that timezone. Expensive, but no other option.
refreshDateTime();
break;
}
}
@ -2741,12 +2757,6 @@ void QDateTimePrivate::refreshDateTime()
// Always set by setDateTime so just return
return;
case Qt::TimeZone:
// If already cached then don't need to refresh as tz won't change
if (isTimeZoneCached())
return;
// Flag that will have a cached result after calculations
setTimeZoneCached();
break;
case Qt::LocalTime:
break;
}
@ -3082,7 +3092,6 @@ bool QDateTime::isNull() const
bool QDateTime::isValid() const
{
d->refreshDateTime();
return (d->isValidDateTime());
}
@ -3143,13 +3152,11 @@ Qt::TimeSpec QDateTime::timeSpec() const
QTimeZone QDateTime::timeZone() const
{
switch (d->m_spec) {
case Qt::OffsetFromUTC:
if (!d->m_timeZone.isValid())
d->m_timeZone = QTimeZone(d->m_offsetFromUtc);
return d->m_timeZone;
case Qt::UTC:
return QTimeZone::utc();
case Qt::OffsetFromUTC:
case Qt::TimeZone:
Q_ASSERT(d->m_timeZone.isValid());
return d->m_timeZone;
case Qt::LocalTime:
return QTimeZone::systemTimeZone();
@ -3178,7 +3185,6 @@ QTimeZone QDateTime::timeZone() const
int QDateTime::offsetFromUtc() const
{
d->refreshDateTime();
return d->m_offsetFromUtc;
}
@ -3350,7 +3356,7 @@ void QDateTime::setTimeZone(const QTimeZone &toZone)
d->m_spec = Qt::TimeZone;
d->m_offsetFromUtc = 0;
d->m_timeZone = toZone;
d->m_status = d->m_status & ~QDateTimePrivate::ValidDateTime & ~QDateTimePrivate::TimeZoneCached;
d->refreshDateTime();
}
#endif // QT_BOOTSTRAPPED
@ -3371,7 +3377,6 @@ void QDateTime::setTimeZone(const QTimeZone &toZone)
*/
qint64 QDateTime::toMSecsSinceEpoch() const
{
d->refreshDateTime();
return d->toMSecsSinceEpoch();
}
@ -3453,8 +3458,8 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs)
d->m_status = d->m_status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime
| QDateTimePrivate::TimeZoneCached;
| QDateTimePrivate::ValidDateTime;
d->refreshDateTime();
#endif // QT_BOOTSTRAPPED
break;
case Qt::LocalTime: {

View File

@ -326,7 +326,7 @@ private:
// ### Qt6: Using a private here has high impact on runtime
// on users such as QFileInfo. In Qt 6, the data members
// should be inlined.
QExplicitlySharedDataPointer<QDateTimePrivate> d;
QSharedDataPointer<QDateTimePrivate> d;
#ifndef QT_NO_DATASTREAM
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);

View File

@ -79,10 +79,9 @@ public:
enum StatusFlag {
NullDate = 0x01,
NullTime = 0x02,
ValidDate = 0x04,
ValidTime = 0x08,
ValidDateTime = 0x10,
TimeZoneCached = 0x20,
ValidDate = 0x04, // just the date field
ValidTime = 0x08, // just the time field
ValidDateTime = 0x10, // the whole object (including timezone)
SetToStandardTime = 0x40,
SetToDaylightTime = 0x80
};
@ -120,7 +119,7 @@ public:
DaylightStatus daylightStatus() const;
// Returns msecs since epoch, assumes offset value is current
inline qint64 toMSecsSinceEpoch() const { return (m_msecs - (m_offsetFromUtc * 1000)); }
inline qint64 toMSecsSinceEpoch() const;
void checkValidDateTime();
void refreshDateTime();
@ -133,14 +132,11 @@ public:
inline bool isValidDateTime() const { return m_status & ValidDateTime; }
inline void setValidDateTime() { m_status |= ValidDateTime; }
inline void clearValidDateTime() { m_status &= ~ValidDateTime; }
inline bool isTimeZoneCached() const { return m_status & TimeZoneCached; }
inline void setTimeZoneCached() { m_status |= TimeZoneCached; }
inline void clearTimeZoneCached() { m_status &= ~TimeZoneCached; }
inline void clearSetToDaylightStatus() { m_status &= ~(SetToStandardTime | SetToDaylightTime); }
#ifndef QT_BOOTSTRAPPED
static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone,
QDate *localDate, QTime *localTime);
QDate *localDate = 0, QTime *localTime = 0);
#endif // QT_BOOTSTRAPPED
static inline qint64 minJd() { return QDate::minJd(); }

View File

@ -247,6 +247,7 @@ namespace QtSharedPointer {
ExternalRefCountWithContiguousData *that =
static_cast<ExternalRefCountWithContiguousData *>(self);
that->data.~T();
Q_UNUSED(that); // MSVC warns if T has a trivial destructor
}
static void safetyCheckDeleter(ExternalRefCountData *self)
{

View File

@ -114,7 +114,7 @@ template <typename StringType> struct QStringAlgorithms
return str;
const Char *src = str.cbegin();
const Char *end = str.cend();
NakedStringType result = isConst ?
NakedStringType result = isConst || !str.isDetached() ?
StringType(str.size(), Qt::Uninitialized) :
qMove(str);

View File

@ -873,9 +873,14 @@ QWindowList QGuiApplication::topLevelWindows()
}
/*!
Returns the primary (or default) screen of the application.
Returns the primary (or default) screen of the application, or null if there is none
This will be the screen where QWindows are initially shown, unless otherwise specified.
On some platforms, it may be null when there are actually no screens connected.
It is not possible to start a new QGuiApplication while there are no screens.
Applications which were running at the time the primary screen was removed
will stop rendering graphics until one or more screens are restored.
*/
QScreen *QGuiApplication::primaryScreen()
{
@ -1859,6 +1864,13 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
window = QGuiApplication::focusWindow();
}
#if !defined(Q_OS_OSX)
// On OS X the shortcut override is checked earlier, see: QWindowSystemInterface::handleKeyEvent()
const bool checkShortcut = e->keyType == QEvent::KeyPress && window != 0;
if (checkShortcut && QWindowSystemInterface::tryHandleShortcutEvent(window, e->timestamp, e->key, e->modifiers, e->unicode))
return;
#endif // Q_OS_OSX
QKeyEvent ev(e->keyType, e->key, e->modifiers,
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers,
e->unicode, e->repeat, e->repeatCount);

View File

@ -42,57 +42,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DRAGANDDROP
#ifdef QDND_DEBUG
QString dragActionsToString(Qt::DropActions actions)
{
QString str;
if (actions == Qt::IgnoreAction) {
if (!str.isEmpty())
str += QLatin1String(" | ");
str += QLatin1String("IgnoreAction");
}
if (actions & Qt::LinkAction) {
if (!str.isEmpty())
str += QLatin1String(" | ");
str += QLatin1String("LinkAction");
}
if (actions & Qt::CopyAction) {
if (!str.isEmpty())
str += QLatin1String(" | ");
str += QLatin1String("CopyAction");
}
if (actions & Qt::MoveAction) {
if (!str.isEmpty())
str += QLatin1String(" | ");
str += QLatin1String("MoveAction");
}
if ((actions & Qt::TargetMoveAction) == Qt::TargetMoveAction ) {
if (!str.isEmpty())
str += QLatin1String(" | ");
str += QLatin1String("TargetMoveAction");
}
return str;
}
QString KeyboardModifiersToString(Qt::KeyboardModifiers modifiers)
{
QString str;
if (modifiers & Qt::ControlModifier) {
if (!str.isEmpty())
str += QLatin1String(" | ");
str += QLatin1String("ControlModifier");
}
if (modifiers & Qt::AltModifier) {
if (!str.isEmpty())
str += QLatin1String(" | ");
str += QLatin1String("AltModifier");
}
if (modifiers & Qt::ShiftModifier) {
if (!str.isEmpty())
str += QLatin1String(" | ");
str += QLatin1String("ShiftModifier");
}
return str;
}
# include <QtCore/QDebug>
#endif
QPlatformDropQtResponse::QPlatformDropQtResponse(bool accepted, Qt::DropAction acceptedAction)
@ -156,8 +106,7 @@ Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions,
Qt::KeyboardModifiers modifiers) const
{
#ifdef QDND_DEBUG
qDebug("QDragManager::defaultAction(Qt::DropActions possibleActions)");
qDebug("keyboard modifiers : %s", qPrintable(KeyboardModifiersToString(modifiers)));
qDebug() << "QDragManager::defaultAction(Qt::DropActions possibleActions)\nkeyboard modifiers : " << modifiers;
#endif
Qt::DropAction default_action = Qt::IgnoreAction;
@ -183,7 +132,7 @@ Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions,
default_action = Qt::LinkAction;
#ifdef QDND_DEBUG
qDebug("possible actions : %s", qPrintable(dragActionsToString(possibleActions)));
qDebug() << "possible actions : " << possibleActions;
#endif
// Check if the action determined is allowed
@ -199,7 +148,7 @@ Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions,
}
#ifdef QDND_DEBUG
qDebug("default action : %s", qPrintable(dragActionsToString(default_action)));
qDebug() << "default action : " << default_action;
#endif
return default_action;

View File

@ -315,7 +315,7 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_O, KB_Mac},
{QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_Gnome | KB_Mac},
{QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, KB_Mac},
{QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_Gnome | KB_KDE | KB_Mac},
{QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_X11 | KB_Gnome | KB_KDE | KB_Mac},
{QKeySequence::FullScreen, 1, Qt::META | Qt::CTRL | Qt::Key_F, KB_Mac},
{QKeySequence::FullScreen, 0, Qt::ALT | Qt::Key_Enter, KB_Win},
{QKeySequence::FullScreen, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F, KB_KDE},

View File

@ -79,7 +79,8 @@ QPlatformWindow *QPlatformWindow::parent() const
}
/*!
Returns the platform screen handle corresponding to this platform window.
Returns the platform screen handle corresponding to this platform window,
or null if the window is not associated with a screen.
*/
QPlatformScreen *QPlatformWindow::screen() const
{

View File

@ -1678,7 +1678,7 @@ bool QWindow::setMouseGrabEnabled(bool grab)
}
/*!
Returns the screen on which the window is shown.
Returns the screen on which the window is shown, or null if there is none.
For child windows, this returns the screen of the corresponding top level window.

View File

@ -292,8 +292,13 @@ void QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Q
void QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
{
// This is special handling needed for OS X which eventually will call sendEvent(), on other platforms
// this might not be safe, e.g., on Android. See: QGuiApplicationPrivate::processKeyEvent() for
// shortcut overriding on other platforms.
#if defined(Q_OS_OSX)
if (t == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, k, mods, text))
return;
#endif // Q_OS_OSX
QWindowSystemInterfacePrivate::KeyEvent * e =
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
@ -318,10 +323,7 @@ void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestam
const QString& text, bool autorep,
ushort count, bool tryShortcutOverride)
{
// on OS X we try the shortcut override even earlier and thus shouldn't handle it here
if (tryShortcutOverride && type == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, key, modifiers, text))
return;
Q_UNUSED(tryShortcutOverride)
QWindowSystemInterfacePrivate::KeyEvent * e =
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);

View File

@ -1523,10 +1523,13 @@ void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearP
#ifndef QT_NO_VECTOR3D
/*!
Multiplies this matrix by another that applies an \a eye position
transformation. The \a center value indicates the center of the
view that the \a eye is looking at. The \a up value indicates
which direction should be considered up with respect to the \a eye.
Multiplies this matrix by a viewing matrix derived from an eye
point. The \a center value indicates the center of the view that
the \a eye is looking at. The \a up value indicates which direction
should be considered up with respect to the \a eye.
\note The \a up vector must not be parallel to the line of sight
from \a eye to \a center.
*/
void QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up)
{

View File

@ -212,10 +212,19 @@ QT_BEGIN_NAMESPACE
\sa scalar(), setX(), setY(), setZ()
*/
/*!
\fn float QQuaternion::dotProduct(const QQuaternion &q1, const QQuaternion &q2)
\since 5.5
Returns the dot product of \a q1 and \a q2.
\sa length()
*/
/*!
Returns the length of the quaternion. This is also called the "norm".
\sa lengthSquared(), normalized()
\sa lengthSquared(), normalized(), dotProduct()
*/
float QQuaternion::length() const
{
@ -225,7 +234,7 @@ float QQuaternion::length() const
/*!
Returns the squared length of the quaternion.
\sa length()
\sa length(), dotProduct()
*/
float QQuaternion::lengthSquared() const
{
@ -240,7 +249,7 @@ float QQuaternion::lengthSquared() const
will be returned as-is. Otherwise the normalized form of the
quaternion of length 1 will be returned.
\sa length(), normalize()
\sa normalize(), length(), dotProduct()
*/
QQuaternion QQuaternion::normalized() const
{
@ -583,7 +592,7 @@ QQuaternion QQuaternion::fromEulerAngles(float pitch, float yaw, float roll)
\note If this quaternion is not normalized,
the resulting rotation matrix will contain scaling information.
\sa fromRotationMatrix()
\sa fromRotationMatrix(), getAxes()
*/
QMatrix3x3 QQuaternion::toRotationMatrix() const
{
@ -626,7 +635,7 @@ QMatrix3x3 QQuaternion::toRotationMatrix() const
\note If a given rotation matrix is not normalized,
the resulting quaternion will contain scaling information.
\sa toRotationMatrix()
\sa toRotationMatrix(), fromAxes()
*/
QQuaternion QQuaternion::fromRotationMatrix(const QMatrix3x3 &rot3x3)
{
@ -663,6 +672,85 @@ QQuaternion QQuaternion::fromRotationMatrix(const QMatrix3x3 &rot3x3)
return QQuaternion(scalar, axis[0], axis[1], axis[2]);
}
#ifndef QT_NO_VECTOR3D
/*!
\since 5.5
Returns the 3 orthonormal axes (\a xAxis, \a yAxis, \a zAxis) defining the quaternion.
\sa fromAxes(), toRotationMatrix()
*/
void QQuaternion::getAxes(QVector3D *xAxis, QVector3D *yAxis, QVector3D *zAxis) const
{
Q_ASSERT(xAxis && yAxis && zAxis);
const QMatrix3x3 rot3x3(toRotationMatrix());
*xAxis = QVector3D(rot3x3(0, 0), rot3x3(1, 0), rot3x3(2, 0));
*yAxis = QVector3D(rot3x3(0, 1), rot3x3(1, 1), rot3x3(2, 1));
*zAxis = QVector3D(rot3x3(0, 2), rot3x3(1, 2), rot3x3(2, 2));
}
/*!
\since 5.5
Constructs the quaternion using 3 axes (\a xAxis, \a yAxis, \a zAxis).
\note The axes are assumed to be orthonormal.
\sa getAxes(), fromRotationMatrix()
*/
QQuaternion QQuaternion::fromAxes(const QVector3D &xAxis, const QVector3D &yAxis, const QVector3D &zAxis)
{
QMatrix3x3 rot3x3(Qt::Uninitialized);
rot3x3(0, 0) = xAxis.x();
rot3x3(1, 0) = xAxis.y();
rot3x3(2, 0) = xAxis.z();
rot3x3(0, 1) = yAxis.x();
rot3x3(1, 1) = yAxis.y();
rot3x3(2, 1) = yAxis.z();
rot3x3(0, 2) = zAxis.x();
rot3x3(1, 2) = zAxis.y();
rot3x3(2, 2) = zAxis.z();
return QQuaternion::fromRotationMatrix(rot3x3);
}
/*!
\since 5.5
Returns the shortest arc quaternion to rotate from the direction described by the vector \a from
to the direction described by the vector \a to.
*/
QQuaternion QQuaternion::rotationTo(const QVector3D &from, const QVector3D &to)
{
// Based on Stan Melax's article in Game Programming Gems
const QVector3D v0(from.normalized());
const QVector3D v1(to.normalized());
float d = QVector3D::dotProduct(v0, v1) + 1.0f;
// if dest vector is close to the inverse of source vector, ANY axis of rotation is valid
if (qFuzzyIsNull(d)) {
QVector3D axis = QVector3D::crossProduct(QVector3D(1.0f, 0.0f, 0.0f), v0);
if (qFuzzyIsNull(axis.lengthSquared()))
axis = QVector3D::crossProduct(QVector3D(0.0f, 1.0f, 0.0f), v0);
axis.normalize();
// same as QQuaternion::fromAxisAndAngle(axis, 180.0f)
return QQuaternion(0.0f, axis.x(), axis.y(), axis.z());
}
d = std::sqrt(2.0f * d);
const QVector3D axis(QVector3D::crossProduct(v0, v1) / d);
return QQuaternion(d * 0.5f, axis).normalized();
}
#endif // QT_NO_VECTOR3D
/*!
\fn bool operator==(const QQuaternion &q1, const QQuaternion &q2)
\relates QQuaternion
@ -792,13 +880,10 @@ QQuaternion QQuaternion::slerp
return q2;
// Determine the angle between the two quaternions.
QQuaternion q2b;
float dot;
dot = q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
if (dot >= 0.0f) {
q2b = q2;
} else {
q2b = -q2;
QQuaternion q2b(q2);
float dot = QQuaternion::dotProduct(q1, q2);
if (dot < 0.0f) {
q2b = -q2b;
dot = -dot;
}
@ -844,13 +929,10 @@ QQuaternion QQuaternion::nlerp
return q2;
// Determine the angle between the two quaternions.
QQuaternion q2b;
float dot;
dot = q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
if (dot >= 0.0f)
q2b = q2;
else
q2b = -q2;
QQuaternion q2b(q2);
float dot = QQuaternion::dotProduct(q1, q2);
if (dot < 0.0f)
q2b = -q2b;
// Perform the linear interpolation.
return (q1 * (1.0f - t) + q2b * t).normalized();

View File

@ -78,6 +78,8 @@ public:
void setZ(float z);
void setScalar(float scalar);
Q_DECL_CONSTEXPR static inline float dotProduct(const QQuaternion &q1, const QQuaternion &q2);
float length() const;
float lengthSquared() const;
@ -132,6 +134,13 @@ public:
QMatrix3x3 toRotationMatrix() const;
static QQuaternion fromRotationMatrix(const QMatrix3x3 &rot3x3);
#ifndef QT_NO_VECTOR3D
void getAxes(QVector3D *xAxis, QVector3D *yAxis, QVector3D *zAxis) const;
static QQuaternion fromAxes(const QVector3D &xAxis, const QVector3D &yAxis, const QVector3D &zAxis);
static QQuaternion rotationTo(const QVector3D &from, const QVector3D &to);
#endif
static QQuaternion slerp
(const QQuaternion& q1, const QQuaternion& q2, float t);
static QQuaternion nlerp
@ -168,6 +177,11 @@ inline void QQuaternion::setY(float aY) { yp = aY; }
inline void QQuaternion::setZ(float aZ) { zp = aZ; }
inline void QQuaternion::setScalar(float aScalar) { wp = aScalar; }
Q_DECL_CONSTEXPR inline float QQuaternion::dotProduct(const QQuaternion &q1, const QQuaternion &q2)
{
return q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
}
inline QQuaternion QQuaternion::inverted() const
{
// Need some extra precision if the length is very small.

View File

@ -69,8 +69,6 @@ enum {
// must be multiple of 4 for easier SIMD implementations
static const int buffer_size = 2048;
#ifdef Q_COMPILER_CONSTEXPR
template<QImage::Format> Q_DECL_CONSTEXPR uint redWidth();
template<QImage::Format> Q_DECL_CONSTEXPR uint redShift();
template<QImage::Format> Q_DECL_CONSTEXPR uint greenWidth();
@ -310,6 +308,8 @@ static const uint *QT_FASTCALL convertARGBPMFromARGB32PM(uint *buffer, const uin
return buffer;
}
#ifdef Q_COMPILER_CONSTEXPR
template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutRGB()
{
return QPixelLayout{
@ -338,177 +338,6 @@ template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixe
};
}
#else // CONSTEXPR
static const uint *QT_FASTCALL convertToARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *layout, const QRgb *)
{
Q_ASSERT(layout->redWidth >= 4);
Q_ASSERT(layout->greenWidth >= 4);
Q_ASSERT(layout->blueWidth >= 4);
Q_ASSERT(layout->alphaWidth >= 4);
const uint redMask = ((1 << layout->redWidth) - 1);
const uint greenMask = ((1 << layout->greenWidth) - 1);
const uint blueMask = ((1 << layout->blueWidth) - 1);
const uchar redLeftShift = 8 - layout->redWidth;
const uchar greenLeftShift = 8 - layout->greenWidth;
const uchar blueLeftShift = 8 - layout->blueWidth;
const uchar redRightShift = 2 * layout->redWidth - 8;
const uchar greenRightShift = 2 * layout->greenWidth - 8;
const uchar blueRightShift = 2 * layout->blueWidth - 8;
const uint alphaMask = ((1 << layout->alphaWidth) - 1);
const uchar alphaLeftShift = 8 - layout->alphaWidth;
const uchar alphaRightShift = 2 * layout->alphaWidth - 8;
if (layout->premultiplied) {
for (int i = 0; i < count; ++i) {
uint alpha = (src[i] >> layout->alphaShift) & alphaMask;
uint red = (src[i] >> layout->redShift) & redMask;
uint green = (src[i] >> layout->greenShift) & greenMask;
uint blue = (src[i] >> layout->blueShift) & blueMask;
alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift);
red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift));
green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift));
blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift));
buffer[i] = (alpha << 24) | (red << 16) | (green << 8) | blue;
}
} else {
for (int i = 0; i < count; ++i) {
uint alpha = (src[i] >> layout->alphaShift) & alphaMask;
uint red = (src[i] >> layout->redShift) & redMask;
uint green = (src[i] >> layout->greenShift) & greenMask;
uint blue = (src[i] >> layout->blueShift) & blueMask;
alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift);
red = (red << redLeftShift) | (red >> redRightShift);
green = (green << greenLeftShift) | (green >> greenRightShift);
blue = (blue << blueLeftShift) | (blue >> blueRightShift);
buffer[i] = qPremultiply((alpha << 24) | (red << 16) | (green << 8) | blue);
}
}
return buffer;
}
static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int count,
const QPixelLayout *layout, const QRgb *)
{
Q_ASSERT(layout->redWidth >= 4);
Q_ASSERT(layout->greenWidth >= 4);
Q_ASSERT(layout->blueWidth >= 4);
Q_ASSERT(layout->alphaWidth == 0);
const uint redMask = ((1 << layout->redWidth) - 1);
const uint greenMask = ((1 << layout->greenWidth) - 1);
const uint blueMask = ((1 << layout->blueWidth) - 1);
const uchar redLeftShift = 8 - layout->redWidth;
const uchar greenLeftShift = 8 - layout->greenWidth;
const uchar blueLeftShift = 8 - layout->blueWidth;
const uchar redRightShift = 2 * layout->redWidth - 8;
const uchar greenRightShift = 2 * layout->greenWidth - 8;
const uchar blueRightShift = 2 * layout->blueWidth - 8;
for (int i = 0; i < count; ++i) {
uint red = (src[i] >> layout->redShift) & redMask;
uint green = (src[i] >> layout->greenShift) & greenMask;
uint blue = (src[i] >> layout->blueShift) & blueMask;
red = (red << redLeftShift) | (red >> redRightShift);
green = (green << greenLeftShift) | (green >> greenRightShift);
blue = (blue << blueLeftShift) | (blue >> blueRightShift);
buffer[i] = 0xff000000 | (red << 16) | (green << 8) | blue;
}
return buffer;
}
static const uint *QT_FASTCALL convertFromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *layout, const QRgb *)
{
Q_ASSERT(layout->redWidth <= 8);
Q_ASSERT(layout->greenWidth <= 8);
Q_ASSERT(layout->blueWidth <= 8);
Q_ASSERT(layout->alphaWidth <= 8);
const uint redMask = (1 << layout->redWidth) - 1;
const uint greenMask = (1 << layout->greenWidth) - 1;
const uint blueMask = (1 << layout->blueWidth) - 1;
const uint alphaMask = (1 << layout->alphaWidth) - 1;
const uchar redRightShift = 24 - layout->redWidth;
const uchar greenRightShift = 16 - layout->greenWidth;
const uchar blueRightShift = 8 - layout->blueWidth;
const uchar alphaRightShift = 32 - layout->alphaWidth;
if (!layout->premultiplied) {
for (int i = 0; i < count; ++i)
buffer[i] = qUnpremultiply(src[i]);
src = buffer;
}
for (int i = 0; i < count; ++i) {
uint red = ((src[i] >> redRightShift) & redMask) << layout->redShift;
uint green = ((src[i] >> greenRightShift) & greenMask) << layout->greenShift;
uint blue = ((src[i] >> blueRightShift) & blueMask) << layout->blueShift;
uint alpha = ((src[i] >> alphaRightShift) & alphaMask) << layout->alphaShift;
buffer[i] = red | green | blue | alpha;
}
return buffer;
}
static const uint *QT_FASTCALL convertFromRGB32(uint *buffer, const uint *src, int count,
const QPixelLayout *layout, const QRgb *)
{
Q_ASSERT(layout->redWidth <= 8);
Q_ASSERT(layout->greenWidth <= 8);
Q_ASSERT(layout->blueWidth <= 8);
const uint redMask = (1 << layout->redWidth) - 1;
const uint greenMask = (1 << layout->greenWidth) - 1;
const uint blueMask = (1 << layout->blueWidth) - 1;
const uint alphaMask = (1 << layout->alphaWidth) - 1;
const uchar redRightShift = 24 - layout->redWidth;
const uchar greenRightShift = 16 - layout->greenWidth;
const uchar blueRightShift = 8 - layout->blueWidth;
for (int i = 0; i < count; ++i) {
uint red = ((src[i] >> redRightShift) & redMask) << layout->redShift;
uint green = ((src[i] >> greenRightShift) & greenMask) << layout->greenShift;
uint blue = ((src[i] >> blueRightShift) & blueMask) << layout->blueShift;
uint alpha = (0xff & alphaMask) << layout->alphaShift;
buffer[i] = red | green | blue | alpha;
}
return buffer;
}
static const uint *QT_FASTCALL convertRGB16ToRGB32(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qConvertRgb16To32(src[i]);
return buffer;
}
static const uint *QT_FASTCALL convertRGB16FromRGB32(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qConvertRgb32To16(src[i]);
return buffer;
}
static const uint *QT_FASTCALL convertRGB16FromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qConvertRgb32To16(qUnpremultiply(src[i]));
return buffer;
}
#endif
// To convert in place, let 'dest' and 'src' be the same.
@ -851,15 +680,42 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
pixelLayoutRGB<QImage::Format_RGB444>(),
pixelLayoutARGBPM<QImage::Format_ARGB4444_Premultiplied>(),
#else
{ 5, 11, 6, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16, convertRGB16ToRGB32, convertRGB16FromARGB32PM, convertRGB16FromRGB32 }, // Format_RGB16
{ 5, 19, 6, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, convertToARGB32PM, convertFromARGB32PM, convertFromRGB32 }, // Format_ARGB8565_Premultiplied
{ 6, 12, 6, 6, 6, 0, 0, 0, false, QPixelLayout::BPP24, convertToRGB32, convertFromARGB32PM, convertFromRGB32 }, // Format_RGB666
{ 6, 12, 6, 6, 6, 0, 6, 18, true, QPixelLayout::BPP24, convertToARGB32PM, convertFromARGB32PM, convertFromRGB32 }, // Format_ARGB6666_Premultiplied
{ 5, 10, 5, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, convertFromARGB32PM, convertFromRGB32 }, // Format_RGB555
{ 5, 18, 5, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, convertToARGB32PM, convertFromARGB32PM, convertFromRGB32 }, // Format_ARGB8555_Premultiplied
{ 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP24, convertToRGB32, convertFromARGB32PM, convertFromRGB32 }, // Format_RGB888
{ 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, convertFromARGB32PM, convertFromRGB32 }, // Format_RGB444
{ 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertToARGB32PM, convertFromARGB32PM, convertFromRGB32 }, // Format_ARGB4444_Premultiplied
{ 5, 11, 6, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16,
convertToRGB32<QImage::Format_RGB16>,
convertRGBFromARGB32PM<QImage::Format_RGB16>,
convertRGBFromRGB32<QImage::Format_RGB16>},
{ 5, 19, 6, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24,
convertARGBPMToARGB32PM<QImage::Format_ARGB8565_Premultiplied>,
convertARGBPMFromARGB32PM<QImage::Format_ARGB8565_Premultiplied>,
convertARGBPMFromRGB32<QImage::Format_ARGB8565_Premultiplied>},
{ 6, 12, 6, 6, 6, 0, 0, 0, false, QPixelLayout::BPP24,
convertToRGB32<QImage::Format_RGB666>,
convertRGBFromARGB32PM<QImage::Format_RGB666>,
convertRGBFromRGB32<QImage::Format_RGB666>},
{ 6, 12, 6, 6, 6, 0, 6, 18, true, QPixelLayout::BPP24,
convertARGBPMToARGB32PM<QImage::Format_ARGB6666_Premultiplied>,
convertARGBPMFromARGB32PM<QImage::Format_ARGB6666_Premultiplied>,
convertARGBPMFromRGB32<QImage::Format_ARGB6666_Premultiplied>},
{ 5, 10, 5, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16,
convertToRGB32<QImage::Format_RGB555>,
convertRGBFromARGB32PM<QImage::Format_RGB555>,
convertRGBFromRGB32<QImage::Format_RGB555> },
{ 5, 18, 5, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24,
convertARGBPMToARGB32PM<QImage::Format_ARGB8555_Premultiplied>,
convertARGBPMFromARGB32PM<QImage::Format_ARGB8555_Premultiplied>,
convertARGBPMFromRGB32<QImage::Format_ARGB8555_Premultiplied>},
{ 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP24,
convertToRGB32<QImage::Format_RGB888>,
convertRGBFromARGB32PM<QImage::Format_RGB888>,
convertRGBFromRGB32<QImage::Format_RGB888>},
{ 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16,
convertToRGB32<QImage::Format_RGB444>,
convertRGBFromARGB32PM<QImage::Format_RGB444>,
convertRGBFromRGB32<QImage::Format_RGB444>},
{ 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16,
convertARGBPMToARGB32PM<QImage::Format_ARGB4444_Premultiplied>,
convertARGBPMFromARGB32PM<QImage::Format_ARGB4444_Premultiplied>,
convertARGBPMFromRGB32<QImage::Format_ARGB4444_Premultiplied>},
#endif
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
{ 8, 24, 8, 16, 8, 8, 0, 0, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBXFromARGB32PM, convertRGBXFromRGB32 }, // Format_RGBX8888

View File

@ -63,7 +63,6 @@ class QTextCursor;
template<typename T> class QVector;
#ifndef Q_QDOC // Workaround for QTBUG-35230
namespace Qt
{
Q_GUI_EXPORT bool mightBeRichText(const QString&);
@ -73,7 +72,6 @@ namespace Qt
Q_GUI_EXPORT QTextCodec *codecForHtml(const QByteArray &ba);
#endif
}
#endif // Q_QDOC
class Q_GUI_EXPORT QAbstractUndoItem
{

View File

@ -1078,7 +1078,7 @@ static QByteArray qStringAsUcs2Le(const QString& src)
}
static QString qStringFromUcs2Le(const QByteArray& src)
static QString qStringFromUcs2Le(QByteArray src)
{
Q_ASSERT(src.size() % 2 == 0);
unsigned short *d = (unsigned short*)src.data();

View File

@ -123,28 +123,41 @@ QHostAddressPrivate::QHostAddressPrivate()
void QHostAddressPrivate::setAddress(quint32 a_)
{
a = a_;
//create mapped address
//create mapped address, except for a_ == 0 (any)
memset(&a6, 0, sizeof(a6));
if (a) {
a6[11] = 0xFF;
a6[10] = 0xFF;
} else {
a6[11] = 0;
a6[10] = 0;
}
int i;
for (i=15; a_ != 0; i--) {
a6[i] = a_ & 0xFF;
a_ >>=8;
}
Q_ASSERT(i >= 11);
a6[11] = 0xFF;
a6[10] = 0xFF;
protocol = QAbstractSocket::IPv4Protocol;
isParsed = true;
}
static bool parseMappedAddress(quint32& a, const Q_IPV6ADDR &a6)
/// parses v4-mapped addresses or the AnyIPv6 address and stores in \a a;
/// returns true if the address was one of those
static bool convertToIpv4(quint32& a, const Q_IPV6ADDR &a6)
{
int i;
for (i=0;i<10;i++)
if (a6[i]) return false;
for (;i<12;i++)
if (a6[i] != 0xFF) return false;
a=(a6[12] << 24) | (a6[13] << 16) | (a6[14] << 8) | a6[15];
const uchar *ptr = a6.c;
if (qFromUnaligned<quint64>(ptr) != 0)
return false;
if (qFromBigEndian<quint32>(ptr + 8) == 0) {
// is it AnyIPv6?
a = 0;
return qFromBigEndian<quint32>(ptr + 12) == 0;
}
if (qFromBigEndian<quint32>(ptr + 8) != 0xFFFF)
return false;
a = qFromBigEndian<quint32>(ptr + 12);
return true;
}
@ -153,10 +166,8 @@ void QHostAddressPrivate::setAddress(const quint8 *a_)
for (int i = 0; i < 16; i++)
a6[i] = a_[i];
a = 0;
if (parseMappedAddress(a, a6))
protocol = QAbstractSocket::IPv4Protocol;
else
protocol = QAbstractSocket::IPv6Protocol;
convertToIpv4(a, a6);
protocol = QAbstractSocket::IPv6Protocol;
isParsed = true;
}
@ -164,10 +175,8 @@ void QHostAddressPrivate::setAddress(const Q_IPV6ADDR &a_)
{
a6 = a_;
a = 0;
if (parseMappedAddress(a, a6))
protocol = QAbstractSocket::IPv4Protocol;
else
protocol = QAbstractSocket::IPv6Protocol;
convertToIpv4(a, a6);
protocol = QAbstractSocket::IPv6Protocol;
isParsed = true;
}
@ -197,7 +206,6 @@ bool QHostAddressPrivate::parse()
quint8 maybeIp6[16];
if (parseIp6(a, maybeIp6, &scopeId)) {
setAddress(maybeIp6);
protocol = QAbstractSocket::IPv6Protocol;
return true;
}
}
@ -205,7 +213,6 @@ bool QHostAddressPrivate::parse()
quint32 maybeIp4 = 0;
if (QIPAddressUtils::parseIp4(maybeIp4, a.constBegin(), a.constEnd())) {
setAddress(maybeIp4);
protocol = QAbstractSocket::IPv4Protocol;
return true;
}
@ -626,8 +633,32 @@ void QHostAddress::setAddress(const struct sockaddr *sockaddr)
\sa toString()
*/
quint32 QHostAddress::toIPv4Address() const
{
return toIPv4Address(Q_NULLPTR);
}
/*!
Returns the IPv4 address as a number.
For example, if the address is 127.0.0.1, the returned value is
2130706433 (i.e. 0x7f000001).
This value is valid if the protocol() is
\l{QAbstractSocket::}{IPv4Protocol},
or if the protocol is
\l{QAbstractSocket::}{IPv6Protocol},
and the IPv6 address is an IPv4 mapped address. (RFC4291). In those
cases, \a ok will be set to true. Otherwise, it will be set to false.
\sa toString()
*/
quint32 QHostAddress::toIPv4Address(bool *ok) const
{
QT_ENSURE_PARSED(this);
quint32 dummy;
if (ok)
*ok = d->protocol == QAbstractSocket::IPv4Protocol || d->protocol == QAbstractSocket::AnyIPProtocol
|| (d->protocol == QAbstractSocket::IPv6Protocol && convertToIpv4(dummy, d->a6));
return d->a;
}

View File

@ -93,7 +93,8 @@ public:
bool setAddress(const QString &address);
QAbstractSocket::NetworkLayerProtocol protocol() const;
quint32 toIPv4Address() const;
quint32 toIPv4Address() const; // ### Qt6: merge with next overload
quint32 toIPv4Address(bool *ok) const;
Q_IPV6ADDR toIPv6Address() const;
QString toString() const;

View File

@ -689,6 +689,7 @@ void qt_qhostinfo_clear_cache()
}
}
#ifdef QT_BUILD_INTERNAL
void Q_AUTOTEST_EXPORT qt_qhostinfo_enable_cache(bool e)
{
QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager();
@ -697,6 +698,16 @@ void Q_AUTOTEST_EXPORT qt_qhostinfo_enable_cache(bool e)
}
}
void qt_qhostinfo_cache_inject(const QString &hostname, const QHostInfo &resolution)
{
QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager();
if (!manager || !manager->cache.isEnabled())
return;
manager->cache.put(hostname, resolution);
}
#endif
// cache for 60 seconds
// cache 128 items
QHostInfoCache::QHostInfoCache() : max_age(60), enabled(true), cache(128)

View File

@ -117,6 +117,7 @@ public:
QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id);
void Q_AUTOTEST_EXPORT qt_qhostinfo_clear_cache();
void Q_AUTOTEST_EXPORT qt_qhostinfo_enable_cache(bool e);
void Q_AUTOTEST_EXPORT qt_qhostinfo_cache_inject(const QString &hostname, const QHostInfo &resolution);
class QHostInfoCache
{

View File

@ -976,7 +976,7 @@ void QAbstractSocketPrivate::startConnectingByName(const QString &host)
connectTimeElapsed = 0;
if (initSocketLayer(QAbstractSocket::UnknownNetworkLayerProtocol)) {
if (cachedSocketDescriptor != -1 || initSocketLayer(QAbstractSocket::UnknownNetworkLayerProtocol)) {
if (socketEngine->connectToHostByName(host, port) ||
socketEngine->state() == QAbstractSocket::ConnectingState) {
cachedSocketDescriptor = socketEngine->socketDescriptor();
@ -1117,7 +1117,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress()
host.toString().toLatin1().constData(), port, addresses.count());
#endif
if (!initSocketLayer(host.protocol())) {
if (cachedSocketDescriptor == -1 && !initSocketLayer(host.protocol())) {
// hope that the next address is better
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::_q_connectToNextAddress(), failed to initialize sock layer");
@ -1134,9 +1134,6 @@ void QAbstractSocketPrivate::_q_connectToNextAddress()
return;
}
// cache the socket descriptor even if we're not fully connected yet
cachedSocketDescriptor = socketEngine->socketDescriptor();
// Check that we're in delayed connection state. If not, try
// the next address
if (socketEngine->state() != QAbstractSocket::ConnectingState) {
@ -1481,54 +1478,60 @@ void QAbstractSocket::setPauseMode(PauseModes pauseMode)
bool QAbstractSocket::bind(const QHostAddress &address, quint16 port, BindMode mode)
{
Q_D(QAbstractSocket);
return d->bind(address, port, mode);
}
bool QAbstractSocketPrivate::bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode)
{
Q_Q(QAbstractSocket);
// now check if the socket engine is initialized and to the right type
if (!d->socketEngine || !d->socketEngine->isValid()) {
if (!socketEngine || !socketEngine->isValid()) {
QHostAddress nullAddress;
d->resolveProxy(nullAddress.toString(), port);
resolveProxy(nullAddress.toString(), port);
QAbstractSocket::NetworkLayerProtocol protocol = address.protocol();
if (protocol == QAbstractSocket::UnknownNetworkLayerProtocol)
protocol = nullAddress.protocol();
if (!d->initSocketLayer(protocol))
if (!initSocketLayer(protocol))
return false;
}
if (mode != DefaultForPlatform) {
if (mode != QAbstractSocket::DefaultForPlatform) {
#ifdef Q_OS_UNIX
if ((mode & ShareAddress) || (mode & ReuseAddressHint))
d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
if ((mode & QAbstractSocket::ShareAddress) || (mode & QAbstractSocket::ReuseAddressHint))
socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
else
d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
#endif
#ifdef Q_OS_WIN
if (mode & ReuseAddressHint)
d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
if (mode & QAbstractSocket::ReuseAddressHint)
socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
else
d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
if (mode & DontShareAddress)
d->socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 1);
socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
if (mode & QAbstractSocket::DontShareAddress)
socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 1);
else
d->socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 0);
socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 0);
#endif
}
bool result = d->socketEngine->bind(address, port);
d->cachedSocketDescriptor = d->socketEngine->socketDescriptor();
bool result = socketEngine->bind(address, port);
cachedSocketDescriptor = socketEngine->socketDescriptor();
if (!result) {
d->socketError = d->socketEngine->error();
setErrorString(d->socketEngine->errorString());
emit error(d->socketError);
socketError = socketEngine->error();
q->setErrorString(socketEngine->errorString());
emit q->error(socketError);
return false;
}
d->state = BoundState;
d->localAddress = d->socketEngine->localAddress();
d->localPort = d->socketEngine->localPort();
state = QAbstractSocket::BoundState;
localAddress = socketEngine->localAddress();
localPort = socketEngine->localPort();
emit stateChanged(d->state);
d->socketEngine->setReadNotificationEnabled(true);
emit q->stateChanged(state);
socketEngine->setReadNotificationEnabled(true);
return true;
}
@ -1605,14 +1608,16 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
d->preferredNetworkLayerProtocol = protocol;
d->hostName = hostName;
d->port = port;
d->state = UnconnectedState;
d->buffer.clear();
d->writeBuffer.clear();
d->abortCalled = false;
d->pendingClose = false;
d->localPort = 0;
if (d->state != BoundState) {
d->state = UnconnectedState;
d->localPort = 0;
d->localAddress.clear();
}
d->peerPort = 0;
d->localAddress.clear();
d->peerAddress.clear();
d->peerName = hostName;
if (d->hostLookupId != -1) {

View File

@ -135,9 +135,11 @@ public:
PauseModes pauseMode() const;
void setPauseMode(PauseModes pauseMode);
// ### Qt6: make the first one virtual
bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform);
bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform);
// ### Qt6: de-virtualize connectToHost(QHostAddress) overload
virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
virtual void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
virtual void disconnectFromHost();

View File

@ -78,6 +78,8 @@ public:
}
#endif
virtual bool bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode);
bool canReadNotification();
bool canWriteNotification();
void canCloseNotification();

View File

@ -136,6 +136,12 @@ QT_BEGIN_NAMESPACE
" not in "#state1" or "#state2); \
return (returnValue); \
} } while (0)
#define Q_CHECK_STATES3(function, state1, state2, state3, returnValue) do { \
if (d->socketState != (state1) && d->socketState != (state2) && d->socketState != (state3)) { \
qWarning(""#function" was called" \
" not in "#state1" or "#state2); \
return (returnValue); \
} } while (0)
#define Q_CHECK_TYPE(function, type, returnValue) do { \
if (d->socketType != (type)) { \
qWarning(#function" was called by a" \
@ -275,6 +281,38 @@ void QNativeSocketEnginePrivate::setError(QAbstractSocket::SocketError error, Er
}
}
/*!
\internal
Adjusts the incoming \a address family to match the currently bound address
(if any). This function will convert v4-mapped IPv6 addresses to IPv4 and
vice-versa. All other address types and values will be left unchanged.
*/
QHostAddress QNativeSocketEnginePrivate::adjustAddressProtocol(const QHostAddress &address) const
{
QAbstractSocket::NetworkLayerProtocol targetProtocol = socketProtocol;
if (Q_LIKELY(targetProtocol == QAbstractSocket::UnknownNetworkLayerProtocol))
return address;
QAbstractSocket::NetworkLayerProtocol sourceProtocol = address.protocol();
if (targetProtocol == QAbstractSocket::AnyIPProtocol)
targetProtocol = QAbstractSocket::IPv6Protocol;
if (targetProtocol == QAbstractSocket::IPv6Protocol && sourceProtocol == QAbstractSocket::IPv4Protocol) {
// convert to IPv6 v4-mapped address. This always works
return QHostAddress(address.toIPv6Address());
}
if (targetProtocol == QAbstractSocket::IPv4Protocol && sourceProtocol == QAbstractSocket::IPv6Protocol) {
// convert to IPv4 if the source is a v4-mapped address
quint32 ip4 = address.toIPv4Address();
if (ip4)
return QHostAddress(ip4);
}
return address;
}
bool QNativeSocketEnginePrivate::checkProxy(const QHostAddress &address)
{
if (address.isLoopback())
@ -495,12 +533,12 @@ bool QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 por
if (!d->checkProxy(address))
return false;
Q_CHECK_STATES(QNativeSocketEngine::connectToHost(),
Q_CHECK_STATES3(QNativeSocketEngine::connectToHost(), QAbstractSocket::BoundState,
QAbstractSocket::UnconnectedState, QAbstractSocket::ConnectingState, false);
d->peerAddress = address;
d->peerPort = port;
bool connected = d->nativeConnect(address, port);
bool connected = d->nativeConnect(d->adjustAddressProtocol(address), port);
if (connected)
d->fetchConnectionParameters();
@ -560,7 +598,7 @@ bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port)
Q_CHECK_STATE(QNativeSocketEngine::bind(), QAbstractSocket::UnconnectedState, false);
if (!d->nativeBind(address, port))
if (!d->nativeBind(d->adjustAddressProtocol(address), port))
return false;
d->fetchConnectionParameters();
@ -770,7 +808,7 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 size,
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::writeDatagram(), -1);
Q_CHECK_TYPE(QNativeSocketEngine::writeDatagram(), QAbstractSocket::UdpSocket, -1);
return d->nativeSendDatagram(data, size, host, port);
return d->nativeSendDatagram(data, size, d->adjustAddressProtocol(host), port);
}
/*!
@ -961,7 +999,7 @@ bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut)
QNativeSocketEnginePrivate::TimeOutErrorString);
d->hasSetSocketError = false; // A timeout error is temporary in waitFor functions
return false;
} else if (state() == QAbstractSocket::ConnectingState) {
} else if (state() == QAbstractSocket::ConnectingState || (state() == QAbstractSocket::BoundState && d->socketDescriptor != -1)) {
connectToHost(d->peerAddress, d->peerPort);
}

View File

@ -232,6 +232,7 @@ public:
};
void setError(QAbstractSocket::SocketError error, ErrorString errorString) const;
QHostAddress adjustAddressProtocol(const QHostAddress &address) const;
// native functions
int option(QNativeSocketEngine::SocketOption option) const;

View File

@ -60,7 +60,7 @@ static DH *get_dh1024()
"/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC"));
const char *ptr = params.constData();
DH *dh = q_d2i_DHparams(NULL, (unsigned char **)(&ptr), params.length());
DH *dh = q_d2i_DHparams(NULL, reinterpret_cast<const unsigned char **>(&ptr), params.length());
return dh;
}

View File

@ -2404,6 +2404,29 @@ bool QSslSocketPrivate::isPaused() const
return paused;
}
bool QSslSocketPrivate::bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode)
{
// this function is called from QAbstractSocket::bind
if (!initialized)
init();
initialized = false;
#ifdef QSSLSOCKET_DEBUG
qCDebug(lcSsl) << "QSslSocket::bind(" << address << ',' << port << ',' << mode << ')';
#endif
if (!plainSocket) {
#ifdef QSSLSOCKET_DEBUG
qCDebug(lcSsl) << "\tcreating internal plain socket";
#endif
createPlainSocket(QIODevice::ReadWrite);
}
bool ret = plainSocket->bind(address, port, mode);
localPort = plainSocket->localPort();
localAddress = plainSocket->localAddress();
cachedSocketDescriptor = plainSocket->socketDescriptor();
return ret;
}
/*!
\internal
*/

View File

@ -399,7 +399,7 @@ DEFINEFUNC3(void, SSL_get0_next_proto_negotiated, const SSL *s, s,
#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...
DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, unsigned char **pp, pp, long length, length, return 0, return);
DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return 0, return)
DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return 0, return)
#ifndef OPENSSL_NO_EC
DEFINEFUNC(EC_KEY *, EC_KEY_dup, const EC_KEY *ec, ec, return 0, return)

View File

@ -440,7 +440,7 @@ STACK_OF(X509) *q_X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
// Diffie-Hellman support
DH *q_DH_new();
void q_DH_free(DH *dh);
DH *q_d2i_DHparams(DH **a, unsigned char **pp, long length);
DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
#define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)

View File

@ -172,6 +172,7 @@ public:
static void checkSettingSslContext(QSslSocket*, QSharedPointer<QSslContext>);
static QSharedPointer<QSslContext> sslContext(QSslSocket *socket);
bool isPaused() const;
bool bind(const QHostAddress &address, quint16, QAbstractSocket::BindMode) Q_DECL_OVERRIDE;
void _q_connectedSlot();
void _q_hostFoundSlot();
void _q_disconnectedSlot();

View File

@ -62,7 +62,7 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen)
m_textureCoordEntry(0),
m_textureEntry(0),
m_deviceListener(0),
m_updater(screen)
m_updateRequested(false)
{
QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
if (!hideCursorVal.isEmpty())
@ -246,30 +246,43 @@ bool QEGLPlatformCursor::setCurrentCursor(QCursor *cursor)
}
#endif
void QEGLPlatformCursorUpdater::update(const QPoint &pos, const QRegion &rgn)
class CursorUpdateEvent : public QEvent
{
m_active = false;
QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(pos), rgn);
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
}
public:
CursorUpdateEvent(const QPoint &pos, const QRegion &rgn)
: QEvent(QEvent::Type(QEvent::User + 1)),
m_pos(pos),
m_region(rgn)
{ }
QPoint pos() const { return m_pos; }
QRegion region() const { return m_region; }
void QEGLPlatformCursorUpdater::scheduleUpdate(const QPoint &pos, const QRegion &rgn)
private:
QPoint m_pos;
QRegion m_region;
};
bool QEGLPlatformCursor::event(QEvent *e)
{
if (m_active)
return;
m_active = true;
// Must not flush the window system events directly from here since we are likely to
// be a called directly from QGuiApplication's processMouseEvents. Flushing events
// could cause reentering by dispatching more queued mouse events.
QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection,
Q_ARG(QPoint, pos), Q_ARG(QRegion, rgn));
if (e->type() == QEvent::User + 1) {
CursorUpdateEvent *ev = static_cast<CursorUpdateEvent *>(e);
m_updateRequested = false;
QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(ev->pos()), ev->region());
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
return true;
}
return QPlatformCursor::event(e);
}
void QEGLPlatformCursor::update(const QRegion &rgn)
{
m_updater.scheduleUpdate(m_cursor.pos, rgn);
if (!m_updateRequested) {
// Must not flush the window system events directly from here since we are likely to
// be a called directly from QGuiApplication's processMouseEvents. Flushing events
// could cause reentering by dispatching more queued mouse events.
m_updateRequested = true;
QCoreApplication::postEvent(this, new CursorUpdateEvent(m_cursor.pos, rgn));
}
}
QRect QEGLPlatformCursor::cursorRect() const

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