summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-08-27 22:51:09 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-08-27 22:51:09 +0200
commit190fa97c83472863fd886e86f626ab8196ed51b3 (patch)
tree49edb9f6a41d6c999c9bb43ae28911a8e7212757 /src
parent3aa163491c9c8f28c88ac87cafc6418f2c0e46c5 (diff)
parent5971e0918757737425151c39a5f81a238663a17a (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: examples/widgets/doc/src/addressbook-fr.qdoc Change-Id: Id1196e8e0c6445f1616c3f29234c974d809f8e48
Diffstat (limited to 'src')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in5
-rw-r--r--src/corelib/Qt5CoreMacros.cmake80
-rw-r--r--src/corelib/doc/qtcore.qdocconf3
-rw-r--r--src/corelib/doc/src/datastreamformat.qdoc2
-rw-r--r--src/corelib/doc/src/json.qdoc2
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc2
-rw-r--r--src/corelib/global/qglobal.cpp7
-rw-r--r--src/corelib/global/qglobal.h4
-rw-r--r--src/corelib/json/qjsonarray.cpp2
-rw-r--r--src/corelib/json/qjsondocument.cpp2
-rw-r--r--src/corelib/json/qjsonobject.cpp6
-rw-r--r--src/corelib/json/qjsonparser.cpp2
-rw-r--r--src/corelib/json/qjsonvalue.cpp2
-rw-r--r--src/corelib/tools/qbytearray.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp2
-rw-r--r--src/gui/kernel/qwindow.cpp5
-rw-r--r--src/gui/opengl/qopenglfunctions_es2.h2
-rw-r--r--src/gui/painting/qbackingstore.cpp5
-rw-r--r--src/gui/text/qcssparser.cpp4
-rw-r--r--src/gui/text/qdistancefield.cpp270
-rw-r--r--src/gui/text/qdistancefield_p.h65
-rw-r--r--src/gui/text/qfontdatabase.cpp24
-rw-r--r--src/network/kernel/qnetworkinterface_unix.cpp58
-rw-r--r--src/platformsupport/jniconvenience/qjnihelpers_p.h18
-rw-r--r--src/platformsupport/jniconvenience/qjniobject.cpp276
-rw-r--r--src/platformsupport/jniconvenience/qjniobject_p.h39
-rw-r--r--src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm7
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm4
-rw-r--r--src/plugins/platforms/qnx/qqnxbpseventfilter.cpp5
-rw-r--r--src/plugins/platforms/qnx/qqnxrootwindow.cpp31
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp16
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp68
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h3
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp39
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp3
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.cpp2
-rw-r--r--src/tools/moc/generator.cpp20
-rw-r--r--src/tools/moc/preprocessor.cpp4
-rw-r--r--src/tools/qdoc/doc/qdoc-minimum-qdocconf.qdoc86
-rw-r--r--src/tools/qdoc/doc/qtgui-qdocconf.qdoc18
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp2
-rw-r--r--src/widgets/styles/qcommonstyle.cpp1
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp46
48 files changed, 895 insertions, 367 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 36a54787b3..2d87783107 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -131,6 +131,11 @@ if (NOT TARGET Qt5::WinMain)
get_target_property(_configs Qt5::Core IMPORTED_CONFIGURATIONS)
foreach(_config ${_configs})
set_property(TARGET Qt5::Core APPEND PROPERTY
+ INTERFACE_LINK_LIBRARIES
+ $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt5::WinMain>
+ )
+ # For backward compatibility with CMake < 2.8.12
+ set_property(TARGET Qt5::Core APPEND PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES_${_config}
$<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt5::WinMain>
)
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 6630885257..dca257f080 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -94,34 +94,45 @@ endmacro()
# helper macro to set up a moc rule
-macro(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
- # For Windows, create a parameters file to work around command line length limit
- if(WIN32)
- # Pass the parameters in a file. Set the working directory to
- # be that containing the parameters file and reference it by
- # just the file name. This is necessary because the moc tool on
- # MinGW builds does not seem to handle spaces in the path to the
- # file given with the @ syntax.
- get_filename_component(_moc_outfile_name "${outfile}" NAME)
- get_filename_component(_moc_outfile_dir "${outfile}" PATH)
- if(_moc_outfile_dir)
- set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
- endif()
- set(_moc_parameters_file ${outfile}_parameters)
- set(_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
- string(REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
- file(WRITE ${_moc_parameters_file} "${_moc_parameters}")
- add_custom_command(OUTPUT ${outfile}
- COMMAND ${Qt5Core_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
- DEPENDS ${infile}
- ${_moc_working_dir}
- VERBATIM)
+macro(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
+ # Pass the parameters in a file. Set the working directory to
+ # be that containing the parameters file and reference it by
+ # just the file name. This is necessary because the moc tool on
+ # MinGW builds does not seem to handle spaces in the path to the
+ # file given with the @ syntax.
+ get_filename_component(_moc_outfile_name "${outfile}" NAME)
+ get_filename_component(_moc_outfile_dir "${outfile}" PATH)
+ if(_moc_outfile_dir)
+ set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
+ endif()
+ set (_moc_parameters_file ${outfile}_parameters)
+ set (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
+ string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
+
+ if(moc_target)
+ set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
+ set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>")
+
+ set(targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:${targetincludes},\n-I>\n>")
+ set(targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:${targetdefines},\n-D>\n>")
+
+ file (GENERATE
+ OUTPUT ${_moc_parameters_file}
+ CONTENT "${targetdefines}${targetincludes}${_moc_parameters}\n"
+ )
+
+ set(targetincludes)
+ set(targetdefines)
else()
- add_custom_command(OUTPUT ${outfile}
- COMMAND ${Qt5Core_MOC_EXECUTABLE}
- ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
- DEPENDS ${infile} VERBATIM)
+ file(WRITE ${_moc_parameters_file} "${_moc_parameters}\n")
endif()
+
+ set(_moc_extra_parameters_file @${_moc_parameters_file})
+ add_custom_command(OUTPUT ${outfile}
+ COMMAND ${Qt5Core_MOC_EXECUTABLE} ${_moc_extra_parameters_file}
+ DEPENDS ${infile}
+ ${_moc_working_dir}
+ VERBATIM)
endmacro()
@@ -133,7 +144,13 @@ function(QT5_GENERATE_MOC infile outfile )
if(NOT IS_ABSOLUTE "${outfile}")
set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
endif()
- qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "")
+ if ("x${ARGV2}" STREQUAL "xTARGET")
+ if (CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "The TARGET parameter to qt5_generate_moc is only available when using CMake 2.8.12 or later.")
+ endif()
+ set(moc_target ${ARGV3})
+ endif()
+ qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}")
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
endfunction()
@@ -145,17 +162,22 @@ function(QT5_WRAP_CPP outfiles )
qt5_get_moc_flags(moc_flags)
set(options)
- set(oneValueArgs)
+ set(oneValueArgs TARGET)
set(multiValueArgs OPTIONS)
cmake_parse_arguments(_WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(moc_files ${_WRAP_CPP_UNPARSED_ARGUMENTS})
set(moc_options ${_WRAP_CPP_OPTIONS})
+ set(moc_target ${_WRAP_CPP_TARGET})
+
+ if (moc_target AND CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "The TARGET parameter to qt5_wrap_cpp is only available when using CMake 2.8.12 or later.")
+ endif()
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
qt5_make_output_file(${it} moc_ cpp outfile)
- qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}")
+ qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}")
list(APPEND ${outfiles} ${outfile})
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 7a3e20aa89..fdd46995c5 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -36,7 +36,8 @@ exampledirs += \
../ \
snippets \
../../../examples/threads/ \
- ../../../examples/tools/
+ ../../../examples/tools/ \
+ ../../../examples/json/
imagedirs += images
diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc
index 99a0a077cd..b6efe6aa33 100644
--- a/src/corelib/doc/src/datastreamformat.qdoc
+++ b/src/corelib/doc/src/datastreamformat.qdoc
@@ -369,4 +369,6 @@
\li The items (T)
\endlist
\endtable
+
+ \sa {JSON Support in Qt}
*/
diff --git a/src/corelib/doc/src/json.qdoc b/src/corelib/doc/src/json.qdoc
index 89e1bcac34..5bffe98ae5 100644
--- a/src/corelib/doc/src/json.qdoc
+++ b/src/corelib/doc/src/json.qdoc
@@ -99,6 +99,8 @@
A valid JSON document is either an array or an object, so a document always starts
with a square or curly bracket.
+ \sa {JSON Save Game Example}
+
\section1 The JSON Classes
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
index d1690c5908..70f0b88e06 100644
--- a/src/corelib/doc/src/objectmodel/properties.qdoc
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -67,7 +67,7 @@
\li A \c READ accessor function is required if no \c MEMBER variable was
specified. It is for reading the property value. Ideally, a const function
is used for this purpose, and it must return either the property's type or a
- pointer or reference to that type. e.g., QWidget::focus is a read-only
+ const reference to that type. e.g., QWidget::focus is a read-only
property with \c READ function, QWidget::hasFocus().
\li A \c WRITE accessor function is optional. It is for setting the
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 4ee4235278..9656f4b68a 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1168,6 +1168,13 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
+ \macro Q_OS_ANDROID
+ \relates <QtGlobal>
+
+ Defined on Android.
+*/
+
+/*!
\macro Q_OS_FREEBSD
\relates <QtGlobal>
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 41f21bb0dd..e72ea792dd 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -206,11 +206,7 @@ typedef quint64 qulonglong;
QT_BEGIN_INCLUDE_NAMESPACE
typedef unsigned char uchar;
typedef unsigned short ushort;
-#if defined(Q_QDOC) || !defined(Q_OS_ANDROID)
typedef unsigned int uint;
-#else
-# include <sys/types.h>
-#endif
typedef unsigned long ulong;
QT_END_INCLUDE_NAMESPACE
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index fb8d2e83ff..8dd7f6092f 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -71,6 +71,8 @@ QT_BEGIN_NAMESPACE
it has been created from as long as it is not being modified.
You can convert the array to and from text based JSON through QJsonDocument.
+
+ \sa {JSON Support in Qt}, {JSON Save Game Example}
*/
/*!
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index bdb46528d3..05d57e2ab9 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -76,6 +76,8 @@ QT_BEGIN_NAMESPACE
A document can also be created from a stored binary representation using fromBinaryData() or
fromRawData().
+
+ \sa {JSON Support in Qt}, {JSON Save Game Example}
*/
/*!
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index 43336de2e7..362d01384e 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -70,6 +70,8 @@ QT_BEGIN_NAMESPACE
it has been created from as long as it is not being modified.
You can convert the object to and from text based JSON through QJsonDocument.
+
+ \sa {JSON Support in Qt}, {JSON Save Game Example}
*/
/*!
@@ -604,7 +606,7 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
Multiple iterators can be used on the same object. Existing iterators will however
become dangling once the object gets modified.
- \sa QJsonObject::const_iterator
+ \sa QJsonObject::const_iterator, {JSON Support in Qt}, {JSON Save Game Example}
*/
/*! \typedef QJsonObject::iterator::difference_type
@@ -799,7 +801,7 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
Multiple iterators can be used on the same object. Existing iterators
will however become dangling if the object gets modified.
- \sa QJsonObject::iterator
+ \sa QJsonObject::iterator, {JSON Support in Qt}, {JSON Save Game Example}
*/
/*! \typedef QJsonObject::const_iterator::difference_type
diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp
index b151af7955..8721f06064 100644
--- a/src/corelib/json/qjsonparser.cpp
+++ b/src/corelib/json/qjsonparser.cpp
@@ -86,6 +86,8 @@ QT_BEGIN_NAMESPACE
\since 5.0
\brief The QJsonParseError class is used to report errors during JSON parsing.
+
+ \sa {JSON Support in Qt}, {JSON Save Game Example}
*/
/*!
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index ef9f057d77..d0634602f3 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -81,6 +81,8 @@ QT_BEGIN_NAMESPACE
Values are strictly typed internally and contrary to QVariant will not attempt to do any implicit type
conversions. This implies that converting to a type that is not stored in the value will return a default
constructed return value.
+
+ \sa {JSON Support in Qt}, {JSON Save Game Example}
*/
/*!
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index a2d3891f00..20d4339a19 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -646,6 +646,8 @@ static inline char qToLower(char c)
store raw binary data, and when memory conservation is critical
(e.g., with Qt for Embedded Linux).
+ The maximum array size of a QByteArray is under 2^30.
+
One way to initialize a QByteArray is simply to pass a \c{const
char *} to its constructor. For example, the following code
creates a byte array of size 5 containing the data "Hello":
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 6be3b066d8..eed1c41bfa 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1664,7 +1664,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
) {
return;
}
- if (window->d_func()->blockedByModalWindow) {
+ if (window && window->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow key events through
return;
}
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 9ef19715ed..490cf0c110 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -348,8 +348,9 @@ void QWindowPrivate::updateVisibility()
void QWindowPrivate::setScreen(QScreen *newScreen, bool recreate)
{
Q_Q(QWindow);
- if (newScreen != q->screen()) {
- const bool shouldRecreate = recreate && platformWindow != 0;
+ if (newScreen != screen) {
+ const bool shouldRecreate = recreate && platformWindow != 0
+ && !(screen && screen->virtualSiblings().contains(newScreen));
if (shouldRecreate)
q->destroy();
if (screen)
diff --git a/src/gui/opengl/qopenglfunctions_es2.h b/src/gui/opengl/qopenglfunctions_es2.h
index 9c14567723..21ed6bec93 100644
--- a/src/gui/opengl/qopenglfunctions_es2.h
+++ b/src/gui/opengl/qopenglfunctions_es2.h
@@ -44,7 +44,7 @@
#include <QtCore/qglobal.h>
-#if defined(QT_OPENGL_ES_2)
+#if defined(QT_OPENGL_ES_2) || defined(Q_QDOC)
#include <QtGui/QOpenGLVersionFunctions>
#include <QtGui/qopenglcontext.h>
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index edb5f66c5b..c1f7c6c738 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -97,6 +97,11 @@ void QBackingStore::flush(const QRegion &region, QWindow *win, const QPoint &off
{
if (!win)
win = window();
+ if (!win->handle()) {
+ qWarning() << "QBackingStore::flush() called for "
+ << win << " which does not have a handle.";
+ return;
+ }
#ifdef QBACKINGSTORE_DEBUG
if (win && win->isTopLevel() && !qt_window_private(win)->receivedExpose) {
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 1264330873..b486ec05fa 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -583,7 +583,11 @@ bool ValueExtractor::extractBorder(int *borders, QBrush *colors, BorderStyle *st
case BorderRightStyle: styles[RightEdge] = decl.styleValue(); break;
case BorderStyles: decl.styleValues(styles); break;
+#ifndef QT_OS_ANDROID_GCC_48_WORKAROUND
case BorderTopLeftRadius: radii[0] = sizeValue(decl); break;
+#else
+ case BorderTopLeftRadius: new(radii)QSize(sizeValue(decl)); break;
+#endif
case BorderTopRightRadius: radii[1] = sizeValue(decl); break;
case BorderBottomLeftRadius: radii[2] = sizeValue(decl); break;
case BorderBottomRightRadius: radii[3] = sizeValue(decl); break;
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index f4274a2c19..e584b66a25 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -487,15 +487,19 @@ static void drawPolygons(qint32 *bits, int width, int height, const QPoint *vert
}
}
-static QImage makeDistanceField(int imgWidth, int imgHeight, const QPainterPath &path, int dfScale, int offs)
+static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path, int dfScale, int offs)
{
- QImage image(imgWidth, imgHeight, QImage::Format_Indexed8);
+ if (!data || !data->data)
+ return;
if (path.isEmpty()) {
- image.fill(0);
- return image;
+ memset(data->data, 0, data->nbytes);
+ return;
}
+ int imgWidth = data->width;
+ int imgHeight = data->height;
+
QTransform transform;
transform.translate(offs, offs);
transform.scale(qreal(1) / dfScale, qreal(1) / dfScale);
@@ -521,8 +525,8 @@ static QImage makeDistanceField(int imgWidth, int imgHeight, const QPainterPath
QVarLengthArray<bool> isConvex;
QVarLengthArray<bool> needsClipping;
- drawPolygons(bits.data(), imgWidth, imgHeight, pathVertices.data(), indices, pathIndices.size(),
- interiorColor);
+ drawPolygons(bits.data(), imgWidth, imgHeight, pathVertices.data(),
+ indices, pathIndices.size(), interiorColor);
int index = 0;
@@ -681,15 +685,11 @@ static QImage makeDistanceField(int imgWidth, int imgHeight, const QPainterPath
}
const qint32 *inLine = bits.data();
- uchar *outLine = image.bits();
- int padding = image.bytesPerLine() - image.width();
+ uchar *outLine = data->data;
for (int y = 0; y < imgHeight; ++y) {
for (int x = 0; x < imgWidth; ++x, ++inLine, ++outLine)
*outLine = uchar((0x7f80 - *inLine) >> 8);
- outLine += padding;
}
-
- return image;
}
static bool imageHasNarrowOutlines(const QImage &im)
@@ -769,31 +769,96 @@ bool qt_fontHasNarrowOutlines(const QRawFont &f)
QRawFont::PixelAntialiasing));
}
-static QImage renderDistanceFieldPath(const QPainterPath &path, bool doubleResolution)
+
+QDistanceFieldData::QDistanceFieldData(const QDistanceFieldData &other)
+ : QSharedData(other)
+ , glyph(other.glyph)
+ , width(other.width)
+ , height(other.height)
+ , nbytes(other.nbytes)
+{
+ if (nbytes && other.data)
+ data = (uchar *)memcpy(malloc(nbytes), other.data, nbytes);
+ else
+ data = 0;
+}
+
+QDistanceFieldData::~QDistanceFieldData()
+{
+ free(data);
+}
+
+QDistanceFieldData *QDistanceFieldData::create(const QSize &size)
+{
+ QDistanceFieldData *data = new QDistanceFieldData;
+
+ if (size.isValid()) {
+ data->width = size.width();
+ data->height = size.height();
+ // pixel data stored as a 1-byte alpha value
+ data->nbytes = data->width * data->height; // tightly packed
+ data->data = (uchar *)malloc(data->nbytes);
+ }
+
+ return data;
+}
+
+QDistanceFieldData *QDistanceFieldData::create(const QPainterPath &path, bool doubleResolution)
{
int dfMargin = QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution);
int glyphWidth = qCeil(path.boundingRect().width() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2;
- QImage im = makeDistanceField(glyphWidth,
- QT_DISTANCEFIELD_TILESIZE(doubleResolution),
- path,
- QT_DISTANCEFIELD_SCALE(doubleResolution),
- QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution));
- return im;
+ QDistanceFieldData *data = create(QSize(glyphWidth, QT_DISTANCEFIELD_TILESIZE(doubleResolution)));
+
+ makeDistanceField(data,
+ path,
+ QT_DISTANCEFIELD_SCALE(doubleResolution),
+ QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution));
+ return data;
}
-QImage qt_renderDistanceFieldGlyph(QFontEngine *fe, glyph_t glyph, bool doubleResolution)
+
+QDistanceField::QDistanceField()
+ : d(new QDistanceFieldData)
{
- QFixedPoint position;
- QPainterPath path;
- fe->addGlyphsToPath(&glyph, &position, 1, &path, 0);
- path.translate(-path.boundingRect().topLeft());
- path.setFillRule(Qt::WindingFill);
+}
- return renderDistanceFieldPath(path, doubleResolution);
+QDistanceField::QDistanceField(int width, int height)
+ : d(QDistanceFieldData::create(QSize(width, height)))
+{
}
-QImage qt_renderDistanceFieldGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution)
+QDistanceField::QDistanceField(const QDistanceField &other)
+{
+ d = other.d;
+}
+
+QDistanceField::QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution)
+{
+ setGlyph(font, glyph, doubleResolution);
+}
+
+QDistanceField::QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution)
+{
+ setGlyph(fontEngine, glyph, doubleResolution);
+}
+
+QDistanceField::QDistanceField(QDistanceFieldData *data)
+ : d(data)
+{
+}
+
+bool QDistanceField::isNull() const
+{
+ return !d->data;
+}
+
+glyph_t QDistanceField::glyph() const
+{
+ return d->glyph;
+}
+
+void QDistanceField::setGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution)
{
QRawFont renderFont = font;
renderFont.setPixelSize(QT_DISTANCEFIELD_BASEFONTSIZE(doubleResolution) * QT_DISTANCEFIELD_SCALE(doubleResolution));
@@ -802,7 +867,158 @@ QImage qt_renderDistanceFieldGlyph(const QRawFont &font, glyph_t glyph, bool dou
path.translate(-path.boundingRect().topLeft());
path.setFillRule(Qt::WindingFill);
- return renderDistanceFieldPath(path, doubleResolution);
+ d = QDistanceFieldData::create(path, doubleResolution);
+ d->glyph = glyph;
+}
+
+void QDistanceField::setGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution)
+{
+ QFixedPoint position;
+ QPainterPath path;
+ fontEngine->addGlyphsToPath(&glyph, &position, 1, &path, 0);
+ path.translate(-path.boundingRect().topLeft());
+ path.setFillRule(Qt::WindingFill);
+
+ d = QDistanceFieldData::create(path, doubleResolution);
+ d->glyph = glyph;
+}
+
+int QDistanceField::width() const
+{
+ return d->width;
+}
+
+int QDistanceField::height() const
+{
+ return d->height;
+}
+
+QDistanceField QDistanceField::copy(const QRect &r) const
+{
+ if (isNull())
+ return QDistanceField();
+
+ if (r.isNull())
+ return QDistanceField(new QDistanceFieldData(*d));
+
+ int x = r.x();
+ int y = r.y();
+ int w = r.width();
+ int h = r.height();
+
+ int dx = 0;
+ int dy = 0;
+ if (w <= 0 || h <= 0)
+ return QDistanceField();
+
+ QDistanceField df(w, h);
+ if (df.isNull())
+ return df;
+
+ if (x < 0 || y < 0 || x + w > d->width || y + h > d->height) {
+ memset(df.d->data, 0, df.d->nbytes);
+ if (x < 0) {
+ dx = -x;
+ x = 0;
+ }
+ if (y < 0) {
+ dy = -y;
+ y = 0;
+ }
+ }
+
+ int pixels_to_copy = qMax(w - dx, 0);
+ if (x > d->width)
+ pixels_to_copy = 0;
+ else if (pixels_to_copy > d->width - x)
+ pixels_to_copy = d->width - x;
+ int lines_to_copy = qMax(h - dy, 0);
+ if (y > d->height)
+ lines_to_copy = 0;
+ else if (lines_to_copy > d->height - y)
+ lines_to_copy = d->height - y;
+
+ const uchar *src = d->data + x + y * d->width;
+ uchar *dest = df.d->data + dx + dy * df.d->width;
+ for (int i = 0; i < lines_to_copy; ++i) {
+ memcpy(dest, src, pixels_to_copy);
+ src += d->width;
+ dest += df.d->width;
+ }
+
+ df.d->glyph = d->glyph;
+
+ return df;
+}
+
+uchar *QDistanceField::bits()
+{
+ return d->data;
+}
+
+const uchar *QDistanceField::bits() const
+{
+ return d->data;
+}
+
+const uchar *QDistanceField::constBits() const
+{
+ return d->data;
+}
+
+uchar *QDistanceField::scanLine(int i)
+{
+ if (isNull())
+ return 0;
+
+ Q_ASSERT(i >= 0 && i < d->height);
+ return d->data + i * d->width;
+}
+
+const uchar *QDistanceField::scanLine(int i) const
+{
+ if (isNull())
+ return 0;
+
+ Q_ASSERT(i >= 0 && i < d->height);
+ return d->data + i * d->width;
+}
+
+const uchar *QDistanceField::constScanLine(int i) const
+{
+ if (isNull())
+ return 0;
+
+ Q_ASSERT(i >= 0 && i < d->height);
+ return d->data + i * d->width;
+}
+
+QImage QDistanceField::toImage(QImage::Format format) const
+{
+ if (isNull())
+ return QImage();
+
+ QImage image(d->width, d->height, format == QImage::Format_Indexed8 ?
+ format : QImage::Format_ARGB32_Premultiplied);
+ if (image.isNull())
+ return image;
+
+ if (format == QImage::Format_Indexed8) {
+ for (int y = 0; y < d->height; ++y)
+ memcpy(image.scanLine(y), scanLine(y), d->width);
+ } else {
+ for (int y = 0; y < d->height; ++y) {
+ for (int x = 0; x < d->width; ++x) {
+ uint alpha = *(d->data + x + y * d->width);
+ image.setPixel(x, y, alpha << 24);
+ }
+ }
+
+ if (image.format() != format)
+ image = image.convertToFormat(format);
+ }
+
+ return image;
}
QT_END_NAMESPACE
diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h
index f181aadd9d..d4c4f8f46d 100644
--- a/src/gui/text/qdistancefield_p.h
+++ b/src/gui/text/qdistancefield_p.h
@@ -55,6 +55,7 @@
#include <qrawfont.h>
#include <private/qfontengine_p.h>
+#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
@@ -78,9 +79,69 @@ QT_BEGIN_NAMESPACE
QT_DISTANCEFIELD_DEFAULT_RADIUS)
bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(const QRawFont &f);
-QImage Q_GUI_EXPORT qt_renderDistanceFieldGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution);
bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(QFontEngine *fontEngine);
-QImage Q_GUI_EXPORT qt_renderDistanceFieldGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution);
+
+class Q_GUI_EXPORT QDistanceFieldData : public QSharedData
+{
+public:
+ QDistanceFieldData() : glyph(0), width(0), height(0), nbytes(0), data(0) {}
+ QDistanceFieldData(const QDistanceFieldData &other);
+ ~QDistanceFieldData();
+
+ static QDistanceFieldData *create(const QSize &size);
+ static QDistanceFieldData *create(const QPainterPath &path, bool doubleResolution);
+
+ glyph_t glyph;
+ int width;
+ int height;
+ int nbytes;
+ uchar *data;
+};
+
+class Q_GUI_EXPORT QDistanceField
+{
+public:
+ QDistanceField();
+ QDistanceField(int width, int height);
+ QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution = false);
+ QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false);
+ QDistanceField(const QDistanceField &other);
+
+ bool isNull() const;
+
+ glyph_t glyph() const;
+ void setGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution = false);
+ void setGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false);
+
+ int width() const;
+ int height() const;
+
+ QDistanceField copy(const QRect &rect = QRect()) const;
+ inline QDistanceField copy(int x, int y, int w, int h) const
+ { return copy(QRect(x, y, w, h)); }
+
+ uchar *bits();
+ const uchar *bits() const;
+ const uchar *constBits() const;
+
+ uchar *scanLine(int);
+ const uchar *scanLine(int) const;
+ const uchar *constScanLine(int) const;
+
+ QImage toImage(QImage::Format format = QImage::Format_ARGB32_Premultiplied) const;
+
+private:
+ QDistanceField(QDistanceFieldData *data);
+ QSharedDataPointer<QDistanceFieldData> d;
+
+ friend class QDistanceFieldData;
+};
+
+
+inline QImage Q_GUI_EXPORT qt_renderDistanceFieldGlyph(const QRawFont &f, glyph_t g, bool d)
+{ return QDistanceField(f, g, d).toImage(QImage::Format_Indexed8); }
+inline QImage Q_GUI_EXPORT qt_renderDistanceFieldGlyph(QFontEngine *fe, glyph_t g, bool d)
+{ return QDistanceField(fe, g, d).toImage(QImage::Format_Indexed8); }
QT_END_NAMESPACE
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 2e4f341e39..97ac604197 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -315,9 +315,6 @@ struct QtFontFamily
QtFontFamily(const QString &n)
:
fixedPitch(false),
-#if !defined(QWS) && defined(Q_OS_MAC)
- fixedPitchComputed(false),
-#endif
name(n), count(0), foundries(0)
, bogusWritingSystems(false)
, askedForFallback(false)
@@ -331,9 +328,6 @@ struct QtFontFamily
}
bool fixedPitch : 1;
-#if !defined(QWS) && defined(Q_OS_MAC)
- bool fixedPitchComputed : 1;
-#endif
QString name;
QStringList aliases;
@@ -349,18 +343,6 @@ struct QtFontFamily
QtFontFoundry *foundry(const QString &f, bool = false);
};
-#if !defined(QWS) && defined(Q_OS_MAC)
-inline static void qt_mac_get_fixed_pitch(QtFontFamily *f)
-{
- if(f && !f->fixedPitchComputed) {
- QFontMetrics fm(f->name);
- f->fixedPitch = fm.width(QLatin1Char('i')) == fm.width(QLatin1Char('m'));
- f->fixedPitchComputed = true;
- }
-}
-#endif
-
-
QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
{
if (f.isNull() && count == 1)
@@ -824,9 +806,6 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
EncodingMismatch = 0x0002
};
if (pitch != '*') {
-#if !defined(QWS) && defined(Q_OS_MAC)
- qt_mac_get_fixed_pitch(const_cast<QtFontFamily*>(family));
-#endif
if ((pitch == 'm' && !family->fixedPitch)
|| (pitch == 'p' && family->fixedPitch))
this_score += PitchMismatch;
@@ -1275,9 +1254,6 @@ bool QFontDatabase::isFixedPitch(const QString &family,
QT_PREPEND_NAMESPACE(load)(familyName);
QtFontFamily *f = d->family(familyName);
-#if !defined(QWS) && defined(Q_OS_MAC)
- qt_mac_get_fixed_pitch(f);
-#endif
return (f && f->fixedPitch);
}
diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index b090213861..01c082059f 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -312,38 +312,38 @@ QT_END_INCLUDE_NAMESPACE
static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)
{
QList<QNetworkInterfacePrivate *> interfaces;
+ QSet<QString> seenInterfaces;
+ // on Linux, AF_PACKET addresses carry the hardware address and interface index;
+ // scan for them first (they're usually first, but we have no guarantee this
+ // will be the case forever)
for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {
- if ( !ptr->ifa_addr )
- continue;
-
- // Get the interface index
- int ifindex = if_nametoindex(ptr->ifa_name);
+ if (ptr->ifa_addr && ptr->ifa_addr->sa_family == AF_PACKET) {
+ sockaddr_ll *sll = (sockaddr_ll *)ptr->ifa_addr;
+ QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;
+ interfaces << iface;
+ iface->index = sll->sll_ifindex;
+ iface->name = QString::fromLatin1(ptr->ifa_name);
+ iface->flags = convertFlags(ptr->ifa_flags);
+ iface->hardwareAddress = iface->makeHwAddress(sll->sll_halen, (uchar*)sll->sll_addr);
- // on Linux we use AF_PACKET and sockaddr_ll to obtain hHwAddress
- QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();
- for ( ; if_it != interfaces.end(); ++if_it)
- if ((*if_it)->index == ifindex) {
- // this one has been added already
- if ( ptr->ifa_addr->sa_family == AF_PACKET
- && (*if_it)->hardwareAddress.isEmpty()) {
- sockaddr_ll *sll = (sockaddr_ll *)ptr->ifa_addr;
- (*if_it)->hardwareAddress = (*if_it)->makeHwAddress(sll->sll_halen, (uchar*)sll->sll_addr);
- }
- break;
- }
- if ( if_it != interfaces.end() )
- continue;
+ seenInterfaces.insert(iface->name);
+ }
+ }
- QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;
- interfaces << iface;
- iface->index = ifindex;
- iface->name = QString::fromLatin1(ptr->ifa_name);
- iface->flags = convertFlags(ptr->ifa_flags);
+ // see if we missed anything:
+ // virtual interfaces with no HW address have no AF_PACKET
+ for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {
+ if (ptr->ifa_addr && ptr->ifa_addr->sa_family != AF_PACKET) {
+ QString name = QString::fromLatin1(ptr->ifa_name);
+ if (seenInterfaces.contains(name))
+ continue;
- if ( ptr->ifa_addr->sa_family == AF_PACKET ) {
- sockaddr_ll *sll = (sockaddr_ll *)ptr->ifa_addr;
- iface->hardwareAddress = iface->makeHwAddress(sll->sll_halen, (uchar*)sll->sll_addr);
+ QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;
+ interfaces << iface;
+ iface->name = name;
+ iface->flags = convertFlags(ptr->ifa_flags);
+ iface->index = if_nametoindex(ptr->ifa_name);
}
}
@@ -423,11 +423,11 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
interfaces = createInterfaces(interfaceListing);
for (ifaddrs *ptr = interfaceListing; ptr; ptr = ptr->ifa_next) {
// Get the interface index
- int ifindex = if_nametoindex(ptr->ifa_name);
+ QString name = QString::fromLatin1(ptr->ifa_name);
QNetworkInterfacePrivate *iface = 0;
QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();
for ( ; if_it != interfaces.end(); ++if_it)
- if ((*if_it)->index == ifindex) {
+ if ((*if_it)->name == name) {
// found this interface already
iface = *if_it;
break;
diff --git a/src/platformsupport/jniconvenience/qjnihelpers_p.h b/src/platformsupport/jniconvenience/qjnihelpers_p.h
index fb44d156bd..437a0d039a 100644
--- a/src/platformsupport/jniconvenience/qjnihelpers_p.h
+++ b/src/platformsupport/jniconvenience/qjnihelpers_p.h
@@ -157,33 +157,39 @@ private:
template <class T, class X>
bool operator==(const QJNILocalRef<T> &ptr1, const QJNILocalRef<X> &ptr2)
{
- return ptr1.m_obj == ptr2.m_obj;
+ QAttachedJNIEnv env;
+ return env->IsSameObject(ptr1.m_obj, ptr2.m_obj);
}
template <class T, class X>
bool operator!=(const QJNILocalRef<T> &ptr1, const QJNILocalRef<X> &ptr2)
{
- return ptr1.m_obj != ptr2.m_obj;
+ QAttachedJNIEnv env;
+ return !env->IsSameObject(ptr1.m_obj, ptr2.m_obj);
}
template <class T, class X>
bool operator==(const QJNILocalRef<T> &ptr1, X ptr2)
{
- return ptr1.m_obj == ptr2;
+ QAttachedJNIEnv env;
+ return env->IsSameObject(ptr1.m_obj, ptr2);
}
template <class T, class X>
bool operator==(T ptr1, const QJNILocalRef<X> &ptr2)
{
- return ptr1 == ptr2.m_obj;
+ QAttachedJNIEnv env;
+ return env->IsSameObject(ptr1, ptr2.m_obj);
}
template <class T, class X>
bool operator!=(const QJNILocalRef<T> &ptr1, X ptr2)
{
- return !(ptr1 == ptr2);
+ QAttachedJNIEnv env;
+ return !env->IsSameObject(ptr1.m_obj, ptr2);
}
template <class T, class X>
bool operator!=(const T *ptr1, const QJNILocalRef<X> &ptr2)
{
- return !(ptr2 == ptr1);
+ QAttachedJNIEnv env;
+ return !env->IsSameObject(ptr1, ptr2.m_obj);
}
QT_END_NAMESPACE
diff --git a/src/platformsupport/jniconvenience/qjniobject.cpp b/src/platformsupport/jniconvenience/qjniobject.cpp
index 515e82b2f0..ecf247aabf 100644
--- a/src/platformsupport/jniconvenience/qjniobject.cpp
+++ b/src/platformsupport/jniconvenience/qjniobject.cpp
@@ -57,6 +57,9 @@ static jclass getCachedClass(JNIEnv *env, const char *className)
jclass c = env->FindClass(className);
if (env->ExceptionCheck()) {
c = 0;
+#ifdef QT_DEBUG
+ env->ExceptionDescribe();
+#endif // QT_DEBUG
env->ExceptionClear();
}
if (c)
@@ -88,6 +91,9 @@ static jmethodID getCachedMethodID(JNIEnv *env,
if (env->ExceptionCheck()) {
id = 0;
+#ifdef QT_DEBUG
+ env->ExceptionDescribe();
+#endif // QT_DEBUG
env->ExceptionClear();
}
@@ -117,6 +123,9 @@ static jfieldID getCachedFieldID(JNIEnv *env,
if (env->ExceptionCheck()) {
id = 0;
+#ifdef QT_DEBUG
+ env->ExceptionDescribe();
+#endif // QT_DEBUG
env->ExceptionClear();
}
@@ -127,7 +136,7 @@ static jfieldID getCachedFieldID(JNIEnv *env,
return id;
}
-QJNIObject::QJNIObject(const char *className)
+QJNIObjectPrivate::QJNIObjectPrivate(const char *className)
: m_jobject(0)
, m_jclass(0)
, m_own_jclass(false)
@@ -147,7 +156,7 @@ QJNIObject::QJNIObject(const char *className)
}
}
-QJNIObject::QJNIObject(const char *className, const char *sig, ...)
+QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, va_list args)
: m_jobject(0)
, m_jclass(0)
, m_own_jclass(false)
@@ -157,10 +166,7 @@ QJNIObject::QJNIObject(const char *className, const char *sig, ...)
if (m_jclass) {
jmethodID constructorId = getCachedMethodID(env, m_jclass, "<init>", sig);
if (constructorId) {
- va_list args;
- va_start(args, sig);
jobject obj = env->NewObjectV(m_jclass, constructorId, args);
- va_end(args);
if (obj) {
m_jobject = env->NewGlobalRef(obj);
env->DeleteLocalRef(obj);
@@ -169,7 +175,7 @@ QJNIObject::QJNIObject(const char *className, const char *sig, ...)
}
}
-QJNIObject::QJNIObject(jclass clazz)
+QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz)
: m_jobject(0)
, m_jclass(0)
, m_own_jclass(true)
@@ -189,7 +195,7 @@ QJNIObject::QJNIObject(jclass clazz)
}
}
-QJNIObject::QJNIObject(jclass clazz, const char *sig, ...)
+QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, va_list args)
: m_jobject(0)
, m_jclass(0)
, m_own_jclass(true)
@@ -200,10 +206,7 @@ QJNIObject::QJNIObject(jclass clazz, const char *sig, ...)
if (m_jclass) {
jmethodID constructorId = getCachedMethodID(env, m_jclass, "<init>", sig);
if (constructorId) {
- va_list args;
- va_start(args, sig);
jobject obj = env->NewObjectV(m_jclass, constructorId, args);
- va_end(args);
if (obj) {
m_jobject = env->NewGlobalRef(obj);
env->DeleteLocalRef(obj);
@@ -213,7 +216,7 @@ QJNIObject::QJNIObject(jclass clazz, const char *sig, ...)
}
}
-QJNIObject::QJNIObject(jobject obj)
+QJNIObjectPrivate::QJNIObjectPrivate(jobject obj)
: m_jobject(0)
, m_jclass(0)
, m_own_jclass(true)
@@ -223,7 +226,7 @@ QJNIObject::QJNIObject(jobject obj)
m_jclass = static_cast<jclass>(env->NewGlobalRef(env->GetObjectClass(m_jobject)));
}
-QJNIObject::~QJNIObject()
+QJNIObjectPrivate::~QJNIObjectPrivate()
{
QAttachedJNIEnv env;
if (m_jobject)
@@ -232,6 +235,23 @@ QJNIObject::~QJNIObject()
env->DeleteGlobalRef(m_jclass);
}
+QJNIObject::QJNIObject(const char *className, const char *sig, ...)
+{
+ va_list args;
+ va_start(args, sig);
+ d = QSharedPointer<QJNIObjectPrivate>(new QJNIObjectPrivate(className, sig, args));
+ va_end(args);
+}
+
+QJNIObject::QJNIObject(jclass clazz, const char *sig, ...)
+{
+ va_list args;
+ va_start(args, sig);
+ d = QSharedPointer<QJNIObjectPrivate>(new QJNIObjectPrivate(clazz, sig, args));
+ va_end(args);
+}
+
+
bool QJNIObject::isClassAvailable(const char *className)
{
QAttachedJNIEnv env;
@@ -248,11 +268,11 @@ template <>
void QJNIObject::callMethod<void>(const char *methodName, const char *sig, ...)
{
QAttachedJNIEnv env;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- env->CallVoidMethodV(m_jobject, id, args);
+ env->CallVoidMethodV(d->m_jobject, id, args);
va_end(args);
}
}
@@ -262,11 +282,11 @@ jboolean QJNIObject::callMethod<jboolean>(const char *methodName, const char *si
{
QAttachedJNIEnv env;
jboolean res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallBooleanMethodV(m_jobject, id, args);
+ res = env->CallBooleanMethodV(d->m_jobject, id, args);
va_end(args);
}
return res;
@@ -277,11 +297,11 @@ jbyte QJNIObject::callMethod<jbyte>(const char *methodName, const char *sig, ...
{
QAttachedJNIEnv env;
jbyte res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallByteMethodV(m_jobject, id, args);
+ res = env->CallByteMethodV(d->m_jobject, id, args);
va_end(args);
}
return res;
@@ -292,11 +312,11 @@ jchar QJNIObject::callMethod<jchar>(const char *methodName, const char *sig, ...
{
QAttachedJNIEnv env;
jchar res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallCharMethodV(m_jobject, id, args);
+ res = env->CallCharMethodV(d->m_jobject, id, args);
va_end(args);
}
return res;
@@ -307,11 +327,11 @@ jshort QJNIObject::callMethod<jshort>(const char *methodName, const char *sig, .
{
QAttachedJNIEnv env;
jshort res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallShortMethodV(m_jobject, id, args);
+ res = env->CallShortMethodV(d->m_jobject, id, args);
va_end(args);
}
return res;
@@ -322,11 +342,11 @@ jint QJNIObject::callMethod<jint>(const char *methodName, const char *sig, ...)
{
QAttachedJNIEnv env;
jint res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallIntMethodV(m_jobject, id, args);
+ res = env->CallIntMethodV(d->m_jobject, id, args);
va_end(args);
}
return res;
@@ -337,11 +357,11 @@ jlong QJNIObject::callMethod<jlong>(const char *methodName, const char *sig, ...
{
QAttachedJNIEnv env;
jlong res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallLongMethodV(m_jobject, id, args);
+ res = env->CallLongMethodV(d->m_jobject, id, args);
va_end(args);
}
return res;
@@ -352,11 +372,11 @@ jfloat QJNIObject::callMethod<jfloat>(const char *methodName, const char *sig, .
{
QAttachedJNIEnv env;
jfloat res = 0.f;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallFloatMethodV(m_jobject, id, args);
+ res = env->CallFloatMethodV(d->m_jobject, id, args);
va_end(args);
}
return res;
@@ -367,11 +387,11 @@ jdouble QJNIObject::callMethod<jdouble>(const char *methodName, const char *sig,
{
QAttachedJNIEnv env;
jdouble res = 0.;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallDoubleMethodV(m_jobject, id, args);
+ res = env->CallDoubleMethodV(d->m_jobject, id, args);
va_end(args);
}
return res;
@@ -384,11 +404,11 @@ QJNILocalRef<jobject> QJNIObject::callObjectMethod<jobject>(const char *methodNa
{
QAttachedJNIEnv env;
jobject res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = env->CallObjectMethodV(m_jobject, id, args);
+ res = env->CallObjectMethodV(d->m_jobject, id, args);
va_end(args);
}
return QJNILocalRef<jobject>(res);
@@ -401,11 +421,11 @@ QJNILocalRef<jstring> QJNIObject::callObjectMethod<jstring>(const char *methodNa
{
QAttachedJNIEnv env;
jstring res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jstring>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jstring>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jstring>(res);
@@ -418,11 +438,11 @@ QJNILocalRef<jobjectArray> QJNIObject::callObjectMethod<jobjectArray>(const char
{
QAttachedJNIEnv env;
jobjectArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jobjectArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jobjectArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jobjectArray>(res);
@@ -435,11 +455,11 @@ QJNILocalRef<jbooleanArray> QJNIObject::callObjectMethod<jbooleanArray>(const ch
{
QAttachedJNIEnv env;
jbooleanArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jbooleanArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jbooleanArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jbooleanArray>(res);
@@ -452,11 +472,11 @@ QJNILocalRef<jbyteArray> QJNIObject::callObjectMethod<jbyteArray>(const char *me
{
QAttachedJNIEnv env;
jbyteArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jbyteArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jbyteArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jbyteArray>(res);
@@ -469,11 +489,11 @@ QJNILocalRef<jcharArray> QJNIObject::callObjectMethod<jcharArray>(const char *me
{
QAttachedJNIEnv env;
jcharArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jcharArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jcharArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jcharArray>(res);
@@ -486,11 +506,11 @@ QJNILocalRef<jshortArray> QJNIObject::callObjectMethod<jshortArray>(const char *
{
QAttachedJNIEnv env;
jshortArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jshortArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jshortArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jshortArray>(res);
@@ -503,11 +523,11 @@ QJNILocalRef<jintArray> QJNIObject::callObjectMethod<jintArray>(const char *meth
{
QAttachedJNIEnv env;
jintArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jintArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jintArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jintArray>(res);
@@ -520,11 +540,11 @@ QJNILocalRef<jlongArray> QJNIObject::callObjectMethod<jlongArray>(const char *me
{
QAttachedJNIEnv env;
jlongArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jlongArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jlongArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jlongArray>(res);
@@ -537,11 +557,11 @@ QJNILocalRef<jfloatArray> QJNIObject::callObjectMethod<jfloatArray>(const char *
{
QAttachedJNIEnv env;
jfloatArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jfloatArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jfloatArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jfloatArray>(res);
@@ -554,11 +574,11 @@ QJNILocalRef<jdoubleArray> QJNIObject::callObjectMethod<jdoubleArray>(const char
{
QAttachedJNIEnv env;
jdoubleArray res = 0;
- jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
if (id) {
va_list args;
va_start(args, sig);
- res = static_cast<jdoubleArray>(env->CallObjectMethodV(m_jobject, id, args));
+ res = static_cast<jdoubleArray>(env->CallObjectMethodV(d->m_jobject, id, args));
va_end(args);
}
return QJNILocalRef<jdoubleArray>(res);
@@ -1796,9 +1816,9 @@ jboolean QJNIObject::getField<jboolean>(const char *fieldName)
{
QAttachedJNIEnv env;
jboolean res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Z");
if (id)
- res = env->GetBooleanField(m_jobject, id);
+ res = env->GetBooleanField(d->m_jobject, id);
return res;
}
@@ -1808,9 +1828,9 @@ jbyte QJNIObject::getField<jbyte>(const char *fieldName)
{
QAttachedJNIEnv env;
jbyte res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "B");
if (id)
- res = env->GetByteField(m_jobject, id);
+ res = env->GetByteField(d->m_jobject, id);
return res;
}
@@ -1820,9 +1840,9 @@ jchar QJNIObject::getField<jchar>(const char *fieldName)
{
QAttachedJNIEnv env;
jchar res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "C");
if (id)
- res = env->GetCharField(m_jobject, id);
+ res = env->GetCharField(d->m_jobject, id);
return res;
}
@@ -1832,9 +1852,9 @@ jshort QJNIObject::getField<jshort>(const char *fieldName)
{
QAttachedJNIEnv env;
jshort res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "S");
if (id)
- res = env->GetShortField(m_jobject, id);
+ res = env->GetShortField(d->m_jobject, id);
return res;
}
@@ -1844,9 +1864,9 @@ jint QJNIObject::getField<jint>(const char *fieldName)
{
QAttachedJNIEnv env;
jint res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "I");
if (id)
- res = env->GetIntField(m_jobject, id);
+ res = env->GetIntField(d->m_jobject, id);
return res;
}
@@ -1856,9 +1876,9 @@ jlong QJNIObject::getField<jlong>(const char *fieldName)
{
QAttachedJNIEnv env;
jlong res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "J");
if (id)
- res = env->GetLongField(m_jobject, id);
+ res = env->GetLongField(d->m_jobject, id);
return res;
}
@@ -1868,9 +1888,9 @@ jfloat QJNIObject::getField<jfloat>(const char *fieldName)
{
QAttachedJNIEnv env;
jfloat res = 0.f;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "F");
if (id)
- res = env->GetFloatField(m_jobject, id);
+ res = env->GetFloatField(d->m_jobject, id);
return res;
}
@@ -1880,9 +1900,9 @@ jdouble QJNIObject::getField<jdouble>(const char *fieldName)
{
QAttachedJNIEnv env;
jdouble res = 0.;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "D");
if (id)
- res = env->GetDoubleField(m_jobject, id);
+ res = env->GetDoubleField(d->m_jobject, id);
return res;
}
@@ -1892,9 +1912,9 @@ QJNILocalRef<jobject> QJNIObject::getObjectField<jobject>(const char *fieldName,
{
QAttachedJNIEnv env;
jobject res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
if (id)
- res = env->GetObjectField(m_jobject, id);
+ res = env->GetObjectField(d->m_jobject, id);
return QJNILocalRef<jobject>(res);
}
@@ -1904,9 +1924,9 @@ QJNILocalRef<jbooleanArray> QJNIObject::getObjectField<jbooleanArray>(const char
{
QAttachedJNIEnv env;
jbooleanArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[Z");
if (id)
- res = static_cast<jbooleanArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jbooleanArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jbooleanArray>(res);
}
@@ -1916,9 +1936,9 @@ QJNILocalRef<jbyteArray> QJNIObject::getObjectField<jbyteArray>(const char *fiel
{
QAttachedJNIEnv env;
jbyteArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[B");
if (id)
- res = static_cast<jbyteArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jbyteArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jbyteArray>(res);
}
@@ -1928,9 +1948,9 @@ QJNILocalRef<jcharArray> QJNIObject::getObjectField<jcharArray>(const char *fiel
{
QAttachedJNIEnv env;
jcharArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[C");
if (id)
- res = static_cast<jcharArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jcharArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jcharArray>(res);
}
@@ -1940,9 +1960,9 @@ QJNILocalRef<jshortArray> QJNIObject::getObjectField<jshortArray>(const char *fi
{
QAttachedJNIEnv env;
jshortArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[S");
if (id)
- res = static_cast<jshortArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jshortArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jshortArray>(res);
}
@@ -1952,9 +1972,9 @@ QJNILocalRef<jintArray> QJNIObject::getObjectField<jintArray>(const char *fieldN
{
QAttachedJNIEnv env;
jintArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[I");
if (id)
- res = static_cast<jintArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jintArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jintArray>(res);
}
@@ -1964,9 +1984,9 @@ QJNILocalRef<jlongArray> QJNIObject::getObjectField<jlongArray>(const char *fiel
{
QAttachedJNIEnv env;
jlongArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[J");
if (id)
- res = static_cast<jlongArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jlongArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jlongArray>(res);
}
@@ -1976,9 +1996,9 @@ QJNILocalRef<jfloatArray> QJNIObject::getObjectField<jfloatArray>(const char *fi
{
QAttachedJNIEnv env;
jfloatArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[F");
if (id)
- res = static_cast<jfloatArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jfloatArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jfloatArray>(res);
}
@@ -1988,9 +2008,9 @@ QJNILocalRef<jdoubleArray> QJNIObject::getObjectField<jdoubleArray>(const char *
{
QAttachedJNIEnv env;
jdoubleArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[D");
if (id)
- res = static_cast<jdoubleArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jdoubleArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jdoubleArray>(res);
}
@@ -2000,9 +2020,9 @@ QJNILocalRef<jstring> QJNIObject::getObjectField<jstring>(const char *fieldName)
{
QAttachedJNIEnv env;
jstring res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Ljava/lang/String;");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Ljava/lang/String;");
if (id)
- res = static_cast<jstring>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jstring>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jstring>(res);
}
@@ -2013,9 +2033,9 @@ QJNILocalRef<jobjectArray> QJNIObject::getObjectField<jobjectArray>(const char *
{
QAttachedJNIEnv env;
jobjectArray res = 0;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
if (id)
- res = static_cast<jobjectArray>(env->GetObjectField(m_jobject, id));
+ res = static_cast<jobjectArray>(env->GetObjectField(d->m_jobject, id));
return QJNILocalRef<jobjectArray>(res);
}
@@ -2024,9 +2044,9 @@ template <>
void QJNIObject::setField<jboolean>(const char *fieldName, jboolean value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Z");
if (id)
- env->SetBooleanField(m_jobject, id, value);
+ env->SetBooleanField(d->m_jobject, id, value);
}
@@ -2034,9 +2054,9 @@ template <>
void QJNIObject::setField<jbyte>(const char *fieldName, jbyte value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "B");
if (id)
- env->SetByteField(m_jobject, id, value);
+ env->SetByteField(d->m_jobject, id, value);
}
@@ -2044,9 +2064,9 @@ template <>
void QJNIObject::setField<jchar>(const char *fieldName, jchar value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "C");
if (id)
- env->SetCharField(m_jobject, id, value);
+ env->SetCharField(d->m_jobject, id, value);
}
@@ -2054,9 +2074,9 @@ template <>
void QJNIObject::setField<jshort>(const char *fieldName, jshort value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "S");
if (id)
- env->SetShortField(m_jobject, id, value);
+ env->SetShortField(d->m_jobject, id, value);
}
@@ -2064,9 +2084,9 @@ template <>
void QJNIObject::setField<jint>(const char *fieldName, jint value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "I");
if (id)
- env->SetIntField(m_jobject, id, value);
+ env->SetIntField(d->m_jobject, id, value);
}
@@ -2074,9 +2094,9 @@ template <>
void QJNIObject::setField<jlong>(const char *fieldName, jlong value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "J");
if (id)
- env->SetLongField(m_jobject, id, value);
+ env->SetLongField(d->m_jobject, id, value);
}
@@ -2084,9 +2104,9 @@ template <>
void QJNIObject::setField<jfloat>(const char *fieldName, jfloat value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "F");
if (id)
- env->SetFloatField(m_jobject, id, value);
+ env->SetFloatField(d->m_jobject, id, value);
}
@@ -2094,9 +2114,9 @@ template <>
void QJNIObject::setField<jdouble>(const char *fieldName, jdouble value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "D");
if (id)
- env->SetDoubleField(m_jobject, id, value);
+ env->SetDoubleField(d->m_jobject, id, value);
}
@@ -2104,9 +2124,9 @@ template <>
void QJNIObject::setField<jbooleanArray>(const char *fieldName, jbooleanArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[Z");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2114,9 +2134,9 @@ template <>
void QJNIObject::setField<jbyteArray>(const char *fieldName, jbyteArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[B");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2124,9 +2144,9 @@ template <>
void QJNIObject::setField<jcharArray>(const char *fieldName, jcharArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[C");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2134,9 +2154,9 @@ template <>
void QJNIObject::setField<jshortArray>(const char *fieldName, jshortArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[S");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2144,9 +2164,9 @@ template <>
void QJNIObject::setField<jintArray>(const char *fieldName, jintArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[I");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2154,9 +2174,9 @@ template <>
void QJNIObject::setField<jlongArray>(const char *fieldName, jlongArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[J");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2164,9 +2184,9 @@ template <>
void QJNIObject::setField<jfloatArray>(const char *fieldName, jfloatArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[F");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2174,9 +2194,9 @@ template <>
void QJNIObject::setField<jdoubleArray>(const char *fieldName, jdoubleArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[D");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2184,9 +2204,9 @@ template <>
void QJNIObject::setField<jstring>(const char *fieldName, jstring value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Ljava/lang/String;");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Ljava/lang/String;");
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2194,9 +2214,9 @@ template <>
void QJNIObject::setField<jobject>(const char *fieldName, const char *sig, jobject value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
@@ -2206,9 +2226,9 @@ void QJNIObject::setField<jobjectArray>(const char *fieldName,
jobjectArray value)
{
QAttachedJNIEnv env;
- jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
if (id)
- env->SetObjectField(m_jobject, id, value);
+ env->SetObjectField(d->m_jobject, id, value);
}
diff --git a/src/platformsupport/jniconvenience/qjniobject_p.h b/src/platformsupport/jniconvenience/qjniobject_p.h
index 6874765f06..8721ec3a6a 100644
--- a/src/platformsupport/jniconvenience/qjniobject_p.h
+++ b/src/platformsupport/jniconvenience/qjniobject_p.h
@@ -43,6 +43,7 @@
#define QJNIOBJECT_H
#include <qglobal.h>
+#include <qsharedpointer.h>
#include <jni.h>
QT_BEGIN_NAMESPACE
@@ -72,20 +73,40 @@ class QJNILocalRef;
* someObject.setField<jint>("fieldName", 10);
* someObject.callMethod<void>("doStuff");
*/
+
+class QJNIObjectPrivate
+{
+public:
+ QJNIObjectPrivate(const char *className);
+ QJNIObjectPrivate(const char *className, const char *sig, va_list args);
+ QJNIObjectPrivate(jclass clazz);
+ QJNIObjectPrivate(jclass clazz, const char *sig, va_list args);
+ QJNIObjectPrivate(jobject obj);
+ ~QJNIObjectPrivate();
+
+private:
+ Q_DISABLE_COPY(QJNIObjectPrivate)
+ friend class QJNIObject;
+ jobject m_jobject;
+ jclass m_jclass;
+ bool m_own_jclass;
+};
+
class QJNIObject
{
public:
- QJNIObject(const char *className);
+ explicit QJNIObject(const char *className) : d(new QJNIObjectPrivate(className)) { }
QJNIObject(const char *className, const char *sig, ...);
- QJNIObject(jclass clazz);
+ explicit QJNIObject(jclass clazz) : d(new QJNIObjectPrivate(clazz)) { }
QJNIObject(jclass clazz, const char *sig, ...);
- QJNIObject(jobject obj);
- virtual ~QJNIObject();
+ explicit QJNIObject(jobject obj) : d(new QJNIObjectPrivate(obj)) { }
+
+ virtual ~QJNIObject() { }
static bool isClassAvailable(const char *className);
- bool isValid() const { return m_jobject != 0; }
- jobject object() const { return m_jobject; }
+ bool isValid() const { return d->m_jobject != 0; }
+ jobject object() const { return d->m_jobject; }
template <typename T>
T callMethod(const char *methodName);
@@ -158,10 +179,8 @@ public:
template <typename T>
static void setStaticField(jclass clazz, const char *fieldName, T value);
-protected:
- jobject m_jobject;
- jclass m_jclass;
- bool m_own_jclass;
+private:
+ QSharedPointer<QJNIObjectPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp b/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp
index 5362906e0e..24a7debd1f 100644
--- a/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp
+++ b/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp
@@ -69,7 +69,6 @@ void QAndroidOpenGLPlatformWindow::invalidateSurface()
{
QWindowSystemInterface::handleExposeEvent(window(), QRegion()); // Obscure event
QWindowSystemInterface::flushWindowSystemEvents();
- QEglFSWindow::invalidateSurface();
m_window = 0;
m_surface = 0;
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 2ac9a5dac9..9a661ffe5a 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -594,6 +594,7 @@ void QCocoaEventDispatcherPrivate::temporarilyStopAllModalSessions()
if (info.session) {
[NSApp endModalSession:info.session];
info.session = 0;
+ [(NSWindow*) info.nswindow release];
}
}
currentModalSessionCached = 0;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 20f767e240..46d3b7329e 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1010,7 +1010,12 @@ qreal QCocoaWindow::devicePixelRatio() const
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- return qreal([[m_contentView window] backingScaleFactor]);
+ NSWindow* window = [m_contentView window];
+ if (window) {
+ return qreal([window backingScaleFactor]);
+ } else {
+ return 1.0;
+ }
} else
#endif
{
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index e529e445ad..51c3953af1 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -285,6 +285,10 @@ static QTouchDevice *touchDevice = 0;
Qt::WindowState newState = notificationName == NSWindowDidMiniaturizeNotification ?
Qt::WindowMinimized : Qt::WindowNoState;
[self notifyWindowStateChanged:newState];
+ // NSWindowDidOrderOnScreenAndFinishAnimatingNotification is private API, and not
+ // emitted in 10.6, so we bring back the old behavior for that case alone.
+ if (newState == Qt::WindowNoState && QSysInfo::QSysInfo::MacintoshVersion == QSysInfo::MV_10_6)
+ m_platformWindow->exposeWindow();
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOffScreenNotification"]) {
m_platformWindow->obscureWindow();
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) {
diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
index 133bf02fee..4c36a97ab6 100644
--- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
+++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
@@ -226,9 +226,14 @@ bool QQnxBpsEventFilter::handleNavigatorEvent(bps_event_t *event)
break;
case NAVIGATOR_WINDOW_THUMBNAIL:
m_navigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowMinimized);
+#if defined(Q_OS_BLACKBERRY_TABLET)
+ m_navigatorEventHandler->handleWindowGroupActivated(id);
+#endif
break;
case NAVIGATOR_WINDOW_INVISIBLE:
+#if defined(Q_OS_BLACKBERRY_TABLET)
m_navigatorEventHandler->handleWindowGroupDeactivated(id);
+#endif
break;
}
diff --git a/src/plugins/platforms/qnx/qqnxrootwindow.cpp b/src/plugins/platforms/qnx/qqnxrootwindow.cpp
index ff5866d1b7..b3f5c87176 100644
--- a/src/plugins/platforms/qnx/qqnxrootwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxrootwindow.cpp
@@ -188,35 +188,8 @@ void QQnxRootWindow::makeTranslucent()
int result;
errno = 0;
- result = screen_destroy_window_buffers(m_window);
- if (result != 0) {
- qFatal("QQnxRootWindow: failed to destroy window buffer, errno=%d", errno);
- }
-
- QRect geometry = m_screen->geometry();
- errno = 0;
- int val[2];
- val[0] = geometry.width();
- val[1] = geometry.height();
- result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val);
- if (result != 0) {
- qFatal("QQnxRootWindow: failed to set window buffer size, errno=%d", errno);
- }
-
- errno = 0;
- result = screen_create_window_buffers(m_window, 1);
- if (result != 0) {
- qFatal("QQNX: failed to create window buffer, errno=%d", errno);
- }
-
- // Install an alpha channel on the root window.
- //
- // This is necessary in order to avoid interfering with any particular
- // toplevel widget's QQnxWindow window instance from showing transparent
- // if it desires.
- errno = 0;
- val[0] = SCREEN_TRANSPARENCY_SOURCE_OVER;
- result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val);
+ const int val = SCREEN_TRANSPARENCY_DISCARD;
+ result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, &val);
if (result != 0) {
qFatal("QQnxRootWindow: failed to set window transparency, errno=%d", errno);
}
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index 45e565f24f..9b9576c88b 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -432,15 +432,27 @@ QQnxBuffer &QQnxWindow::renderBuffer()
// Get all buffers available for rendering
errno = 0;
screen_buffer_t buffers[MAX_BUFFER_COUNT];
- const int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers);
+ int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers);
if (result != 0)
qFatal("QQnxWindow: failed to query window buffers, errno=%d", errno);
- // Wrap each buffer
+ // Wrap each buffer and clear
for (int i = 0; i < MAX_BUFFER_COUNT; ++i) {
m_buffers[i] = QQnxBuffer(buffers[i]);
+
+ // Clear Buffer
+ errno = 0;
+ int bg[] = { SCREEN_BLIT_COLOR, 0x00000000, SCREEN_BLIT_END };
+ result = screen_fill(m_screen->nativeContext(), buffers[i], bg);
+ if (result != 0)
+ qFatal("QQnxWindow: failed to clear window buffer, errno=%d", errno);
}
+ errno = 0;
+ result = screen_flush_blits(m_screen->nativeContext(), 0);
+ if (result != 0)
+ qFatal("QQnxWindow: failed to flush blits, errno=%d", errno);
+
// Use the first available render buffer
m_currentBufferIndex = 0;
m_previousBufferIndex = -1;
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index fc2ba454df..754d7a0288 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -395,6 +395,8 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co
return true;
case MultipleWindows:
return true;
+ case ForeignWindows:
+ return true;
default:
return QPlatformIntegration::hasCapability(cap);
}
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index f616972aa0..530ebc38b7 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -98,35 +98,39 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM
WindowsScreenDataList *result = reinterpret_cast<WindowsScreenDataList *>(p);
QWindowsScreenData data;
data.geometry = QRect(QPoint(info.rcMonitor.left, info.rcMonitor.top), QPoint(info.rcMonitor.right - 1, info.rcMonitor.bottom - 1));
+ data.name = QString::fromWCharArray(info.szDevice);
+ if (data.name == QLatin1String("WinDisc")) {
+ data.flags |= QWindowsScreenData::LockScreen;
+ } else {
#ifdef Q_OS_WINCE
- //Windows CE, just supports one Display and expects to get only DISPLAY,
- //instead of DISPLAY0 and so on, which are passed by info.szDevice
- HDC hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
+ //Windows CE, just supports one Display and expects to get only DISPLAY,
+ //instead of DISPLAY0 and so on, which are passed by info.szDevice
+ HDC hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
#else
- HDC hdc = CreateDC(info.szDevice, NULL, NULL, NULL);
+ HDC hdc = CreateDC(info.szDevice, NULL, NULL, NULL);
#endif
- if (hdc) {
- data.dpi = deviceDPI(hdc);
- data.depth = GetDeviceCaps(hdc, BITSPIXEL);
- data.format = data.depth == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
- data.physicalSizeMM = QSizeF(GetDeviceCaps(hdc, HORZSIZE), GetDeviceCaps(hdc, VERTSIZE));
- const int refreshRate = GetDeviceCaps(hdc, VREFRESH);
- if (refreshRate > 1) // 0,1 means heardware default.
- data.refreshRateHz = refreshRate;
- DeleteDC(hdc);
- } else {
- qWarning("%s: Unable to obtain handle for monitor '%s', defaulting to %g DPI.",
- __FUNCTION__, qPrintable(QString::fromWCharArray(info.szDevice)),
- data.dpi.first);
- }
+ if (hdc) {
+ data.dpi = deviceDPI(hdc);
+ data.depth = GetDeviceCaps(hdc, BITSPIXEL);
+ data.format = data.depth == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
+ data.physicalSizeMM = QSizeF(GetDeviceCaps(hdc, HORZSIZE), GetDeviceCaps(hdc, VERTSIZE));
+ const int refreshRate = GetDeviceCaps(hdc, VREFRESH);
+ if (refreshRate > 1) // 0,1 means hardware default.
+ data.refreshRateHz = refreshRate;
+ DeleteDC(hdc);
+ } else {
+ qWarning("%s: Unable to obtain handle for monitor '%s', defaulting to %g DPI.",
+ __FUNCTION__, qPrintable(QString::fromWCharArray(info.szDevice)),
+ data.dpi.first);
+ } // CreateDC() failed
+ } // not lock screen
data.geometry = QRect(QPoint(info.rcMonitor.left, info.rcMonitor.top), QPoint(info.rcMonitor.right - 1, info.rcMonitor.bottom - 1));
data.availableGeometry = QRect(QPoint(info.rcWork.left, info.rcWork.top), QPoint(info.rcWork.right - 1, info.rcWork.bottom - 1));
data.orientation = data.geometry.height() > data.geometry.width() ?
Qt::PortraitOrientation : Qt::LandscapeOrientation;
// EnumDisplayMonitors (as opposed to EnumDisplayDevices) enumerates only
// virtual desktop screens.
- data.name = QString::fromWCharArray(info.szDevice);
- data.flags = QWindowsScreenData::VirtualDesktop;
+ data.flags |= QWindowsScreenData::VirtualDesktop;
if (info.dwFlags & MONITORINFOF_PRIMARY) {
data.flags |= QWindowsScreenData::PrimaryScreen;
// QPlatformIntegration::screenAdded() documentation specifies that first
@@ -162,6 +166,8 @@ static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d)
nospace << " primary";
if (d.flags & QWindowsScreenData::VirtualDesktop)
nospace << " virtual desktop";
+ if (d.flags & QWindowsScreenData::LockScreen)
+ nospace << " lock screen";
return dbg;
}
@@ -392,7 +398,8 @@ static inline int indexOfMonitor(const QList<QWindowsScreenData> &screenData,
bool QWindowsScreenManager::handleScreenChanges()
{
// Look for changed monitors, add new ones
- const WindowsScreenDataList newDataList = monitorData();
+ WindowsScreenDataList newDataList = monitorData();
+ const bool lockScreen = newDataList.size() == 1 && (newDataList.front().flags & QWindowsScreenData::LockScreen);
foreach (const QWindowsScreenData &newData, newDataList) {
const int existingIndex = indexOfMonitor(m_screens, newData.name);
if (existingIndex != -1) {
@@ -405,14 +412,17 @@ bool QWindowsScreenManager::handleScreenChanges()
qDebug() << "New Monitor: " << newData;
} // exists
} // for new screens.
- // Remove deleted ones.
- for (int i = m_screens.size() - 1; i >= 0; --i) {
- if (indexOfMonitor(newDataList, m_screens.at(i)->data().name) == -1) {
- if (QWindowsContext::verboseWindows)
- qDebug() << "Removing Monitor: " << m_screens.at(i) ->data();
- delete m_screens.takeAt(i);
- } // not found
- } // for existing screens
+ // Remove deleted ones but keep main monitors if we get only the
+ // temporary lock screen to avoid window recreation (QTBUG-33062).
+ if (!lockScreen) {
+ for (int i = m_screens.size() - 1; i >= 0; --i) {
+ if (indexOfMonitor(newDataList, m_screens.at(i)->data().name) == -1) {
+ if (QWindowsContext::verboseWindows)
+ qDebug() << "Removing Monitor: " << m_screens.at(i) ->data();
+ delete m_screens.takeAt(i);
+ } // not found
+ } // for existing screens
+ } // not lock screen
return true;
}
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index 216973125b..930814a17d 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -59,7 +59,8 @@ struct QWindowsScreenData
enum Flags
{
PrimaryScreen = 0x1,
- VirtualDesktop = 0x2
+ VirtualDesktop = 0x2,
+ LockScreen = 0x4 // Temporary screen existing during user change, etc.
};
QWindowsScreenData();
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 8ec10294a2..ace18ddf5b 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -485,6 +485,18 @@ QWindowsWindow::WindowData
qDebug().nospace() << "Created desktop window " << w << result.hwnd;
return result;
}
+ if ((flags & Qt::WindowType_Mask) == Qt::ForeignWindow) {
+ result.hwnd = reinterpret_cast<HWND>(w->winId());
+ Q_ASSERT(result.hwnd);
+ const LONG_PTR style = GetWindowLongPtr(result.hwnd, GWL_STYLE);
+ const LONG_PTR exStyle = GetWindowLongPtr(result.hwnd, GWL_EXSTYLE);
+ result.geometry = frameGeometry(result.hwnd, !GetParent(result.hwnd));
+ result.frame = QWindowsGeometryHint::frame(style, exStyle);
+ result.embedded = false;
+ if (QWindowsContext::verboseWindows)
+ qDebug() << "Foreign window: " << w << result.hwnd << result.geometry << result.frame;
+ return result;
+ }
const HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0);
@@ -894,7 +906,7 @@ void QWindowsWindow::destroyWindow()
}
}
#endif // !Q_OS_WINCE
- if (m_data.hwnd != GetDesktopWindow())
+ if (m_data.hwnd != GetDesktopWindow() && window()->type() != Qt::ForeignWindow)
DestroyWindow(m_data.hwnd);
context->removeWindow(m_data.hwnd);
m_data.hwnd = 0;
@@ -1408,14 +1420,27 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state)
handleHidden();
QWindowSystemInterface::flushWindowSystemEvents(); // Tell QQuickWindow to stop rendering now.
break;
- case Qt::WindowNoState:
+ case Qt::WindowNoState: {
// QTBUG-17548: We send expose events when receiving WM_Paint, but for
- // layered windows, we won't receive any WM_Paint.
- if (GetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE) & WS_EX_LAYERED) {
- fireExpose(QRegion(0, 0, window()->width(), window()->height()));
- if (!QWindowsContext::instance()->asyncExpose())
- QWindowSystemInterface::flushWindowSystemEvents();
+ // layered windows and transient children, we won't receive any WM_Paint.
+ QWindow *w = window();
+ bool exposeEventsSent = false;
+ if (isLayered()) {
+ fireExpose(QRegion(0, 0, w->width(), w->height()));
+ exposeEventsSent = true;
}
+ foreach (QWindow *child, QGuiApplication::allWindows()) {
+ if (child != w && child->isVisible() && child->transientParent() == w) {
+ QWindowsWindow *platformWindow = QWindowsWindow::baseWindowOf(child);
+ if (platformWindow->isLayered()) {
+ platformWindow->fireExpose(QRegion(0, 0, child->width(), child->height()));
+ exposeEventsSent = true;
+ }
+ }
+ }
+ if (exposeEventsSent && !QWindowsContext::instance()->asyncExpose())
+ QWindowSystemInterface::flushWindowSystemEvents();
+ }
break;
default:
break;
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index f7d142fc36..afcfa8b821 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -229,6 +229,7 @@ public:
static inline void setUserDataOf(HWND hwnd, void *ud);
static bool setWindowLayered(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, qreal opacity);
+ bool isLayered() const;
HDC getDC();
void releaseDC();
@@ -375,6 +376,15 @@ inline void QWindowsWindow::destroyIcon()
}
}
+inline bool QWindowsWindow::isLayered() const
+{
+#ifndef Q_OS_WINCE
+ return GetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE) & WS_EX_LAYERED;
+#else
+ return false;
+#endif
+}
+
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QMargins)
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index 1f2485db0d..dc677cd3be 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -306,6 +306,10 @@ void QXcbBackingStore::flush(QWindow *window, const QRegion &region, const QPoin
Q_XCB_NOOP(connection());
QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window->handle());
+ if (!platformWindow) {
+ qWarning("QXcbBackingStore::flush: QWindow has no platform window (QTBUG-32681)");
+ return;
+ }
QVector<QRect> rects = clipped.rects();
for (int i = 0; i < rects.size(); ++i)
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 3f717ae2df..e594f1fedc 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -998,8 +998,11 @@ void QXcbEventReader::run()
emit eventPending();
}
+ m_mutex.lock();
for (int i = 0; i < m_events.size(); ++i)
free(m_events.at(i));
+ m_events.clear();
+ m_mutex.unlock();
}
void QXcbEventReader::addEvent(xcb_generic_event_t *event)
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp
index bd97db189c..e4979e54a4 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/sql/drivers/ibase/qsql_ibase.cpp
@@ -240,7 +240,7 @@ static ISC_TIMESTAMP toTimeStamp(const QDateTime &dt)
static QDateTime fromTimeStamp(char *buffer)
{
static const QDate bd(1858, 11, 17);
- QTime t;
+ QTime t(0, 0);
QDate d;
// have to demangle the structure ourselves because isc_decode_time
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 4757fdad93..50da6d2e54 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -184,6 +184,18 @@ bool Generator::registerableMetaType(const QByteArray &propertyType)
return false;
}
+/* returns true if name and qualifiedName refers to the same name.
+ * If qualified name is "A::B::C", it returns true for "C", "B::C" or "A::B::C" */
+static bool qualifiedNameEquals(const QByteArray &qualifiedName, const QByteArray &name)
+{
+ if (qualifiedName == name)
+ return true;
+ int index = qualifiedName.indexOf("::");
+ if (index == -1)
+ return false;
+ return qualifiedNameEquals(qualifiedName.mid(index+2), name);
+}
+
void Generator::generateCode()
{
bool isQt = (cdef->classname == "Qt");
@@ -431,7 +443,7 @@ void Generator::generateCode()
int s = p.type.lastIndexOf("::");
if (s > 0) {
QByteArray scope = p.type.left(s);
- if (scope != "Qt" && scope != cdef->classname && !extraList.contains(scope))
+ if (scope != "Qt" && !qualifiedNameEquals(cdef->qualified, scope) && !extraList.contains(scope))
extraList += scope;
}
}
@@ -446,7 +458,7 @@ void Generator::generateCode()
int s = enumKey.lastIndexOf("::");
if (s > 0) {
QByteArray scope = enumKey.left(s);
- if (scope != "Qt" && scope != cdef->classname && !extraList.contains(scope))
+ if (scope != "Qt" && !qualifiedNameEquals(cdef->qualified, scope) && !extraList.contains(scope))
extraList += scope;
}
}
@@ -972,9 +984,9 @@ void Generator::generateMetacall()
if (!p.notify.isEmpty() && p.notifyId != -1) {
const FunctionDef &f = cdef->signalList.at(p.notifyId);
if (f.arguments.size() == 0)
- fprintf(out, " emit %s();\n", p.notify.constData());
+ fprintf(out, " Q_EMIT %s();\n", p.notify.constData());
else if (f.arguments.size() == 1 && f.arguments.at(0).normalizedType == p.type)
- fprintf(out, " emit %s(%s%s);\n",
+ fprintf(out, " Q_EMIT %s(%s%s);\n",
p.notify.constData(), prefix.constData(), p.member.constData());
}
fprintf(out, " }\n");
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 8f4b84a9c8..06758e67bd 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -645,7 +645,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym
// 0 argument macros are a bit special. They are ok if the
// argument is pure whitespace or empty
(macro.arguments.size() != 0 || arguments.size() != 1 || !arguments.at(0).isEmpty()))
- that->error("Macro argument mismatch.");
+ that->warning("Macro argument mismatch.");
// now replace the macro arguments with the expanded arguments
enum Mode {
@@ -662,7 +662,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym
}
int index = macro.arguments.indexOf(s);
if (mode == Normal) {
- if (index >= 0) {
+ if (index >= 0 && index < arguments.size()) {
// each argument undoergoes macro expansion if it's not used as part of a # or ##
if (i == macro.symbols.size() - 1 || macro.symbols.at(i + 1).token != PP_HASHHASH) {
Symbols arg = arguments.at(index);
diff --git a/src/tools/qdoc/doc/qdoc-minimum-qdocconf.qdoc b/src/tools/qdoc/doc/qdoc-minimum-qdocconf.qdoc
new file mode 100644
index 0000000000..4289f357e9
--- /dev/null
+++ b/src/tools/qdoc/doc/qdoc-minimum-qdocconf.qdoc
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+\page qdoc-minimum-qdocconf.html
+\title A minimal qdocconf file with comments
+
+\brief Describes a minimal .qdocconf file
+
+Below you will find the full contents of qtgui.qdocconf. The subsequent section will discuss
+every statement in the qdocconf file.
+
+\code
+ #include(compat.qdocconf)
+ outputdir = html
+ headerdirs = .
+ sourcedirs = .
+ exampledirs = .
+ imagedirs = ./images
+\endcode
+
+\title Notes
+
+\code
+ #include(compat.qdocconf)
+\endcode
+
+For compatibility with older versions of Qt, it is recommended
+to include compat.qdocconf.
+
+\code
+ outputdir = html
+\endcode
+
+QDoc will put the documentation generated in the html directory.
+
+\code
+ headerdirs = .
+\endcode
+
+The header file associated with the \e .cpp source files can be found in the
+current directory.
+
+\code
+ sourcedirs = .
+\endcode
+
+The current directory is the directory containing the source files: the \e .cpp
+and \e .qdoc files used in the documentation.
+
+\code
+ exampledirs = .
+\endcode
+
+The source code of the example files can be found in the current directory.
+
+\code
+ imagedirs = ./images
+\endcode
+
+The image files can be found in the underlying directory "images".
+
+*/
diff --git a/src/tools/qdoc/doc/qtgui-qdocconf.qdoc b/src/tools/qdoc/doc/qtgui-qdocconf.qdoc
index 7e6da0feb5..767934986f 100644
--- a/src/tools/qdoc/doc/qtgui-qdocconf.qdoc
+++ b/src/tools/qdoc/doc/qtgui-qdocconf.qdoc
@@ -83,6 +83,8 @@ every statement in the qdocconf file.
sourcedirs += .. \
../../../examples/gui/doc/src
+ excludedirs = ../../../examples/gui/doc/src/tmp
+
exampledirs += ../../../examples/gui \
snippets
@@ -273,14 +275,30 @@ Add the specified directories to the list of directories containing the \e .cpp
\e .qdoc files used in the documentation.
\code
+ excludedirs = ../../../examples/gui/doc/src/tmp
+\endcode
+
+The \c excludedirs variable is for listing directories that should not be processed
+by qdoc, even if the same directories are included by the \c sourcedirs or \c headerdirs
+variables.
+
+When executed, QDoc will ignore the directories listed.
+\sa excludefiles
+
+\code
exampledirs += ../../../examples/gui \
snippets
\endcode
+\sa examples
\sa examplesinstallpath
Add the two directories specified to the list of directories containing the source
code of the example files.
+If QDoc encounters both \c exampledirs and \c examples, it will look first in the
+\c examples directory. QDoc will accept the first matching file it finds. QDoc will
+search in the directories specified, not in their subdirectories.
+
\code
imagedirs += images \
../../../examples/gui/doc/images \
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index f0846bea6b..665aa4b17a 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -900,6 +900,8 @@ void QWidgetPrivate::createTLSysExtra()
extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh));
if (extra->maxw != QWIDGETSIZE_MAX || extra->maxh != QWIDGETSIZE_MAX)
extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh));
+ if (extra->topextra->opacity != 255 && q->isWindow())
+ extra->topextra->window->setOpacity(qreal(extra->topextra->opacity) / qreal(255));
#ifdef Q_OS_WIN
// Pass on native parent handle for Widget embedded into Active X.
const QVariant activeXNativeParentHandle = q->property(activeXNativeParentHandleProperty);
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 0c1ae56349..539cc70eb7 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1330,7 +1330,6 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
break;
#ifndef QT_NO_MENU
case CE_MenuScroller: {
- p->fillRect(opt->rect, opt->palette.background());
QStyleOption arrowOpt = *opt;
arrowOpt.state |= State_Enabled;
proxy()->drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp),
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index e442e53bde..22458eb96f 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -1830,29 +1830,31 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
int gw = size.cx, gh = size.cy;
- QRect gripperBounds;
- if (flags & State_Horizontal && ((swidth - contentsMargin.cxLeftWidth - contentsMargin.cxRightWidth) > gw)) {
- gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
- gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
- gripperBounds.setWidth(gw);
- gripperBounds.setHeight(gh);
- } else if ((sheight - contentsMargin.cyTopHeight - contentsMargin.cyBottomHeight) > gh) {
- gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
- gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
- gripperBounds.setWidth(gw);
- gripperBounds.setHeight(gh);
- }
+ if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) {
+ QRect gripperBounds;
+ if (flags & State_Horizontal && ((swidth - contentsMargin.cxLeftWidth - contentsMargin.cxRightWidth) > gw)) {
+ gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
+ gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
+ gripperBounds.setWidth(gw);
+ gripperBounds.setHeight(gh);
+ } else if ((sheight - contentsMargin.cyTopHeight - contentsMargin.cyBottomHeight) > gh) {
+ gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
+ gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
+ gripperBounds.setWidth(gw);
+ gripperBounds.setHeight(gh);
+ }
- // Draw gripper if there is enough space
- if (!gripperBounds.isEmpty() && flags & State_Enabled) {
- painter->save();
- XPThemeData grippBackground = theme;
- grippBackground.partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
- theme.rect = gripperBounds;
- painter->setClipRegion(d->region(theme));// Only change inside the region of the gripper
- d->drawBackground(grippBackground);// The gutter is the grippers background
- d->drawBackground(theme); // Transparent gripper ontop of background
- painter->restore();
+ // Draw gripper if there is enough space
+ if (!gripperBounds.isEmpty() && flags & State_Enabled) {
+ painter->save();
+ XPThemeData grippBackground = theme;
+ grippBackground.partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
+ theme.rect = gripperBounds;
+ painter->setClipRegion(d->region(theme));// Only change inside the region of the gripper
+ d->drawBackground(grippBackground);// The gutter is the grippers background
+ d->drawBackground(theme); // Transparent gripper ontop of background
+ painter->restore();
+ }
}
}
}