summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-10-27 08:32:25 (GMT)
committeraxis <qt-info@nokia.com>2009-10-27 08:32:25 (GMT)
commit51bfafed59d77b791f0266fa1bfc36634597c5c4 (patch)
tree630d9fbc5aad375950b03d80cf775c228f31a741 /src
parentcb3a2633bb9d8a0e949c403d0f0631caef254599 (diff)
parent5a4909d9f87b9abf471908a085c0e9f31b7e0a50 (diff)
downloadQt-51bfafed59d77b791f0266fa1bfc36634597c5c4.zip
Qt-51bfafed59d77b791f0266fa1bfc36634597c5c4.tar.gz
Qt-51bfafed59d77b791f0266fa1bfc36634597c5c4.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp40
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp128
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h86
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp96
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp17
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp2
-rw-r--r--src/corelib/global/qnamespace.qdoc3
-rw-r--r--src/gui/dialogs/qfiledialog_mac.mm4
-rw-r--r--src/gui/dialogs/qwizard.cpp2
-rw-r--r--src/gui/dialogs/qwizard_win.cpp2
-rw-r--r--src/gui/effects/qgraphicseffect_p.h2
-rw-r--r--src/gui/embedded/qdecorationdefault_qws.cpp2
-rw-r--r--src/gui/embedded/qdecorationwindows_qws.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.cpp122
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp21
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicstransform.cpp4
-rw-r--r--src/gui/image/qpixmap.cpp3
-rw-r--r--src/gui/itemviews/qheaderview.cpp2
-rw-r--r--src/gui/kernel/qapplication_win.cpp2
-rw-r--r--src/gui/kernel/qgesture.cpp6
-rw-r--r--src/gui/kernel/qgesturerecognizer.cpp2
-rw-r--r--src/gui/kernel/qstandardgestures.cpp1
-rw-r--r--src/gui/kernel/qwidget.cpp2
-rw-r--r--src/gui/kernel/qwidget_mac.mm2
-rw-r--r--src/gui/kernel/qwidget_win.cpp4
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp130
-rw-r--r--src/gui/math3d/qmatrix4x4.h7
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp2
-rw-r--r--src/gui/styles/qcommonstyle.cpp6
-rw-r--r--src/gui/styles/qmotifstyle.cpp4
-rw-r--r--src/gui/styles/qplastiquestyle.cpp8
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp2
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp31
-rw-r--r--src/gui/text/qfont.cpp2
-rw-r--r--src/gui/text/qfont_p.h2
-rw-r--r--src/gui/text/qfontdatabase.cpp2
-rw-r--r--src/gui/text/qfontdatabase_win.cpp12
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp14
-rw-r--r--src/gui/text/qfontengine_ft.cpp10
-rw-r--r--src/gui/text/qfontengine_qpf.cpp2
-rw-r--r--src/gui/text/qfontengine_win.cpp4
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp5
-rw-r--r--src/gui/text/qtextengine.cpp22
-rw-r--r--src/gui/text/qtextengine_mac.cpp2
-rw-r--r--src/gui/text/qtextengine_p.h17
-rw-r--r--src/gui/text/qtextlayout.cpp76
-rw-r--r--src/gui/text/qtextlayout.h4
-rw-r--r--src/gui/text/text.pri1
-rw-r--r--src/gui/widgets/qcombobox.cpp2
-rw-r--r--src/gui/widgets/qdockwidget.cpp2
-rw-r--r--src/gui/widgets/qfontcombobox.cpp2
-rw-r--r--src/gui/widgets/qlineedit.cpp2
-rw-r--r--src/gui/widgets/qplaintextedit.cpp5
-rw-r--r--src/network/ssl/qsslsocket.cpp6
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp1
-rw-r--r--src/opengl/qglshaderprogram.cpp358
-rw-r--r--src/opengl/qglshaderprogram.h8
-rw-r--r--src/opengl/qwindowsurface_gl.cpp2
-rw-r--r--src/opengl/qwindowsurface_x11gl.cpp3
-rw-r--r--src/openvg/qpaintengine_vg.cpp98
-rw-r--r--src/qt3support/widgets/q3dockwindow.cpp2
-rw-r--r--src/script/api/qscriptengine.cpp112
-rw-r--r--src/script/api/qscriptengine_p.h91
-rw-r--r--src/script/api/qscriptstring.cpp3
-rw-r--r--src/script/api/qscriptstring_p.h7
-rw-r--r--src/script/api/qscriptvalue.cpp105
-rw-r--r--src/script/api/qscriptvalue_p.h17
-rw-r--r--src/script/bridge/qscriptclassobject.cpp11
-rw-r--r--src/script/bridge/qscriptclassobject_p.h15
-rw-r--r--src/script/bridge/qscriptobject.cpp30
-rw-r--r--src/script/bridge/qscriptobject_p.h38
-rw-r--r--src/sql/drivers/oci/qsql_oci.cpp11
73 files changed, 1259 insertions, 596 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp
index 90ea807..457518c 100644
--- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp
@@ -75,12 +75,25 @@ namespace JSC {
#define THUMB_FUNC_PARAM(name)
#endif
-#if PLATFORM(LINUX) && PLATFORM(X86_64)
+#if PLATFORM(LINUX) && (PLATFORM(X86_64) || PLATFORM(X86))
#define SYMBOL_STRING_RELOCATION(name) #name "@plt"
#else
#define SYMBOL_STRING_RELOCATION(name) SYMBOL_STRING(name)
#endif
+#if PLATFORM(DARWIN)
+ // Mach-O platform
+#define HIDE_SYMBOL(name) ".private_extern _" #name
+#elif PLATFORM(AIX)
+ // IBM's own file format
+#define HIDE_SYMBOL(name) ".lglobl " #name
+#elif PLATFORM(LINUX) || PLATFORM(FREEBSD) || PLATFORM(OPENBSD) || PLATFORM(SOLARIS) || (PLATFORM(HPUX) && PLATFORM(IA64)) || PLATFORM(SYMBIAN) || PLATFORM(NETBSD)
+ // ELF platform
+#define HIDE_SYMBOL(name) ".hidden " #name
+#else
+#define HIDE_SYMBOL(name)
+#endif
+
#if USE(JSVALUE32_64)
#if COMPILER(GCC) && PLATFORM(X86)
@@ -93,7 +106,9 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_
COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline);
asm volatile (
+".text\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+HIDE_SYMBOL(ctiTrampoline) "\n"
SYMBOL_STRING(ctiTrampoline) ":" "\n"
"pushl %ebp" "\n"
"movl %esp, %ebp" "\n"
@@ -114,6 +129,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
#if !USE(JIT_STUB_ARGUMENT_VA_LIST)
"movl %esp, %ecx" "\n"
@@ -129,6 +145,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
"addl $0x3c, %esp" "\n"
"popl %ebx" "\n"
@@ -153,6 +170,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_
asm volatile (
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+HIDE_SYMBOL(ctiTrampoline) "\n"
SYMBOL_STRING(ctiTrampoline) ":" "\n"
"pushq %rbp" "\n"
"movq %rsp, %rbp" "\n"
@@ -179,6 +197,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"movq %rsp, %rdi" "\n"
"call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
@@ -194,6 +213,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
"addq $0x48, %rsp" "\n"
"popq %rbx" "\n"
@@ -215,6 +235,7 @@ asm volatile (
".text" "\n"
".align 2" "\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+HIDE_SYMBOL(ctiTrampoline) "\n"
".thumb" "\n"
".thumb_func " THUMB_FUNC_PARAM(ctiTrampoline) "\n"
SYMBOL_STRING(ctiTrampoline) ":" "\n"
@@ -241,6 +262,7 @@ asm volatile (
".text" "\n"
".align 2" "\n"
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
".thumb" "\n"
".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
@@ -346,7 +368,9 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_
COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
asm volatile (
+".text\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+HIDE_SYMBOL(ctiTrampoline) "\n"
SYMBOL_STRING(ctiTrampoline) ":" "\n"
"pushl %ebp" "\n"
"movl %esp, %ebp" "\n"
@@ -367,6 +391,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
#if !USE(JIT_STUB_ARGUMENT_VA_LIST)
"movl %esp, %ecx" "\n"
@@ -382,6 +407,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
"addl $0x1c, %esp" "\n"
"popl %ebx" "\n"
@@ -404,7 +430,9 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x48, JITStackFrame_code_
COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x78, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
asm volatile (
+".text\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+HIDE_SYMBOL(ctiTrampoline) "\n"
SYMBOL_STRING(ctiTrampoline) ":" "\n"
"pushq %rbp" "\n"
"movq %rsp, %rbp" "\n"
@@ -438,6 +466,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"movq %rsp, %rdi" "\n"
"call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
@@ -453,6 +482,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
"addq $0x78, %rsp" "\n"
"popq %rbx" "\n"
@@ -474,6 +504,7 @@ asm volatile (
".text" "\n"
".align 2" "\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+HIDE_SYMBOL(ctiTrampoline) "\n"
".thumb" "\n"
".thumb_func " THUMB_FUNC_PARAM(ctiTrampoline) "\n"
SYMBOL_STRING(ctiTrampoline) ":" "\n"
@@ -500,6 +531,7 @@ asm volatile (
".text" "\n"
".align 2" "\n"
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
".thumb" "\n"
".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
@@ -517,6 +549,7 @@ asm volatile (
".text" "\n"
".align 2" "\n"
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
".thumb" "\n"
".thumb_func " THUMB_FUNC_PARAM(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
@@ -531,7 +564,9 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
#elif COMPILER(GCC) && PLATFORM(ARM_TRADITIONAL)
asm volatile (
+".text\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+HIDE_SYMBOL(ctiTrampoline) "\n"
SYMBOL_STRING(ctiTrampoline) ":" "\n"
"stmdb sp!, {r1-r3}" "\n"
"stmdb sp!, {r4-r8, lr}" "\n"
@@ -555,6 +590,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
asm volatile (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"mov r0, sp" "\n"
"mov lr, r6" "\n"
@@ -564,6 +600,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
// Both has the same return sequence
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
"add sp, sp, #32" "\n"
"ldmia sp!, {r4-r8, lr}" "\n"
@@ -898,6 +935,7 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD
".text" "\n" \
".align 2" "\n" \
".globl " SYMBOL_STRING(cti_##op) "\n" \
+ HIDE_SYMBOL(cti_##op) "\n" \
".thumb" "\n" \
".thumb_func " THUMB_FUNC_PARAM(cti_##op) "\n" \
SYMBOL_STRING(cti_##op) ":" "\n" \
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp
index 3749eed..a588ab1 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp
@@ -1,64 +1,64 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSExceptionBase.h"
-
-#include "JSDOMCoreException.h"
-#include "JSEventException.h"
-#include "JSRangeException.h"
-#include "JSXMLHttpRequestException.h"
-#if ENABLE(SVG)
-#include "JSSVGException.h"
-#endif
-#if ENABLE(XPATH)
-#include "JSXPathException.h"
-#endif
-
-namespace WebCore {
-
-ExceptionBase* toExceptionBase(JSC::JSValue value)
-{
- if (DOMCoreException* domException = toDOMCoreException(value))
- return reinterpret_cast<ExceptionBase*>(domException);
- if (RangeException* rangeException = toRangeException(value))
- return reinterpret_cast<ExceptionBase*>(rangeException);
- if (EventException* eventException = toEventException(value))
- return reinterpret_cast<ExceptionBase*>(eventException);
- if (XMLHttpRequestException* xmlHttpException = toXMLHttpRequestException(value))
- return reinterpret_cast<ExceptionBase*>(xmlHttpException);
-#if ENABLE(SVG)
- if (SVGException* svgException = toSVGException(value))
- return reinterpret_cast<ExceptionBase*>(svgException);
-#endif
-#if ENABLE(XPATH)
- if (XPathException* pathException = toXPathException(value))
- return reinterpret_cast<ExceptionBase*>(pathException);
-#endif
-
- return 0;
-}
-
-} // namespace WebCore
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSExceptionBase.h"
+
+#include "JSDOMCoreException.h"
+#include "JSEventException.h"
+#include "JSRangeException.h"
+#include "JSXMLHttpRequestException.h"
+#if ENABLE(SVG)
+#include "JSSVGException.h"
+#endif
+#if ENABLE(XPATH)
+#include "JSXPathException.h"
+#endif
+
+namespace WebCore {
+
+ExceptionBase* toExceptionBase(JSC::JSValue value)
+{
+ if (DOMCoreException* domException = toDOMCoreException(value))
+ return reinterpret_cast<ExceptionBase*>(domException);
+ if (RangeException* rangeException = toRangeException(value))
+ return reinterpret_cast<ExceptionBase*>(rangeException);
+ if (EventException* eventException = toEventException(value))
+ return reinterpret_cast<ExceptionBase*>(eventException);
+ if (XMLHttpRequestException* xmlHttpException = toXMLHttpRequestException(value))
+ return reinterpret_cast<ExceptionBase*>(xmlHttpException);
+#if ENABLE(SVG)
+ if (SVGException* svgException = toSVGException(value))
+ return reinterpret_cast<ExceptionBase*>(svgException);
+#endif
+#if ENABLE(XPATH)
+ if (XPathException* pathException = toXPathException(value))
+ return reinterpret_cast<ExceptionBase*>(pathException);
+#endif
+
+ return 0;
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h b/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h
index 01c6ac2..a9366ed 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h
@@ -1,43 +1,43 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JSExceptionBase_h
-#define JSExceptionBase_h
-
-namespace JSC {
-
-class JSValue;
-
-} // namespace JSC
-
-namespace WebCore {
-
-class ExceptionBase;
-
-ExceptionBase* toExceptionBase(JSC::JSValue);
-
-} // namespace WebCore
-
-#endif // JSExceptionBase_h
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSExceptionBase_h
+#define JSExceptionBase_h
+
+namespace JSC {
+
+class JSValue;
+
+} // namespace JSC
+
+namespace WebCore {
+
+class ExceptionBase;
+
+ExceptionBase* toExceptionBase(JSC::JSValue);
+
+} // namespace WebCore
+
+#endif // JSExceptionBase_h
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
index 7e485a0..0cb4204 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
@@ -164,17 +164,101 @@ void QGraphicsWebViewPrivate::_q_setStatusBarMessage(const QString& s)
/*!
\class QGraphicsWebView
- \brief The QGraphicsWebView class allows web content to be added to a GraphicsView.
+ \brief The QGraphicsWebView class allows Web content to be added to a GraphicsView.
\since 4.6
- A WebGraphicsItem renders web content based on a URL or set data.
+ An instance of this class renders Web content from a URL or supplied as data, using
+ features of the QtWebKit module.
- If the width and height of the item is not set, they will
- dynamically adjust to a size appropriate for the content.
- This width may be large (eg. 980) for typical online web pages.
+ If the width and height of the item is not set, they will dynamically adjust to
+ a size appropriate for the content. This width may be large (e.g., 980 pixels or
+ more) for typical online Web pages.
+
+ \section1 Browser Features
+
+ Many of the functions, signals and properties provided by QWebView are also available
+ for this item, making it simple to adapt existing code to use QGraphicsWebView instead
+ of QWebView.
+
+ The item uses a QWebPage object to perform the rendering of Web content, and this can
+ be obtained with the page() function, enabling the document itself to be accessed and
+ modified.
+
+ As with QWebView, the item records the browsing history using a QWebHistory object,
+ accessible using the history() function. The QWebSettings object that defines the
+ configuration of the browser can be obtained with the settings() function, enabling
+ features like plugin support to be customized for each item.
+
+ \sa QWebView, QGraphicsTextItem
+*/
+
+/*!
+ \fn void QGraphicsWebView::titleChanged(const QString &title)
+
+ This signal is emitted whenever the \a title of the main frame changes.
+
+ \sa title()
+*/
+
+/*!
+ \fn void QGraphicsWebView::urlChanged(const QUrl &url)
+
+ This signal is emitted when the \a url of the view changes.
+
+ \sa url(), load()
+*/
+
+/*!
+ \fn void QGraphicsWebView::statusChanged()
+
+ This signal is emitted when the status bar text is changed by the page.
+*/
+
+/*!
+ \fn void QGraphicsWebView::iconChanged()
+
+ This signal is emitted whenever the icon of the page is loaded or changes.
+
+ In order for icons to be loaded, you will need to set an icon database path
+ using QWebSettings::setIconDatabasePath().
+
+ \sa icon(), QWebSettings::setIconDatabasePath()
+*/
+
+/*!
+ \fn void QGraphicsWebView::loadStarted()
+
+ This signal is emitted when a new load of the page is started.
+
+ \sa progressChanged(), loadFinished()
+*/
+
+/*!
+ \fn void QGraphicsWebView::loadFinished(bool ok)
+
+ This signal is emitted when a load of the page is finished.
+ \a ok will indicate whether the load was successful or any error occurred.
+
+ \sa loadStarted()
*/
/*!
+ \fn void QGraphicsWebView::progressChanged(qreal progress)
+
+ This signal is emitted every time an element in the web page
+ completes loading and the overall loading progress advances.
+
+ This signal tracks the progress of all child frames.
+
+ The current value is provided by \a progress and scales from 0.0 to 1.0,
+ which is the default range of QProgressBar.
+
+ \sa loadStarted(), loadFinished()
+*/
+
+
+
+/*!
Constructs an empty QGraphicsWebView with parent \a parent.
\sa load()
@@ -191,7 +275,7 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent)
}
/*!
- Destroys the web graphicsitem.
+ Destroys the item.
*/
QGraphicsWebView::~QGraphicsWebView()
{
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
index 31d193e..764bfad 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
@@ -2652,6 +2652,17 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos)
as a result of the user clicking on a "file upload" button in a HTML form where multiple
file selection is allowed.
+ \omitvalue ErrorPageExtension (introduced in Qt 4.6)
+*/
+
+/*!
+ \enum QWebPage::ErrorDomain
+ \since 4.6
+ \internal
+
+ \value QtNetwork
+ \value Http
+ \value WebKit
*/
/*!
@@ -2702,6 +2713,12 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos)
*/
/*!
+ \fn QWebPage::ErrorPageExtensionReturn::ErrorPageExtensionReturn()
+
+ Constructs a new error page object.
+*/
+
+/*!
\class QWebPage::ChooseMultipleFilesExtensionOption
\since 4.5
\brief The ChooseMultipleFilesExtensionOption class describes the option
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
index 95d7183..cb487ce 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
@@ -1110,7 +1110,7 @@ void QWebView::changeEvent(QEvent *e)
/*!
\fn void QWebView::statusBarMessage(const QString& text)
- This signal is emitted when the statusbar \a text is changed by the page.
+ This signal is emitted when the status bar \a text is changed by the page.
*/
/*!
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index e8d6df0..5f9d01d 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2841,6 +2841,9 @@
\value WidgetGesture Gestures can only start over the widget itself.
\value WidgetWithChildrenGesture Gestures can start on the widget or over
any of its children.
+ \value ItemGesture Gestures can only start over the item itself.
+ \value ItemWithChildrenGesture Gestures can start on the item or over
+ any of its children.
\sa QWidget::grabGesture()
*/
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm
index 8e4c461..d9bec27 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/gui/dialogs/qfiledialog_mac.mm
@@ -280,6 +280,10 @@ QT_USE_NAMESPACE
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
{
Q_UNUSED(sender);
+
+ if ([filename length] == 0)
+ return NO;
+
QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename);
QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C)));
QString path = info.absolutePath();
diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp
index 0102e25..db1c9e9 100644
--- a/src/gui/dialogs/qwizard.cpp
+++ b/src/gui/dialogs/qwizard.cpp
@@ -1537,7 +1537,9 @@ void QWizardPrivate::handleAeroStyleChange()
vistaHelper->backButton()->show();
} else {
q->setMouseTracking(true); // ### original value possibly different
+#ifndef QT_NO_CURSOR
q->unsetCursor(); // ### ditto
+#endif
antiFlickerWidget->move(0, 0);
vistaHelper->hideBackButton();
vistaHelper->setTitleBarIconAndCaptionVisible(true);
diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp
index aa38ddc..f3f3a4e 100644
--- a/src/gui/dialogs/qwizard_win.cpp
+++ b/src/gui/dialogs/qwizard_win.cpp
@@ -387,10 +387,12 @@ bool QVistaHelper::winEvent(MSG* msg, long* result)
void QVistaHelper::setMouseCursor(QPoint pos)
{
+#ifndef QT_NO_CURSOR
if (rtTop.contains(pos))
wizard->setCursor(Qt::SizeVerCursor);
else
wizard->setCursor(Qt::ArrowCursor);
+#endif
}
void QVistaHelper::mouseEvent(QEvent *event)
diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h
index 8fb55d8..fc925f2 100644
--- a/src/gui/effects/qgraphicseffect_p.h
+++ b/src/gui/effects/qgraphicseffect_p.h
@@ -102,8 +102,8 @@ public:
QGraphicsEffect::ChangeFlags flags;
if (source) {
flags |= QGraphicsEffect::SourceDetached;
- source->d_func()->detach();
source->d_func()->invalidateCache();
+ source->d_func()->detach();
delete source;
}
source = newSource;
diff --git a/src/gui/embedded/qdecorationdefault_qws.cpp b/src/gui/embedded/qdecorationdefault_qws.cpp
index 5bc8826..70389d3 100644
--- a/src/gui/embedded/qdecorationdefault_qws.cpp
+++ b/src/gui/embedded/qdecorationdefault_qws.cpp
@@ -394,7 +394,7 @@ QPixmap QDecorationDefault::pixmapFor(const QWidget *widget,
*/
int QDecorationDefault::titleBarHeight(const QWidget *)
{
- return qMax(20, QApplication::fontMetrics().lineSpacing() + BORDER_WIDTH);
+ return qMax(20, QApplication::fontMetrics().height() + BORDER_WIDTH);
}
/*!
diff --git a/src/gui/embedded/qdecorationwindows_qws.cpp b/src/gui/embedded/qdecorationwindows_qws.cpp
index 77393cf..7764ca5 100644
--- a/src/gui/embedded/qdecorationwindows_qws.cpp
+++ b/src/gui/embedded/qdecorationwindows_qws.cpp
@@ -216,7 +216,7 @@ QRegion QDecorationWindows::region(const QWidget *widget, const QRect &rect, int
bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
const QFontMetrics fontMetrics = QApplication::fontMetrics();
- int titleHeight = hasTitle ? qMax(20, fontMetrics.lineSpacing()) : 0;
+ int titleHeight = hasTitle ? qMax(20, fontMetrics.height()) : 0;
int state = widget->windowState();
bool isMinimized = state & Qt::WindowMinimized;
bool isMaximized = state & Qt::WindowMaximized;
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
index 081572f..e21cd99 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
@@ -48,36 +48,60 @@
\ingroup geomanagement
\ingroup graphicsview-api
- The anchor layout is a layout where one can specify how widgets should be placed relative to
- each other. The specification is called an anchor, and it is set up by calling anchor().
+ The anchor layout allows developers to specify how widgets should be placed relative to
+ each other, and to the layout itself. The specification is made by adding anchors to the
+ layout by calling addAnchor(), addAnchors() or addCornerAnchors().
+
+ Existing anchors in the layout can be accessed with the anchor() function.
+ Items that are anchored are automatically added to the layout, and if items
+ are removed, all their anchors will be automatically removed.
+
+ \beginfloatleft
+ \inlineimage simpleanchorlayout-example.png Using an anchor layout to align simple colored widgets.
+ \endfloat
+
Anchors are always set up between edges of an item, where the "center" is also considered to
- be an edge. Considering this example:
- \code
- QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
- QGraphicsWidget *a = new QGraphicsWidget;
- QGraphicsWidget *b = new QGraphicsWidget;
- l->anchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
- \endcode
-
- Here is the right edge of item A anchored to the left edge of item B, with the result that
- item B will be placed to the right of item A, with a spacing between A and B. If the
- spacing is negative, the items will overlap to some extent. Items that are anchored are
- automatically added to the layout, and if items are removed, all their anchors will be
- automatically removed
-
- \section1 Size Hints and Size Policies in QGraphicsAnchorLayout
+ be an edge. Consider the following example:
+
+ \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding anchors
+
+ Here, the right edge of item \c a is anchored to the left edge of item \c b and the bottom
+ edge of item \c a is anchored to the top edge of item \c b, with the result that
+ item \c b will be placed diagonally to the right and below item \c b.
+
+ The addCornerAnchors() function provides a simpler way of anchoring the corners
+ of two widgets than the two individual calls to addAnchor() shown in the code
+ above. Here, we see how a widget can be anchored to the top-left corner of the enclosing
+ layout:
+
+ \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding a corner anchor
+
+ In cases where anchors are used to match the widths or heights of widgets, it is
+ convenient to use the addAnchors() function. As with the other functions for specifying
+ anchors, it can also be used to anchor a widget to a layout.
+
+ \clearfloat
+ \section1 Size Hints and Size Policies in an Anchor Layout
QGraphicsAnchorLayout respects each item's size hints and size policies. However it does
- not respect stretch factors currently. This might change in the future, so please refrain
- from using stretch factors in anchor layout to avoid any future regressions.
+ not currently respect their stretch factors. This might change in the future, so avoid
+ using stretch factors in anchor layouts if you want to avoid any future regressions in
+ behavior.
+
+ \section1 Spacing within an Anchor Layout
+
+ The layout may distribute some space between the items. If the spacing has not been
+ explicitly specified, the actual amount of space will usually be 0.
+
+ However, if the first edge is the \e opposite of the second edge (e.g., the right edge
+ of the first widget is anchored to the left edge of the second widget), the size of the
+ anchor will be queried from the style through a pixel metric:
+ \l{QStyle::}{PM_LayoutHorizontalSpacing} for horizontal anchors and
+ \l{QStyle::}{PM_LayoutVerticalSpacing} for vertical anchors.
- \section1 Spacing within QGraphicsAnchorLayout
+ If the spacing is negative, the items will overlap to some extent.
- Between the items, the layout can distribute some space. If the spacing has not been
- explicitly specified, the actual amount of space will usually be 0, but if the first edge
- is the "opposite" of the second edge (i.e. Right is anchored to Left or vice-versa), the
- size of the anchor will be queried from the style through the pixelMetric
- PM_LayoutHorizontalSpacing (or PM_LayoutVerticalSpacing for vertical anchors).
+ \sa QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsLayout
*/
/*!
@@ -215,7 +239,7 @@ QGraphicsAnchorLayout::~QGraphicsAnchorLayout()
If there is already an anchor between the edges, the the new anchor will replace the old one.
\a firstItem and \a secondItem are automatically added to the layout if they are not part
- of the layout. This means that count() can increase with up to 2.
+ of the layout. This means that count() can increase by up to 2.
The spacing an anchor will get depends on the type of anchor. For instance, anchors from the
Right edge of one item to the Left edge of another (or vice versa) will use the default
@@ -228,7 +252,7 @@ QGraphicsAnchorLayout::~QGraphicsAnchorLayout()
Calling this function where \a firstItem or \a secondItem are ancestors of the layout have
undefined behaviour.
- \sa addCornerAnchors(), addAnchors()
+ \sa addAnchors(), addCornerAnchors()
*/
QGraphicsAnchor *
QGraphicsAnchorLayout::addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
@@ -253,29 +277,26 @@ QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint fi
}
/*!
- Creates two anchors between \a firstItem and \a secondItem, where one is for the horizontal
- edge and another one for the vertical edge that the corners \a firstCorner and \a
- secondCorner specifies.
- The magnitude of the anchors is picked up from the style.
+ Creates two anchors between \a firstItem and \a secondItem specified by the corners,
+ \a firstCorner and \a secondCorner, where one is for the horizontal edge and another
+ one for the vertical edge.
- This is a convenience function, since anchoring corners can be expressed as anchoring two edges.
- For instance,
- \code
- layout->addAnchor(layout, Qt::AnchorTop, b, Qt::AnchorTop);
- layout->addAnchor(layout, Qt::AnchorLeft, b, Qt::AnchorLeft);
- \endcode
+ This is a convenience function, since anchoring corners can be expressed as anchoring
+ two edges. For instance:
- has the same effect as
+ \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding a corner anchor in two steps
- \code
- layout->addCornerAnchors(layout, Qt::TopLeft, b, Qt::TopLeft);
- \endcode
+ This can also be achieved with the following line of code:
+
+ \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding a corner anchor
If there is already an anchor between the edge pairs, it will be replaced by the anchors that
this function specifies.
\a firstItem and \a secondItem are automatically added to the layout if they are not part of the
- layout. This means that count() can increase with up to 2.
+ layout. This means that count() can increase by up to 2.
+
+ \sa addAnchor(), addAnchors()
*/
void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem,
Qt::Corner firstCorner,
@@ -302,17 +323,16 @@ void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem,
edges of \a secondItem, so that \a firstItem has the same size as
\a secondItem in the dimensions specified by \a orientations.
- Calling this convenience function with the following arguments
- \code
- l->addAnchors(firstItem, secondItem, Qt::Horizontal)
- \endcode
+ For example, the following example anchors the left and right edges of two items
+ to match their widths:
+
+ \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding anchors to match sizes in two steps
+
+ This can also be achieved using the following line of code:
- is the same as
+ \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding anchors to match sizes
- \code
- l->addAnchor(firstItem, Qt::AnchorLeft, secondItem, Qt::AnchorLeft);
- l->addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
- \endcode
+ \sa addAnchor(), addCornerAnchors()
*/
void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem,
QGraphicsLayoutItem *secondItem,
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 97979e5..edd2d7c 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1228,7 +1228,8 @@ void QGraphicsItemCache::purge()
}
/*!
- Constructs a QGraphicsItem with the given \a parent.
+ Constructs a QGraphicsItem, passing \a item to QGraphicsItem's constructor.
+ It does not modify the parent object returned by QObject::parent().
If \a parent is 0, you can add the item to a scene by calling
QGraphicsScene::addItem(). The item will then become a top-level item.
@@ -7283,6 +7284,21 @@ static void qt_graphicsItem_highlightSelected(
The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms.
It maps many of QGraphicsItem's basic setters and getters to properties and adds notification
signals for many of them.
+
+ \section1 Parents and Children
+
+ Each graphics object can be constructed with a parent item. This ensures that the
+ item will be destroyed when its parent item is destroyed. Although QGraphicsObject
+ inherits from both QObject and QGraphicsItem, you should use the functions provided
+ by QGraphicsItem, \e not QObject, to manage the relationships between parent and
+ child items.
+
+ The relationships between items can be explored using the parentItem() and childItems()
+ functions. In the hierarchy of items in a scene, the parentObject() and parentWidget()
+ functions are the equivalent of the QWidget::parent() and QWidget::parentWidget()
+ functions for QWidget subclasses.
+
+ \sa QGraphicsWidget
*/
/*!
@@ -7320,6 +7336,9 @@ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext co
\property QGraphicsObject::parent
\brief the parent of the item
+ \note The item's parent is set independently of the parent object returned
+ by QObject::parent().
+
\sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject()
*/
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 046f5dc..7c3c4f0 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -542,7 +542,7 @@ struct QGraphicsItemPrivate::TransformData
QMatrix4x4 m;
for (int i = 0; i < graphicsTransforms.size(); ++i)
graphicsTransforms.at(i)->applyTo(&m);
- x *= m.toTransform(0);
+ x *= m.toTransform();
}
x.translate(xOrigin, yOrigin);
x.rotate(rotation);
diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp
index 49d8999..93dc196 100644
--- a/src/gui/graphicsview/qgraphicstransform.cpp
+++ b/src/gui/graphicsview/qgraphicstransform.cpp
@@ -547,9 +547,7 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const
return;
matrix->translate(d->origin);
- QMatrix4x4 m;
- m.rotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z());
- *matrix *= m.toTransform();
+ matrix->projectedRotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z());
matrix->translate(-d->origin);
}
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index a3b7516..45ff5f4 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -860,6 +860,9 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags)
{
+ if (len == 0 || buf == 0)
+ return false;
+
return data->fromData(buf, len, format, flags);
}
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index fc9820f..3bd9a19 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1419,7 +1419,7 @@ int QHeaderView::minimumSectionSize() const
int margin = style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
if (d->orientation == Qt::Horizontal)
return qMax(strut.width(), (fontMetrics().maxWidth() + margin));
- return qMax(strut.height(), (fontMetrics().lineSpacing() + margin));
+ return qMax(strut.height(), (fontMetrics().height() + margin));
}
return d->minimumSectionSize;
}
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 5bb25fa..e84985e 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -615,6 +615,8 @@ static void qt_set_windows_font_resources()
if (qt_wince_is_mobile()) {
smallerFont.setPointSize(systemFont.pointSize()-1);
QApplication::setFont(smallerFont, "QTabBar");
+ smallerFont.setBold(true);
+ QApplication::setFont(smallerFont, "QAbstractButton");
}
#endif// Q_WS_WINCE
}
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index ecdd661..a161876 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -142,12 +142,6 @@ QGesture::~QGesture()
\brief whether the gesture has a hot-spot
*/
-/*!
- \property QGesture::targetObject
- \brief the target object which will receive the gesture event if the hotSpot is
- not set
-*/
-
Qt::GestureType QGesture::gestureType() const
{
return d_func()->gestureType;
diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp
index 9de3bcc..ba3a750 100644
--- a/src/gui/kernel/qgesturerecognizer.cpp
+++ b/src/gui/kernel/qgesturerecognizer.cpp
@@ -186,7 +186,7 @@ void QGestureRecognizer::reset(QGesture *gesture)
\fn QGestureRecognizer::filterEvent(QGesture *gesture, QObject *watched, QEvent *event)
Handles the given \a event for the \a watched object, updating the state of the \a gesture
- object as required, and returns a suitable Result for the current recognition step.
+ object as required, and returns a suitable result for the current recognition step.
This function is called by the framework to allow the recognizer to filter input events
dispatched to QWidget or QGraphicsObject instances that it is monitoring.
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index a136379..dec2311 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -140,7 +140,6 @@ void QPanGestureRecognizer::reset(QGesture *state)
QGestureRecognizer::reset(state);
}
-/*! \internal */
/*
bool QPanGestureRecognizer::event(QEvent *event)
{
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 102f4c9..5fa9a92 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -7320,7 +7320,7 @@ void QWidget::setVisible(bool visible)
break;
parent = parent->parentWidget();
}
- if (parent && !d->getOpaqueRegion().isEmpty())
+ if (parent)
parent->d_func()->setDirtyOpaqueRegion();
}
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 05c6a5b..d08f8a9 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3048,6 +3048,7 @@ void QWidget::grabMouse()
}
}
+#ifndef QT_NO_CURSOR
void QWidget::grabMouse(const QCursor &)
{
if(isVisible() && !qt_nograb()) {
@@ -3056,6 +3057,7 @@ void QWidget::grabMouse(const QCursor &)
mac_mouse_grabber=this;
}
}
+#endif
void QWidget::releaseMouse()
{
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 2b11bec..fa12b0d 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -851,10 +851,13 @@ void QWidget::grabMouse()
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
SetCapture(effectiveWinId());
mouseGrb = this;
+#ifndef QT_NO_CURSOR
mouseGrbCur = new QCursor(mouseGrb->cursor());
+#endif
}
}
+#ifndef QT_NO_CURSOR
void QWidget::grabMouse(const QCursor &cursor)
{
if (!qt_nograb()) {
@@ -868,6 +871,7 @@ void QWidget::grabMouse(const QCursor &cursor)
mouseGrb = this;
}
}
+#endif
void QWidget::releaseMouse()
{
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index ed1b13d..5d624d8 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE
\sa QVector3D, QGenericMatrix
*/
+static const qreal inv_dist_to_plane = 1. / 1024.;
+
/*!
\fn QMatrix4x4::QMatrix4x4()
@@ -1103,7 +1105,111 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
return *this;
}
-#ifndef QT_NO_VECTOR4D
+/*!
+ \internal
+*/
+QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z)
+{
+ // Used by QGraphicsRotation::applyTo() to perform a rotation
+ // and projection back to 2D in a single step.
+ if (angle == 0.0f)
+ return *this;
+ QMatrix4x4 m(1); // The "1" says to not load the identity.
+ qreal c, s, ic;
+ if (angle == 90.0f || angle == -270.0f) {
+ s = 1.0f;
+ c = 0.0f;
+ } else if (angle == -90.0f || angle == 270.0f) {
+ s = -1.0f;
+ c = 0.0f;
+ } else if (angle == 180.0f || angle == -180.0f) {
+ s = 0.0f;
+ c = -1.0f;
+ } else {
+ qreal a = angle * M_PI / 180.0f;
+ c = qCos(a);
+ s = qSin(a);
+ }
+ bool quick = false;
+ if (x == 0.0f) {
+ if (y == 0.0f) {
+ if (z != 0.0f) {
+ // Rotate around the Z axis.
+ m.setIdentity();
+ m.m[0][0] = c;
+ m.m[1][1] = c;
+ if (z < 0.0f) {
+ m.m[1][0] = s;
+ m.m[0][1] = -s;
+ } else {
+ m.m[1][0] = -s;
+ m.m[0][1] = s;
+ }
+ m.flagBits = General;
+ quick = true;
+ }
+ } else if (z == 0.0f) {
+ // Rotate around the Y axis.
+ m.setIdentity();
+ m.m[0][0] = c;
+ m.m[2][2] = 1.0f;
+ if (y < 0.0f) {
+ m.m[0][3] = -s * inv_dist_to_plane;
+ } else {
+ m.m[0][3] = s * inv_dist_to_plane;
+ }
+ m.flagBits = General;
+ quick = true;
+ }
+ } else if (y == 0.0f && z == 0.0f) {
+ // Rotate around the X axis.
+ m.setIdentity();
+ m.m[1][1] = c;
+ m.m[2][2] = 1.0f;
+ if (x < 0.0f) {
+ m.m[1][3] = s * inv_dist_to_plane;
+ } else {
+ m.m[1][3] = -s * inv_dist_to_plane;
+ }
+ m.flagBits = General;
+ quick = true;
+ }
+ if (!quick) {
+ qreal len = x * x + y * y + z * z;
+ if (!qFuzzyIsNull(len - 1.0f) && !qFuzzyIsNull(len)) {
+ len = qSqrt(len);
+ x /= len;
+ y /= len;
+ z /= len;
+ }
+ ic = 1.0f - c;
+ m.m[0][0] = x * x * ic + c;
+ m.m[1][0] = x * y * ic - z * s;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = y * x * ic + z * s;
+ m.m[1][1] = y * y * ic + c;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = 1.0f;
+ m.m[3][2] = 0.0f;
+ m.m[0][3] = (x * z * ic - y * s) * -inv_dist_to_plane;
+ m.m[1][3] = (y * z * ic + x * s) * -inv_dist_to_plane;
+ m.m[2][3] = 0.0f;
+ m.m[3][3] = 1.0f;
+ }
+ int flags = flagBits;
+ *this *= m;
+ if (flags != Identity)
+ flagBits = flags | Rotation;
+ else
+ flagBits = Rotation;
+ return *this;
+}
+
+#ifndef QT_NO_QUATERNION
/*!
Multiples this matrix by another that rotates coordinates according
@@ -1430,15 +1536,31 @@ QMatrix QMatrix4x4::toAffine() const
m[3][0], m[3][1]);
}
-static const qreal inv_dist_to_plane = 1. / 1024.;
+/*!
+ Returns the conventional Qt 2D transformation matrix that
+ corresponds to this matrix.
+
+ The returned QTransform is formed by simply dropping the
+ third row and third column of the QMatrix4x4. This is suitable
+ for implementing orthographic projections where the z co-ordinate
+ should be dropped rather than projected.
+
+ \sa toAffine()
+*/
+QTransform QMatrix4x4::toTransform() const
+{
+ return QTransform(m[0][0], m[0][1], m[0][3],
+ m[1][0], m[1][1], m[1][3],
+ m[3][0], m[3][1], m[3][3]);
+}
/*!
Returns the conventional Qt 2D transformation matrix that
corresponds to this matrix.
If \a distanceToPlane is non-zero, it indicates a projection
- factor to use to adjust for the z co-ordinate. The default
- value of 1024 corresponds to the projection factor used
+ factor to use to adjust for the z co-ordinate. The value of
+ 1024 corresponds to the projection factor used
by QTransform::rotate() for the x and y axes.
If \a distanceToPlane is zero, then the returned QTransform
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index b32e00a..ba74b89 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -159,7 +159,8 @@ public:
void toValueArray(qreal *values) const;
QMatrix toAffine() const;
- QTransform toTransform(qreal distanceToPlane = 1024.0f) const;
+ QTransform toTransform() const;
+ QTransform toTransform(qreal distanceToPlane) const;
QPoint map(const QPoint& point) const;
QPointF map(const QPointF& point) const;
@@ -206,6 +207,10 @@ private:
QMatrix4x4(int) { flagBits = General; }
QMatrix4x4 orthonormalInverse() const;
+
+ QMatrix4x4& projectedRotate(qreal angle, qreal x, qreal y, qreal z);
+
+ friend class QGraphicsRotation;
};
inline QMatrix4x4::QMatrix4x4
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index fabd7ca..fc12cfe 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -3866,7 +3866,7 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption *
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
if (!menuItem->text.isEmpty()) {
- newSize.setHeight(menuItem->fontMetrics.lineSpacing());
+ newSize.setHeight(menuItem->fontMetrics.height());
}
}
#ifndef QT_NO_COMBOBOX
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 5886512..70d130a 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -4396,13 +4396,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
case PM_TitleBarHeight: {
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) {
- ret = qMax(widget ? widget->fontMetrics().lineSpacing() : opt->fontMetrics.lineSpacing(), 16);
+ ret = qMax(widget ? widget->fontMetrics().height() : opt->fontMetrics.height(), 16);
#ifndef QT_NO_DOCKWIDGET
} else if (qobject_cast<const QDockWidget*>(widget)) {
- ret = qMax(widget->fontMetrics().lineSpacing(), int(QStyleHelper::dpiScaled(13)));
+ ret = qMax(widget->fontMetrics().height(), int(QStyleHelper::dpiScaled(13)));
#endif
} else {
- ret = qMax(widget ? widget->fontMetrics().lineSpacing() : opt->fontMetrics.lineSpacing(), 18);
+ ret = qMax(widget ? widget->fontMetrics().height() : opt->fontMetrics.height(), 18);
}
} else {
ret = int(QStyleHelper::dpiScaled(18.));
diff --git a/src/gui/styles/qmotifstyle.cpp b/src/gui/styles/qmotifstyle.cpp
index e6c60cf..b65d45c 100644
--- a/src/gui/styles/qmotifstyle.cpp
+++ b/src/gui/styles/qmotifstyle.cpp
@@ -1154,7 +1154,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
menuitem->palette, menuitem->state & State_Enabled, menuitem->text,
QPalette::Text);
textWidth = menuitem->fontMetrics.width(menuitem->text) + 10;
- y += menuitem->fontMetrics.lineSpacing() / 2;
+ y += menuitem->fontMetrics.height() / 2;
p->setFont(oldFont);
}
p->setPen(opt->palette.dark().color());
@@ -2056,7 +2056,7 @@ QMotifStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
w = 10;
- h = (mi->text.isEmpty()) ? motifSepHeight : mi->fontMetrics.lineSpacing();
+ h = (mi->text.isEmpty()) ? motifSepHeight : mi->fontMetrics.height();
}
// a little bit of border can never harm
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index ce2109a..09f5d36 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/gui/styles/qplastiquestyle.cpp
@@ -5027,7 +5027,7 @@ QSize QPlastiqueStyle::sizeFromContents(ContentsType type, const QStyleOption *o
case CT_MenuItem:
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator)
- newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics.lineSpacing());
+ newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics.height());
}
break;
case CT_MenuBarItem:
@@ -5607,11 +5607,11 @@ int QPlastiqueStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
#ifdef QT3_SUPPORT
if (widget && widget->inherits("Q3DockWindowTitleBar")) {
// Q3DockWindow has smaller title bars than QDockWidget
- ret = qMax(widget->fontMetrics().lineSpacing(), 20);
+ ret = qMax(widget->fontMetrics().height(), 20);
} else
#endif
- ret = qMax(widget ? widget->fontMetrics().lineSpacing() :
- (option ? option->fontMetrics.lineSpacing() : 0), 30);
+ ret = qMax(widget ? widget->fontMetrics().height() :
+ (option ? option->fontMetrics.height() : 0), 30);
break;
case PM_MaximumDragDistance:
return -1;
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 707b05e..2d90aa1 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -4722,7 +4722,7 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const
return subRule.size().height();
else if (subRule.hasBox() || subRule.hasBorder()) {
QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics();
- return subRule.size(QSize(0, fm.lineSpacing())).height();
+ return subRule.size(QSize(0, fm.height())).height();
}
break;
}
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index 5fa6251..7ed187f 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -5347,10 +5347,8 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
painter->drawLines(a);
break; }
case PE_Frame:
- if (d->doubleControls)
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),2,&option->palette.light());
- else
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),1,&option->palette.light());
+ qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),
+ d->doubleControls ? 2 : 1, &option->palette.background());
break;
case PE_FrameLineEdit:
case PE_FrameMenu:
@@ -6840,34 +6838,11 @@ void QWindowsMobileStyle::polish(QWidget *widget) {
else
#endif //QT_NO_TOOLBAR
-#ifndef QT_NO_PROPERTIES
- if (QAbstractButton *pushButton = qobject_cast<QAbstractButton*>(widget)) {
- QVariant oldFont = widget->property("_q_styleWindowsMobileFont");
- if (!oldFont.isValid()) {
- QFont f = pushButton->font();
- widget->setProperty("_q_styleWindowsMobileFont", f);
- f.setBold(true);
- int p = f.pointSize();
- if (p > 2)
- f.setPointSize(p-1);
- pushButton->setFont(f);
- }
- }
-#endif
- QWindowsStyle::polish(widget);
+ QWindowsStyle::polish(widget);
}
void QWindowsMobileStyle::unpolish(QWidget *widget)
{
-#ifndef QT_NO_PROPERTIES
- if (QAbstractButton *pushButton = qobject_cast<QAbstractButton*>(widget)) {
- QVariant oldFont = widget->property("_q_styleWindowsMobileFont");
- if (oldFont.isValid()) {
- widget->setFont(qVariantValue<QFont>(oldFont));
- widget->setProperty("_q_styleWindowsMobileFont", QVariant());
- }
- }
-#endif
QWindowsStyle::unpolish(widget);
}
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 1285935..1b4c380 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -2632,7 +2632,7 @@ QFontCache::~QFontCache()
while (it != end) {
if (--it.value().data->cache_count == 0) {
if (it.value().data->ref == 0) {
- FC_DEBUG("QFontCache::~QFontCache: deleting engine %p key=(%d / %g %d %d %d %d)",
+ FC_DEBUG("QFontCache::~QFontCache: deleting engine %p key=(%d / %g %g %d %d %d)",
it.value().data, it.key().script, it.key().def.pointSize,
it.key().def.pixelSize, it.key().def.weight, it.key().def.style,
it.key().def.fixedPitch);
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index d74f0b4..144a82d 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -86,7 +86,7 @@ struct QFontDef
#endif // Q_WS_X11
qreal pointSize;
- int pixelSize;
+ qreal pixelSize;
uint styleStrategy : 16;
uint styleHint : 8;
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 738e36a..fb8444e 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1331,7 +1331,7 @@ static void match(int script, const QFontDef &request,
" family: %s [%s], script: %d\n"
" weight: %d, style: %d\n"
" stretch: %d\n"
- " pixelSize: %d\n"
+ " pixelSize: %g\n"
" pitch: %c",
family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(),
foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(),
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index ae26dab..6cde9ed 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qt_windows.h"
+#include <qmath.h>
#include <private/qapplication_p.h>
#include "qfont_p.h"
#include "qfontengine_p.h"
@@ -670,7 +671,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
break;
}
- lf.lfHeight = -request.pixelSize;
+ lf.lfHeight = -qRound(request.pixelSize);
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
@@ -899,7 +900,6 @@ static QFontEngine *loadWin(const QFontPrivate *d, int script, const QFontDef &r
return fe;
}
-
void QFontDatabase::load(const QFontPrivate *d, int script)
{
// sanity checks
@@ -910,8 +910,9 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
// normalize the request to get better caching
QFontDef req = d->request;
if (req.pixelSize <= 0)
- req.pixelSize = qMax(1, qRound(req.pointSize * d->dpi / 72.));
- req.pointSize = 0;
+ req.pixelSize = qreal((req.pointSize * d->dpi) / 72.);
+ if (req.pixelSize < 1)
+ req.pixelSize = 1;
if (req.weight == 0)
req.weight = QFont::Normal;
if (req.stretch == 0)
@@ -928,7 +929,8 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
QFontEngine *fe = QFontCache::instance()->findEngine(key);
// set it to the actual pointsize, so QFontInfo will do the right thing
- req.pointSize = req.pixelSize*72./d->dpi;
+ if (req.pointSize < 0)
+ req.pointSize = req.pixelSize*72./d->dpi;
if (!fe) {
if (qt_enable_test_font && req.family == QLatin1String("__Qt__Box__Engine__")) {
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 27ff003..f184811 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -51,6 +51,7 @@
#include <qfile.h>
#include <qtemporaryfile.h>
#include <qabstractfileengine.h>
+#include <qmath.h>
#include <ctype.h>
#include <stdlib.h>
@@ -757,7 +758,7 @@ QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &request)
double size;
if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
- fontDef.pixelSize = qRound(size);
+ fontDef.pixelSize = size;
else
fontDef.pixelSize = 12;
@@ -1455,7 +1456,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD
slant_value = FC_SLANT_OBLIQUE;
FcPatternAddInteger(pattern, FC_SLANT, slant_value);
- double size_value = qMax(1, request.pixelSize);
+ double size_value = qMax(qreal(1.), request.pixelSize);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
int stretch = request.stretch;
@@ -1893,8 +1894,9 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
// normalize the request to get better caching
QFontDef req = d->request;
if (req.pixelSize <= 0)
- req.pixelSize = qRound(qt_pixelSize(req.pointSize, d->dpi));
- req.pointSize = 0;
+ req.pixelSize = floor(qt_pixelSize(req.pointSize, d->dpi) * 100 + 0.5) / 100;
+ if (req.pixelSize < 1)
+ req.pixelSize = 1;
if (req.weight == 0)
req.weight = QFont::Normal;
if (req.stretch == 0)
@@ -1909,7 +1911,9 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
return;
// set it to the actual pointsize, so QFontInfo will do the right thing
- req.pointSize = qt_pointSize(req.pixelSize, d->dpi);
+ if (req.pointSize < 0)
+ req.pointSize = qt_pointSize(req.pixelSize, d->dpi);
+
QFontEngine *fe = QFontCache::instance()->findEngine(key);
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 3da1593..4041717 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -327,7 +327,7 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id)
void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing)
{
- *ysize = fontDef.pixelSize << 6;
+ *ysize = qRound(fontDef.pixelSize * 64);
*xsize = *ysize * fontDef.stretch / 100;
*outline_drawing = false;
@@ -387,7 +387,9 @@ QFontEngine::Properties QFreetypeFace::properties() const
p.descent = QFixed::fromFixed(-face->size->metrics.descender);
p.leading = QFixed::fromFixed(face->size->metrics.height - face->size->metrics.ascender + face->size->metrics.descender);
p.emSquare = face->size->metrics.y_ppem;
- p.boundingBox = QRectF(-p.ascent.toReal(), 0, (p.ascent + p.descent).toReal(), face->size->metrics.max_advance/64.);
+// p.boundingBox = QRectF(-p.ascent.toReal(), 0, (p.ascent + p.descent).toReal(), face->size->metrics.max_advance/64.);
+ p.boundingBox = QRectF(0, -p.ascent.toReal(),
+ face->size->metrics.max_advance/64, (p.ascent + p.descent).toReal() );
}
p.italicAngle = 0;
p.capHeight = p.ascent;
@@ -709,6 +711,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format)
hbFace = freetype->hbFace;
metrics = face->size->metrics;
+
#if defined(Q_WS_QWS)
/*
TrueType fonts with embedded bitmaps may have a bitmap font specific
@@ -1219,7 +1222,8 @@ QFixed QFontEngineFT::ascent() const
QFixed QFontEngineFT::descent() const
{
- return QFixed::fromFixed(-metrics.descender);
+ // subtract a pixel to work around QFontMetrics's built-in + 1
+ return QFixed::fromFixed(-metrics.descender - 64);
}
QFixed QFontEngineFT::leading() const
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index ef3f2ae..6ff0fbd 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -819,7 +819,7 @@ FT_Face QFontEngineQPF::lockFace() const
FT_Face face = freetype->face;
// ### not perfect
- const int ysize = fontDef.pixelSize << 6;
+ const int ysize = int(fontDef.pixelSize) << 6;
const int xsize = ysize;
if (freetype->xsize != xsize || freetype->ysize != ysize) {
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index d781c70..fd34d0f 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -577,7 +577,9 @@ QFixed QFontEngineWin::ascent() const
QFixed QFontEngineWin::descent() const
{
- return tm.tmDescent;
+ // ### we substract 1 to even out the historical +1 in QFontMetrics's
+ // ### height=asc+desc+1 equation. Fix in Qt5.
+ return tm.tmDescent - 1;
}
QFixed QFontEngineWin::leading() const
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index de83d39..73434b1 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1437,7 +1437,9 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
option.setTextDirection(dir);
layout.setTextOption(option);
layout.beginLayout();
- layout.createLine();
+ QTextLine line = layout.createLine();
+ if (line.isValid())
+ line.setLeadingIncluded(true);
layout.endLayout();
layout.draw(painter, QPointF(r.left(), pos.y()));
break;
@@ -2579,6 +2581,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
QTextLine line = tl->createLine();
if (!line.isValid())
break;
+ line.setLeadingIncluded(true);
QFixed left, right;
floatMargins(layoutStruct->y, layoutStruct, &left, &right);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 81c9142..a91408f 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1042,7 +1042,7 @@ void QTextEngine::shapeTextWithCE(int item) const
QScriptItem &si = layoutData->items[item];
si.glyph_data_offset = layoutData->used;
- QFontEngine *fe = fontEngine(si, &si.ascent, &si.descent);
+ QFontEngine *fe = fontEngine(si, &si.ascent, &si.descent, &si.leading);
QTextEngine::ShaperFlags flags;
if (si.analysis.bidiLevel % 2)
@@ -1119,7 +1119,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
si.glyph_data_offset = layoutData->used;
- QFontEngine *font = fontEngine(si, &si.ascent, &si.descent);
+ QFontEngine *font = fontEngine(si, &si.ascent, &si.descent, &si.leading);
bool kerningEnabled = this->font(si).d->kerning;
@@ -1350,8 +1350,11 @@ void QTextEngine::shape(int item) const
layoutData->items[item].position + block.position(), format);
}
} else if (layoutData->items[item].analysis.flags == QScriptAnalysis::Tab) {
- // set up at least the ascent/descent of the script item for the tab
- fontEngine(layoutData->items[item], &layoutData->items[item].ascent, &layoutData->items[item].descent);
+ // set up at least the ascent/descent/leading of the script item for the tab
+ fontEngine(layoutData->items[item],
+ &layoutData->items[item].ascent,
+ &layoutData->items[item].descent,
+ &layoutData->items[item].leading);
} else {
shapeText(item);
}
@@ -1737,7 +1740,7 @@ QFont QTextEngine::font(const QScriptItem &si) const
return font;
}
-QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent) const
+QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent, QFixed *leading) const
{
QFontEngine *engine = 0;
QFontEngine *scaledEngine = 0;
@@ -1777,6 +1780,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
if (ascent) {
*ascent = engine->ascent();
*descent = engine->descent();
+ *leading = engine->leading();
}
if (scaledEngine)
@@ -2009,8 +2013,12 @@ void QScriptLine::setDefaultHeight(QTextEngine *eng)
e = eng->fnt.d->engineForScript(QUnicodeTables::Common);
}
- ascent = qMax(ascent, e->ascent());
- descent = qMax(descent, e->descent());
+ QFixed other_ascent = e->ascent();
+ QFixed other_descent = e->descent();
+ QFixed other_leading = e->leading();
+ leading = qMax(leading + ascent, other_leading + other_ascent) - qMax(ascent, other_ascent);
+ ascent = qMax(ascent, other_ascent);
+ descent = qMax(descent, other_descent);
}
QTextEngine::LayoutData::LayoutData()
diff --git a/src/gui/text/qtextengine_mac.cpp b/src/gui/text/qtextengine_mac.cpp
index e101830..eeccc72 100644
--- a/src/gui/text/qtextengine_mac.cpp
+++ b/src/gui/text/qtextengine_mac.cpp
@@ -557,7 +557,7 @@ void QTextEngine::shapeTextMac(int item) const
si.glyph_data_offset = layoutData->used;
- QFontEngine *font = fontEngine(si, &si.ascent, &si.descent);
+ QFontEngine *font = fontEngine(si, &si.ascent, &si.descent, &si.leading);
if (font->type() != QFontEngine::Multi) {
shapeTextWithHarfbuzz(item);
return;
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 85c6928..a1d363b 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -345,11 +345,11 @@ struct Q_AUTOTEST_EXPORT QScriptItem
{
inline QScriptItem()
: position(0),
- num_glyphs(0), descent(-1), ascent(-1), width(-1),
+ num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1),
glyph_data_offset(0) {}
inline QScriptItem(int p, const QScriptAnalysis &a)
: position(p), analysis(a),
- num_glyphs(0), descent(-1), ascent(-1), width(-1),
+ num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1),
glyph_data_offset(0) {}
int position;
@@ -357,6 +357,7 @@ struct Q_AUTOTEST_EXPORT QScriptItem
unsigned short num_glyphs;
QFixed descent;
QFixed ascent;
+ QFixed leading;
QFixed width;
int glyph_data_offset;
QFixed height() const { return ascent + descent + 1; }
@@ -373,9 +374,10 @@ struct Q_AUTOTEST_EXPORT QScriptLine
QScriptLine()
: from(0), length(0),
justified(0), gridfitted(0),
- hasTrailingSpaces(0) {}
+ hasTrailingSpaces(0), leadingIncluded(0) {}
QFixed descent;
QFixed ascent;
+ QFixed leading;
QFixed x;
QFixed y;
QFixed width;
@@ -385,7 +387,11 @@ struct Q_AUTOTEST_EXPORT QScriptLine
mutable uint justified : 1;
mutable uint gridfitted : 1;
uint hasTrailingSpaces : 1;
- QFixed height() const { return ascent + descent + 1; }
+ uint leadingIncluded : 1;
+ QFixed height() const { return ascent + descent + 1
+ + (leadingIncluded? qMax(QFixed(),leading) : QFixed()); }
+ QFixed base() const { return ascent
+ + (leadingIncluded ? qMax(QFixed(),leading) : QFixed()); }
void setDefaultHeight(QTextEngine *eng);
void operator+=(const QScriptLine &other);
};
@@ -394,6 +400,7 @@ Q_DECLARE_TYPEINFO(QScriptLine, Q_PRIMITIVE_TYPE);
inline void QScriptLine::operator+=(const QScriptLine &other)
{
+ leading= qMax(leading + ascent, other.leading + other.ascent) - qMax(ascent, other.ascent);
descent = qMax(descent, other.descent);
ascent = qMax(ascent, other.ascent);
textWidth += other.textWidth;
@@ -476,7 +483,7 @@ public:
return end - si->position;
}
- QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = 0, QFixed *descent = 0) const;
+ QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = 0, QFixed *descent = 0, QFixed *leading = 0) const;
QFont font(const QScriptItem &si) const;
inline QFont font() const { return fnt; }
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index c5f0e35..4600a29 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -860,7 +860,7 @@ QRectF QTextLayout::boundingRect() const
ymin = qMin(ymin, si.y);
xmax = qMax(xmax, si.x+qMax(si.width, si.textWidth));
// ### shouldn't the ascent be used in ymin???
- ymax = qMax(ymax, si.y+si.ascent+si.descent+1);
+ ymax = qMax(ymax, si.y+si.height());
}
return QRectF(xmin.toReal(), ymin.toReal(), (xmax-xmin).toReal(), (ymax-ymin).toReal());
}
@@ -1071,10 +1071,10 @@ static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPo
QTextLineItemIterator iterator(eng, lineNumber, pos, selection);
- const QFixed y = QFixed::fromReal(pos.y()) + line.y + line.ascent;
+
+ const qreal selectionY = pos.y() + line.y.toReal();
const qreal lineHeight = line.height().toReal();
- const qreal selectionY = (y - line.ascent).toReal();
QFixed lastSelectionX = iterator.x;
QFixed lastSelectionWidth;
@@ -1334,23 +1334,23 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
const qreal x = position.x() + l.cursorToX(cursorPosition);
int itm = d->findItem(cursorPosition - 1);
- QFixed ascent = sl.ascent;
+ QFixed base = sl.base();
QFixed descent = sl.descent;
bool rightToLeft = (d->option.textDirection() == Qt::RightToLeft);
if (itm >= 0) {
const QScriptItem &si = d->layoutData->items.at(itm);
if (si.ascent > 0)
- ascent = si.ascent;
+ base = si.ascent;
if (si.descent > 0)
descent = si.descent;
rightToLeft = si.analysis.bidiLevel % 2;
}
- qreal y = position.y() + (sl.y + sl.ascent - ascent).toReal();
+ qreal y = position.y() + (sl.y + sl.base() - base).toReal();
bool toggleAntialiasing = !(p->renderHints() & QPainter::Antialiasing)
&& (p->transform().type() > QTransform::TxTranslate);
if (toggleAntialiasing)
p->setRenderHint(QPainter::Antialiasing);
- p->fillRect(QRectF(x, y, qreal(width), (ascent + descent).toReal()), p->pen().brush());
+ p->fillRect(QRectF(x, y, qreal(width), (base + descent + 1).toReal()), p->pen().brush());
if (toggleAntialiasing)
p->setRenderHint(QPainter::Antialiasing, false);
if (d->layoutData->hasBidi) {
@@ -1500,9 +1500,11 @@ qreal QTextLine::descent() const
}
/*!
- Returns the line's height. This is equal to ascent() + descent() + 1.
+ Returns the line's height. This is equal to ascent() + descent() + 1
+ if leading is not included. If leading is included, this equals to
+ ascent() + descent() + leading() + 1.
- \sa ascent() descent()
+ \sa ascent() descent() leading() setLeadingIncluded()
*/
qreal QTextLine::height() const
{
@@ -1510,6 +1512,51 @@ qreal QTextLine::height() const
}
/*!
+ \since 4.6
+
+ Returns the line's leading.
+
+ \sa ascent() descent() height()
+*/
+qreal QTextLine::leading() const
+{
+ return eng->lines[i].leading.toReal();
+}
+
+/*! \since 4.6
+
+ Includes positive leading into the line's height if \a included is true;
+ otherwise does not include leading.
+
+ By default, leading is not included.
+
+ Note that negative leading is ignored, it must be handled
+ in the code using the text lines by letting the lines overlap.
+
+ \sa leadingIncluded()
+
+*/
+void QTextLine::setLeadingIncluded(bool included)
+{
+ eng->lines[i].leadingIncluded= included;
+
+}
+
+/*! \since 4.6
+
+ Returns true if positive leading is included into the line's height; otherwise returns false.
+
+ By default, leading is not included.
+
+ \sa setLeadingIncluded()
+*/
+bool QTextLine::leadingIncluded() const
+{
+ return eng->lines[i].leadingIncluded;
+}
+
+
+/*!
Returns the width of the line that is occupied by text. This is
always \<= to width(), and is the minimum width that could be used
by layout() without changing the line break position.
@@ -1712,6 +1759,9 @@ void QTextLine::layout_helper(int maxGlyphs)
}
const QScriptItem &current = eng->layoutData->items[item];
+ lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent,
+ current.leading + current.ascent) - qMax(lbh.tmpData.ascent,
+ current.ascent);
lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent);
lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent);
@@ -2042,7 +2092,9 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
QTextLineItemIterator iterator(eng, i, pos, selection);
- const QFixed y = QFixed::fromReal(pos.y()) + line.y + line.ascent;
+ QFixed lineBase = line.base();
+
+ const QFixed y = QFixed::fromReal(pos.y()) + line.y + lineBase;
bool suppressColors = (eng->option.flags() & QTextOption::SuppressColors);
while (!iterator.atEnd()) {
@@ -2065,7 +2117,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
if (selection)
format.merge(selection->format);
- setPenAndDrawBackground(p, pen, format, QRectF(iterator.x.toReal(), (y - line.ascent).toReal(),
+ setPenAndDrawBackground(p, pen, format, QRectF(iterator.x.toReal(), (y - lineBase).toReal(),
iterator.itemWidth.toReal(), line.height().toReal()));
QTextCharFormat::VerticalAlignment valign = format.verticalAlignment();
@@ -2086,7 +2138,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
if (si.analysis.flags == QScriptAnalysis::Object && eng->block.docHandle()) {
QFixed itemY = y - si.ascent;
if (format.verticalAlignment() == QTextCharFormat::AlignTop) {
- itemY = y - line.ascent;
+ itemY = y - lineBase;
}
QRectF itemRect(iterator.x.toReal(), itemY.toReal(), iterator.itemWidth.toReal(), si.height().toReal());
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index 90afac8..9f170f5 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -196,6 +196,10 @@ public:
qreal ascent() const;
qreal descent() const;
qreal height() const;
+ qreal leading() const;
+
+ void setLeadingIncluded(bool included);
+ bool leadingIncluded() const;
qreal naturalTextWidth() const;
QRectF naturalTextRect() const;
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index b28ecd7..b7615a4 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -78,6 +78,7 @@ win32 {
unix:x11 {
HEADERS += \
text/qfontengine_x11_p.h \
+ text/qfontdatabase_x11.cpp \
text/qfontengine_ft_p.h
SOURCES += \
text/qfont_x11.cpp \
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 4f2e91b..ae56d36 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -314,7 +314,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
// height
- sh.setHeight(qMax(fm.lineSpacing(), 14) + 2);
+ sh.setHeight(qMax(fm.height(), 14) + 2);
if (hasIcon) {
sh.setHeight(qMax(sh.height(), iconSize.height() + 2));
}
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index a574262f..6710275 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -456,7 +456,7 @@ int QDockWidgetLayout::titleHeight() const
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
- return qMax(buttonHeight + 2, titleFontMetrics.lineSpacing() + 2*mw);
+ return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
}
void QDockWidgetLayout::setGeometry(const QRect &geometry)
diff --git a/src/gui/widgets/qfontcombobox.cpp b/src/gui/widgets/qfontcombobox.cpp
index 7b39823..806db59 100644
--- a/src/gui/widgets/qfontcombobox.cpp
+++ b/src/gui/widgets/qfontcombobox.cpp
@@ -194,7 +194,7 @@ QSize QFontFamilyDelegate::sizeHint(const QStyleOptionViewItem &option,
// font.setFamily(text);
font.setPointSize(QFontInfo(font).pointSize() * 3/2);
QFontMetrics fontMetrics(font);
- return QSize(fontMetrics.width(text), fontMetrics.lineSpacing());
+ return QSize(fontMetrics.width(text), fontMetrics.height());
}
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 629e839..e4252b5 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -624,7 +624,7 @@ QSize QLineEdit::sizeHint() const
Q_D(const QLineEdit);
ensurePolished();
QFontMetrics fm(font());
- int h = qMax(fm.lineSpacing(), 14) + 2*d->verticalMargin
+ int h = qMax(fm.height(), 14) + 2*d->verticalMargin
+ d->topTextMargin + d->bottomTextMargin
+ d->topmargin + d->bottommargin;
int w = fm.width(QLatin1Char('x')) * 17 + 2*d->horizontalMargin
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 22438bf..fc61889 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -357,10 +357,8 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block)
Q_D(QPlainTextDocumentLayout);
QTextDocument *doc = document();
qreal margin = doc->documentMargin();
- QFontMetrics fm(doc->defaultFont());
qreal blockMaximumWidth = 0;
- int leading = qMax(0, fm.leading());
qreal height = 0;
QTextLayout *tl = block.layout();
QTextOption option = doc->defaultTextOption();
@@ -381,9 +379,8 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block)
QTextLine line = tl->createLine();
if (!line.isValid())
break;
+ line.setLeadingIncluded(true);
line.setLineWidth(availableWidth);
-
- height += leading;
line.setPosition(QPointF(margin, height));
height += line.height();
blockMaximumWidth = qMax(blockMaximumWidth, line.naturalTextWidth() + 2*margin);
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 2c88130..1f93534 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -467,6 +467,9 @@ bool QSslSocket::setSocketDescriptor(int socketDescriptor, SocketState state, Op
return retVal;
}
+/*!
+ \reimp
+*/
void QSslSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
{
Q_D(QSslSocket);
@@ -474,6 +477,9 @@ void QSslSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVa
d->plainSocket->setSocketOption(option, value);
}
+/*!
+ \reimp
+*/
QVariant QSslSocket::socketOption(QAbstractSocket::SocketOption option)
{
Q_D(QSslSocket);
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index bcc6bdb..a0810bc 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1263,6 +1263,7 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
QGLContext *ctx = d->ctx;
+ Q_UNUSED(ctx);
if (opaque) {
d->prepareForDraw(opaque);
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index dfa6c40..d028522 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -42,6 +42,7 @@
#include "qglshaderprogram.h"
#include "qglextensions_p.h"
#include "qgl_p.h"
+#include <QtCore/private/qobject_p.h>
#include <QtCore/qdebug.h>
#include <QtCore/qfile.h>
#include <QtCore/qvarlengtharray.h>
@@ -200,8 +201,9 @@ QT_BEGIN_NAMESPACE
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
#endif
-class QGLShaderPrivate
+class QGLShaderPrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QGLShader)
public:
QGLShaderPrivate(const QGLContext *context, QGLShader::ShaderType type)
: shaderGuard(context)
@@ -211,6 +213,7 @@ public:
, hasPartialSource(false)
{
}
+ ~QGLShaderPrivate();
QGLSharedResourceGuard shaderGuard;
QGLShader::ShaderType shaderType;
@@ -227,6 +230,14 @@ public:
#define ctx shaderGuard.context()
+QGLShaderPrivate::~QGLShaderPrivate()
+{
+ if (shaderGuard.id()) {
+ QGLShareContextScope scope(shaderGuard.context());
+ glDeleteShader(shaderGuard.id());
+ }
+}
+
bool QGLShaderPrivate::create()
{
const QGLContext *context = shaderGuard.context();
@@ -306,9 +317,9 @@ void QGLShaderPrivate::deleteShader()
\sa compile(), compileFile()
*/
QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent)
- : QObject(parent)
+ : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent)
{
- d = new QGLShaderPrivate(QGLContext::currentContext(), type);
+ Q_D(QGLShader);
d->create();
}
@@ -323,13 +334,21 @@ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent)
*/
QGLShader::QGLShader
(const QString& fileName, QGLShader::ShaderType type, QObject *parent)
- : QObject(parent)
+ : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent)
{
- d = new QGLShaderPrivate(QGLContext::currentContext(), type);
+ Q_D(QGLShader);
if (d->create() && !compileFile(fileName))
d->deleteShader();
}
+static inline const QGLContext *contextOrCurrent(const QGLContext *context)
+{
+ if (context)
+ return context;
+ else
+ return QGLContext::currentContext();
+}
+
/*!
Constructs a new QGLShader object of the specified \a type
and attaches it to \a parent. If shader programs are not supported,
@@ -343,14 +362,12 @@ QGLShader::QGLShader
\sa compile(), compileFile()
*/
QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent)
- : QObject(parent)
+ : QObject(*new QGLShaderPrivate(contextOrCurrent(context), type), parent)
{
- if (!context)
- context = QGLContext::currentContext();
- d = new QGLShaderPrivate(context, type);
+ Q_D(QGLShader);
#ifndef QT_NO_DEBUG
if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) {
- qWarning("QGLShader::QGLShader: \'context\' must be the currect context or sharing with it.");
+ qWarning("QGLShader::QGLShader: \'context\' must be the current context or sharing with it.");
return;
}
#endif
@@ -368,14 +385,12 @@ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObj
*/
QGLShader::QGLShader
(const QString& fileName, QGLShader::ShaderType type, const QGLContext *context, QObject *parent)
- : QObject(parent)
+ : QObject(*new QGLShaderPrivate(contextOrCurrent(context), type), parent)
{
- if (!context)
- context = QGLContext::currentContext();
- d = new QGLShaderPrivate(context, type);
+ Q_D(QGLShader);
#ifndef QT_NO_DEBUG
if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) {
- qWarning("QGLShader::QGLShader: \'context\' must be currect context or sharing with it.");
+ qWarning("QGLShader::QGLShader: \'context\' must be current context or sharing with it.");
return;
}
#endif
@@ -390,11 +405,6 @@ QGLShader::QGLShader
*/
QGLShader::~QGLShader()
{
- if (d->shaderGuard.id()) {
- QGLShareContextScope scope(d->shaderGuard.context());
- glDeleteShader(d->shaderGuard.id());
- }
- delete d;
}
/*!
@@ -402,6 +412,7 @@ QGLShader::~QGLShader()
*/
QGLShader::ShaderType QGLShader::shaderType() const
{
+ Q_D(const QGLShader);
return d->shaderType;
}
@@ -439,12 +450,14 @@ static const char redefineHighp[] =
*/
bool QGLShader::compile(const char *source)
{
+ Q_D(QGLShader);
if (d->isPartial) {
d->partialSource = QByteArray(source);
d->hasPartialSource = true;
return d->compile(this);
} else if (d->shaderGuard.id()) {
- QVarLengthArray<const char *> src;
+ QVarLengthArray<const char *, 4> src;
+ QVarLengthArray<GLint, 4> srclen;
int headerLen = 0;
while (source && source[headerLen] == '#') {
// Skip #version and #extension directives at the start of
@@ -459,21 +472,24 @@ bool QGLShader::compile(const char *source)
if (source[headerLen] == '\n')
++headerLen;
}
- QByteArray header;
if (headerLen > 0) {
- header = QByteArray(source, headerLen);
- src.append(header.constData());
+ src.append(source);
+ srclen.append(GLint(headerLen));
}
#ifdef QGL_DEFINE_QUALIFIERS
src.append(qualifierDefines);
+ srclen.append(GLint(sizeof(qualifierDefines) - 1));
#endif
#ifdef QGL_REDEFINE_HIGHP
if (d->shaderType == FragmentShader ||
- d->shaderType == PartialFragmentShader)
+ d->shaderType == PartialFragmentShader) {
src.append(redefineHighp);
+ srclen.append(GLint(sizeof(redefineHighp) - 1));
+ }
#endif
src.append(source + headerLen);
- glShaderSource(d->shaderGuard.id(), src.size(), src.data(), 0);
+ srclen.append(GLint(qstrlen(source + headerLen)));
+ glShaderSource(d->shaderGuard.id(), src.size(), src.data(), srclen.data());
return d->compile(this);
} else {
return false;
@@ -481,6 +497,61 @@ bool QGLShader::compile(const char *source)
}
/*!
+ \internal
+*/
+bool QGLShader::compile
+ (const QList<QGLShader *>& shaders, QGLShader::ShaderType type)
+{
+ Q_D(QGLShader);
+ QVarLengthArray<const char *, 16> src;
+ QVarLengthArray<GLint, 16> srclen;
+ if (!d->shaderGuard.id())
+ return false;
+ foreach (QGLShader *shader, shaders) {
+ if (shader->shaderType() != type)
+ continue;
+ const char *source = shader->d_func()->partialSource.constData();
+ int headerLen = 0;
+ if (src.isEmpty()) {
+ // First shader: handle the #version and #extension tags
+ // plus the precision qualifiers.
+ while (source && source[headerLen] == '#') {
+ // Skip #version and #extension directives at the start of
+ // the shader code. We need to insert the qualifierDefines
+ // and redefineHighp just after them.
+ if (qstrncmp(source + headerLen, "#version", 8) != 0 &&
+ qstrncmp(source + headerLen, "#extension", 10) != 0) {
+ break;
+ }
+ while (source[headerLen] != '\0' && source[headerLen] != '\n')
+ ++headerLen;
+ if (source[headerLen] == '\n')
+ ++headerLen;
+ }
+ if (headerLen > 0) {
+ src.append(source);
+ srclen.append(GLint(headerLen));
+ }
+#ifdef QGL_DEFINE_QUALIFIERS
+ src.append(qualifierDefines);
+ srclen.append(GLint(sizeof(qualifierDefines) - 1));
+#endif
+#ifdef QGL_REDEFINE_HIGHP
+ if (d->shaderType == FragmentShader ||
+ d->shaderType == PartialFragmentShader) {
+ src.append(redefineHighp);
+ srclen.append(GLint(sizeof(redefineHighp) - 1));
+ }
+#endif
+ }
+ src.append(source + headerLen);
+ srclen.append(GLint(qstrlen(source + headerLen)));
+ }
+ glShaderSource(d->shaderGuard.id(), src.size(), src.data(), srclen.data());
+ return d->compile(this);
+}
+
+/*!
\overload
Sets the \a source code for this shader and compiles it.
@@ -555,6 +626,7 @@ bool QGLShader::compileFile(const QString& fileName)
*/
bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length)
{
+ Q_D(QGLShader);
#if !defined(QT_OPENGL_ES_2)
if (!glShaderBinary)
return false;
@@ -588,21 +660,22 @@ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length)
bool QGLShader::setShaderBinary
(QGLShader& otherShader, GLenum format, const void *binary, int length)
{
+ Q_D(QGLShader);
#if !defined(QT_OPENGL_ES_2)
if (!glShaderBinary)
return false;
#endif
if (d->isPartial || !d->shaderGuard.id())
return false;
- if (otherShader.d->isPartial || !otherShader.d->shaderGuard.id())
+ if (otherShader.d_func()->isPartial || !otherShader.d_func()->shaderGuard.id())
return false;
glGetError(); // Clear error state.
GLuint shaders[2];
shaders[0] = d->shaderGuard.id();
- shaders[1] = otherShader.d->shaderGuard.id();
+ shaders[1] = otherShader.d_func()->shaderGuard.id();
glShaderBinary(2, shaders, format, binary, length);
d->compiled = (glGetError() == GL_NO_ERROR);
- otherShader.d->compiled = d->compiled;
+ otherShader.d_func()->compiled = d->compiled;
return d->compiled;
}
@@ -634,6 +707,7 @@ QList<GLenum> QGLShader::shaderBinaryFormats()
*/
QByteArray QGLShader::sourceCode() const
{
+ Q_D(const QGLShader);
if (d->isPartial)
return d->partialSource;
GLuint shader = d->shaderGuard.id();
@@ -658,6 +732,7 @@ QByteArray QGLShader::sourceCode() const
*/
bool QGLShader::isCompiled() const
{
+ Q_D(const QGLShader);
return d->compiled;
}
@@ -668,6 +743,7 @@ bool QGLShader::isCompiled() const
*/
QString QGLShader::log() const
{
+ Q_D(const QGLShader);
return d->log;
}
@@ -682,14 +758,16 @@ QString QGLShader::log() const
*/
GLuint QGLShader::shaderId() const
{
+ Q_D(const QGLShader);
return d->shaderGuard.id();
}
#undef ctx
#define ctx programGuard.context()
-class QGLShaderProgramPrivate
+class QGLShaderProgramPrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QGLShaderProgram)
public:
QGLShaderProgramPrivate(const QGLContext *context)
: programGuard(context)
@@ -713,6 +791,8 @@ public:
QList<QGLShader *> anonShaders;
QGLShader *vertexShader;
QGLShader *fragmentShader;
+
+ bool hasShader(QGLShader::ShaderType type) const;
};
QGLShaderProgramPrivate::~QGLShaderProgramPrivate()
@@ -723,6 +803,15 @@ QGLShaderProgramPrivate::~QGLShaderProgramPrivate()
}
}
+bool QGLShaderProgramPrivate::hasShader(QGLShader::ShaderType type) const
+{
+ foreach (QGLShader *shader, shaders) {
+ if (shader->shaderType() == type)
+ return true;
+ }
+ return false;
+}
+
#undef ctx
#define ctx d->programGuard.context()
@@ -735,9 +824,8 @@ QGLShaderProgramPrivate::~QGLShaderProgramPrivate()
\sa addShader()
*/
QGLShaderProgram::QGLShaderProgram(QObject *parent)
- : QObject(parent)
+ : QObject(*new QGLShaderProgramPrivate(QGLContext::currentContext()), parent)
{
- d = new QGLShaderProgramPrivate(QGLContext::currentContext());
}
/*!
@@ -749,9 +837,8 @@ QGLShaderProgram::QGLShaderProgram(QObject *parent)
\sa addShader()
*/
QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent)
- : QObject(parent)
+ : QObject(*new QGLShaderProgramPrivate(context), parent)
{
- d = new QGLShaderProgramPrivate(context);
}
/*!
@@ -759,11 +846,11 @@ QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent)
*/
QGLShaderProgram::~QGLShaderProgram()
{
- delete d;
}
bool QGLShaderProgram::init()
{
+ Q_D(QGLShaderProgram);
if (d->programGuard.id() || d->inited)
return true;
d->inited = true;
@@ -801,22 +888,23 @@ bool QGLShaderProgram::init()
*/
bool QGLShaderProgram::addShader(QGLShader *shader)
{
+ Q_D(QGLShaderProgram);
if (!init())
return false;
if (d->shaders.contains(shader))
return true; // Already added to this shader program.
if (d->programGuard.id() && shader) {
- if (!QGLContext::areSharing(shader->d->shaderGuard.context(),
+ if (!QGLContext::areSharing(shader->d_func()->shaderGuard.context(),
d->programGuard.context())) {
qWarning("QGLShaderProgram::addShader: Program and shader are not associated with same context.");
return false;
}
- if (!shader->d->compiled)
+ if (!shader->d_func()->compiled)
return false;
- if (!shader->d->isPartial) {
- if (!shader->d->shaderGuard.id())
+ if (!shader->d_func()->isPartial) {
+ if (!shader->d_func()->shaderGuard.id())
return false;
- glAttachShader(d->programGuard.id(), shader->d->shaderGuard.id());
+ glAttachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id());
} else {
d->hasPartialShaders = true;
}
@@ -843,6 +931,7 @@ bool QGLShaderProgram::addShader(QGLShader *shader)
*/
bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source)
{
+ Q_D(QGLShaderProgram);
if (!init())
return false;
QGLShader *shader = new QGLShader(type, this);
@@ -908,6 +997,7 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QString& sour
bool QGLShaderProgram::addShaderFromFile
(QGLShader::ShaderType type, const QString& fileName)
{
+ Q_D(QGLShaderProgram);
if (!init())
return false;
QGLShader *shader = new QGLShader(type, this);
@@ -927,9 +1017,10 @@ bool QGLShaderProgram::addShaderFromFile
*/
void QGLShaderProgram::removeShader(QGLShader *shader)
{
- if (d->programGuard.id() && shader && shader->d->shaderGuard.id()) {
+ Q_D(QGLShaderProgram);
+ if (d->programGuard.id() && shader && shader->d_func()->shaderGuard.id()) {
QGLShareContextScope scope(d->programGuard.context());
- glDetachShader(d->programGuard.id(), shader->d->shaderGuard.id());
+ glDetachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id());
}
d->linked = false; // Program needs to be relinked.
if (shader) {
@@ -947,6 +1038,7 @@ void QGLShaderProgram::removeShader(QGLShader *shader)
*/
QList<QGLShader *> QGLShaderProgram::shaders() const
{
+ Q_D(const QGLShaderProgram);
return d->shaders;
}
@@ -960,10 +1052,11 @@ QList<QGLShader *> QGLShaderProgram::shaders() const
*/
void QGLShaderProgram::removeAllShaders()
{
+ Q_D(QGLShaderProgram);
d->removingShaders = true;
foreach (QGLShader *shader, d->shaders) {
- if (d->programGuard.id() && shader && shader->d->shaderGuard.id())
- glDetachShader(d->programGuard.id(), shader->d->shaderGuard.id());
+ if (d->programGuard.id() && shader && shader->d_func()->shaderGuard.id())
+ glDetachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id());
}
foreach (QGLShader *shader, d->anonShaders) {
// Delete shader objects that were created anonymously.
@@ -1009,6 +1102,7 @@ void QGLShaderProgram::removeAllShaders()
QByteArray QGLShaderProgram::programBinary(int *format) const
{
#if defined(QT_OPENGL_ES_2)
+ Q_D(const QGLShaderProgram);
if (!isLinked())
return QByteArray();
@@ -1044,6 +1138,7 @@ bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary)
{
#if defined(QT_OPENGL_ES_2)
// Load the binary and check that it was linked correctly.
+ Q_D(QGLShaderProgram);
GLuint program = d->programGuard.id();
if (!program)
return false;
@@ -1113,52 +1208,47 @@ QList<int> QGLShaderProgram::programBinaryFormats()
*/
bool QGLShaderProgram::link()
{
+ Q_D(QGLShaderProgram);
GLuint program = d->programGuard.id();
if (!program)
return false;
if (d->hasPartialShaders) {
// Compile the partial vertex and fragment shaders.
- QByteArray vertexSource;
- QByteArray fragmentSource;
- foreach (QGLShader *shader, d->shaders) {
- if (shader->shaderType() == QGLShader::PartialVertexShader)
- vertexSource += shader->sourceCode();
- else if (shader->shaderType() == QGLShader::PartialFragmentShader)
- fragmentSource += shader->sourceCode();
- }
- if (vertexSource.isEmpty()) {
- if (d->vertexShader) {
- glDetachShader(program, d->vertexShader->d->shaderGuard.id());
- delete d->vertexShader;
- d->vertexShader = 0;
- }
- } else {
+ if (d->hasShader(QGLShader::PartialVertexShader)) {
if (!d->vertexShader) {
d->vertexShader =
new QGLShader(QGLShader::VertexShader, this);
}
- if (!d->vertexShader->compile(vertexSource)) {
+ if (!d->vertexShader->compile
+ (d->shaders, QGLShader::PartialVertexShader)) {
d->log = d->vertexShader->log();
return false;
}
- glAttachShader(program, d->vertexShader->d->shaderGuard.id());
- }
- if (fragmentSource.isEmpty()) {
- if (d->fragmentShader) {
- glDetachShader(program, d->fragmentShader->d->shaderGuard.id());
- delete d->fragmentShader;
- d->fragmentShader = 0;
- }
+ glAttachShader(program, d->vertexShader->d_func()->shaderGuard.id());
} else {
+ if (d->vertexShader) {
+ glDetachShader(program, d->vertexShader->d_func()->shaderGuard.id());
+ delete d->vertexShader;
+ d->vertexShader = 0;
+ }
+ }
+ if (d->hasShader(QGLShader::PartialFragmentShader)) {
if (!d->fragmentShader) {
d->fragmentShader =
new QGLShader(QGLShader::FragmentShader, this);
}
- if (!d->fragmentShader->compile(fragmentSource)) {
+ if (!d->fragmentShader->compile
+ (d->shaders, QGLShader::PartialFragmentShader)) {
d->log = d->fragmentShader->log();
return false;
}
- glAttachShader(program, d->fragmentShader->d->shaderGuard.id());
+ glAttachShader(program, d->fragmentShader->d_func()->shaderGuard.id());
+ } else {
+ if (d->fragmentShader) {
+ glDetachShader(program, d->fragmentShader->d_func()->shaderGuard.id());
+ delete d->fragmentShader;
+ d->fragmentShader = 0;
+ }
}
}
glLinkProgram(program);
@@ -1190,6 +1280,7 @@ bool QGLShaderProgram::link()
*/
bool QGLShaderProgram::isLinked() const
{
+ Q_D(const QGLShaderProgram);
return d->linked;
}
@@ -1201,6 +1292,7 @@ bool QGLShaderProgram::isLinked() const
*/
QString QGLShaderProgram::log() const
{
+ Q_D(const QGLShaderProgram);
return d->log;
}
@@ -1214,6 +1306,7 @@ QString QGLShaderProgram::log() const
*/
bool QGLShaderProgram::enable()
{
+ Q_D(QGLShaderProgram);
GLuint program = d->programGuard.id();
if (!program)
return false;
@@ -1252,6 +1345,7 @@ void QGLShaderProgram::disable()
*/
GLuint QGLShaderProgram::programId() const
{
+ Q_D(const QGLShaderProgram);
return d->programGuard.id();
}
@@ -1265,7 +1359,13 @@ GLuint QGLShaderProgram::programId() const
*/
void QGLShaderProgram::bindAttributeLocation(const char *name, int location)
{
- glBindAttribLocation(d->programGuard.id(), location, name);
+ Q_D(QGLShaderProgram);
+ if (!d->linked) {
+ glBindAttribLocation(d->programGuard.id(), location, name);
+ } else {
+ qWarning() << "QGLShaderProgram::bindAttributeLocation(" << name
+ << "): cannot bind after shader program is linked";
+ }
}
/*!
@@ -1280,7 +1380,7 @@ void QGLShaderProgram::bindAttributeLocation(const char *name, int location)
*/
void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int location)
{
- glBindAttribLocation(d->programGuard.id(), location, name.constData());
+ bindAttributeLocation(name.constData(), location);
}
/*!
@@ -1295,7 +1395,7 @@ void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int locatio
*/
void QGLShaderProgram::bindAttributeLocation(const QString& name, int location)
{
- glBindAttribLocation(d->programGuard.id(), location, name.toLatin1().constData());
+ bindAttributeLocation(name.toLatin1().constData(), location);
}
/*!
@@ -1307,6 +1407,7 @@ void QGLShaderProgram::bindAttributeLocation(const QString& name, int location)
*/
int QGLShaderProgram::attributeLocation(const char *name) const
{
+ Q_D(const QGLShaderProgram);
if (d->linked) {
return glGetAttribLocation(d->programGuard.id(), name);
} else {
@@ -1351,6 +1452,8 @@ int QGLShaderProgram::attributeLocation(const QString& name) const
*/
void QGLShaderProgram::setAttributeValue(int location, GLfloat value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glVertexAttrib1fv(location, &value);
}
@@ -1375,6 +1478,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat value)
*/
void QGLShaderProgram::setAttributeValue(int location, GLfloat x, GLfloat y)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[2] = {x, y};
glVertexAttrib2fv(location, values);
@@ -1403,6 +1508,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat x, GLfloat y)
void QGLShaderProgram::setAttributeValue
(int location, GLfloat x, GLfloat y, GLfloat z)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[3] = {x, y, z};
glVertexAttrib3fv(location, values);
@@ -1432,6 +1539,8 @@ void QGLShaderProgram::setAttributeValue
void QGLShaderProgram::setAttributeValue
(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[4] = {x, y, z, w};
glVertexAttrib4fv(location, values);
@@ -1459,6 +1568,8 @@ void QGLShaderProgram::setAttributeValue
*/
void QGLShaderProgram::setAttributeValue(int location, const QVector2D& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glVertexAttrib2fv(location, reinterpret_cast<const GLfloat *>(&value));
}
@@ -1482,6 +1593,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector2D& valu
*/
void QGLShaderProgram::setAttributeValue(int location, const QVector3D& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glVertexAttrib3fv(location, reinterpret_cast<const GLfloat *>(&value));
}
@@ -1505,6 +1618,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector3D& valu
*/
void QGLShaderProgram::setAttributeValue(int location, const QVector4D& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glVertexAttrib4fv(location, reinterpret_cast<const GLfloat *>(&value));
}
@@ -1528,6 +1643,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector4D& valu
*/
void QGLShaderProgram::setAttributeValue(int location, const QColor& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[4] = {value.redF(), value.greenF(), value.blueF(), value.alphaF()};
glVertexAttrib4fv(location, values);
@@ -1558,6 +1675,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QColor& value)
void QGLShaderProgram::setAttributeValue
(int location, const GLfloat *values, int columns, int rows)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (rows < 1 || rows > 4) {
qWarning() << "QGLShaderProgram::setAttributeValue: rows" << rows << "not supported";
return;
@@ -1607,6 +1726,8 @@ void QGLShaderProgram::setAttributeValue
void QGLShaderProgram::setAttributeArray
(int location, const GLfloat *values, int size, int stride)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE,
stride, values);
@@ -1625,6 +1746,8 @@ void QGLShaderProgram::setAttributeArray
void QGLShaderProgram::setAttributeArray
(int location, const QVector2D *values, int stride)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
glVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE,
stride, values);
@@ -1643,6 +1766,8 @@ void QGLShaderProgram::setAttributeArray
void QGLShaderProgram::setAttributeArray
(int location, const QVector3D *values, int stride)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE,
stride, values);
@@ -1661,6 +1786,8 @@ void QGLShaderProgram::setAttributeArray
void QGLShaderProgram::setAttributeArray
(int location, const QVector4D *values, int stride)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE,
stride, values);
@@ -1741,6 +1868,8 @@ void QGLShaderProgram::setAttributeArray
*/
void QGLShaderProgram::disableAttributeArray(int location)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glDisableVertexAttribArray(location);
}
@@ -1767,6 +1896,8 @@ void QGLShaderProgram::disableAttributeArray(const char *name)
*/
int QGLShaderProgram::uniformLocation(const char *name) const
{
+ Q_D(const QGLShaderProgram);
+ Q_UNUSED(d);
if (d->linked) {
return glGetUniformLocation(d->programGuard.id(), name);
} else {
@@ -1811,6 +1942,8 @@ int QGLShaderProgram::uniformLocation(const QString& name) const
*/
void QGLShaderProgram::setUniformValue(int location, GLfloat value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform1fv(location, 1, &value);
}
@@ -1835,6 +1968,8 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat value)
*/
void QGLShaderProgram::setUniformValue(int location, GLint value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform1i(location, value);
}
@@ -1860,6 +1995,8 @@ void QGLShaderProgram::setUniformValue(const char *name, GLint value)
*/
void QGLShaderProgram::setUniformValue(int location, GLuint value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform1i(location, value);
}
@@ -1885,6 +2022,8 @@ void QGLShaderProgram::setUniformValue(const char *name, GLuint value)
*/
void QGLShaderProgram::setUniformValue(int location, GLfloat x, GLfloat y)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[2] = {x, y};
glUniform2fv(location, 1, values);
@@ -1913,6 +2052,8 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat x, GLfloat y)
void QGLShaderProgram::setUniformValue
(int location, GLfloat x, GLfloat y, GLfloat z)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[3] = {x, y, z};
glUniform3fv(location, 1, values);
@@ -1942,6 +2083,8 @@ void QGLShaderProgram::setUniformValue
void QGLShaderProgram::setUniformValue
(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[4] = {x, y, z, w};
glUniform4fv(location, 1, values);
@@ -1969,6 +2112,8 @@ void QGLShaderProgram::setUniformValue
*/
void QGLShaderProgram::setUniformValue(int location, const QVector2D& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform2fv(location, 1, reinterpret_cast<const GLfloat *>(&value));
}
@@ -1993,6 +2138,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector2D& value)
*/
void QGLShaderProgram::setUniformValue(int location, const QVector3D& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform3fv(location, 1, reinterpret_cast<const GLfloat *>(&value));
}
@@ -2017,6 +2164,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector3D& value)
*/
void QGLShaderProgram::setUniformValue(int location, const QVector4D& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform4fv(location, 1, reinterpret_cast<const GLfloat *>(&value));
}
@@ -2042,6 +2191,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector4D& value)
*/
void QGLShaderProgram::setUniformValue(int location, const QColor& color)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[4] = {color.redF(), color.greenF(), color.blueF(), color.alphaF()};
glUniform4fv(location, 1, values);
@@ -2069,6 +2220,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QColor& color)
*/
void QGLShaderProgram::setUniformValue(int location, const QPoint& point)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[4] = {point.x(), point.y()};
glUniform2fv(location, 1, values);
@@ -2096,6 +2249,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPoint& point)
*/
void QGLShaderProgram::setUniformValue(int location, const QPointF& point)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[4] = {point.x(), point.y()};
glUniform2fv(location, 1, values);
@@ -2123,6 +2278,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPointF& point)
*/
void QGLShaderProgram::setUniformValue(int location, const QSize& size)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[4] = {size.width(), size.width()};
glUniform2fv(location, 1, values);
@@ -2150,6 +2307,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSize& size)
*/
void QGLShaderProgram::setUniformValue(int location, const QSizeF& size)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat values[4] = {size.width(), size.height()};
glUniform2fv(location, 1, values);
@@ -2229,6 +2388,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size)
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformMatrix(glUniformMatrix2fv, location, value, 2, 2);
}
@@ -2253,6 +2414,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x2& value
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrix
(glUniformMatrix2x3fv, glUniform3fv, location, value, 2, 3);
}
@@ -2278,6 +2441,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x3& value
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrix
(glUniformMatrix2x4fv, glUniform4fv, location, value, 2, 4);
}
@@ -2303,6 +2468,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x4& value
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrix
(glUniformMatrix3x2fv, glUniform2fv, location, value, 3, 2);
}
@@ -2328,6 +2495,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x2& value
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformMatrix(glUniformMatrix3fv, location, value, 3, 3);
}
@@ -2352,6 +2521,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x3& value
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrix
(glUniformMatrix3x4fv, glUniform4fv, location, value, 3, 4);
}
@@ -2377,6 +2548,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x4& value
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrix
(glUniformMatrix4x2fv, glUniform2fv, location, value, 4, 2);
}
@@ -2402,6 +2575,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x2& value
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrix
(glUniformMatrix4x3fv, glUniform3fv, location, value, 4, 3);
}
@@ -2427,6 +2602,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x3& value
*/
void QGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformMatrix(glUniformMatrix4fv, location, value, 4, 4);
}
@@ -2454,6 +2631,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value
*/
void QGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4])
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniformMatrix4fv(location, 1, GL_FALSE, value[0]);
}
@@ -2481,6 +2660,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[4][
*/
void QGLShaderProgram::setUniformValue(int location, const QTransform& value)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
GLfloat mat[3][3] = {
{value.m11(), value.m12(), value.m13()},
@@ -2514,6 +2695,8 @@ void QGLShaderProgram::setUniformValue
*/
void QGLShaderProgram::setUniformValueArray(int location, const GLint *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform1iv(location, count, values);
}
@@ -2541,6 +2724,8 @@ void QGLShaderProgram::setUniformValueArray
*/
void QGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform1iv(location, count, reinterpret_cast<const GLint *>(values));
}
@@ -2569,6 +2754,8 @@ void QGLShaderProgram::setUniformValueArray
*/
void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int size)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1) {
if (size == 1)
glUniform1fv(location, count, values);
@@ -2606,6 +2793,8 @@ void QGLShaderProgram::setUniformValueArray
*/
void QGLShaderProgram::setUniformValueArray(int location, const QVector2D *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform2fv(location, count, reinterpret_cast<const GLfloat *>(values));
}
@@ -2631,6 +2820,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector2D *v
*/
void QGLShaderProgram::setUniformValueArray(int location, const QVector3D *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform3fv(location, count, reinterpret_cast<const GLfloat *>(values));
}
@@ -2656,6 +2847,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector3D *v
*/
void QGLShaderProgram::setUniformValueArray(int location, const QVector4D *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
if (location != -1)
glUniform4fv(location, count, reinterpret_cast<const GLfloat *>(values));
}
@@ -2742,6 +2935,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector4D *v
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x2 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformMatrixArray
(glUniformMatrix2fv, location, values, count, QMatrix2x2, 2, 2);
}
@@ -2767,6 +2962,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x2 *
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x3 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrixArray
(glUniformMatrix2x3fv, glUniform3fv, location, values, count,
QMatrix2x3, 2, 3);
@@ -2793,6 +2990,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x3 *
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x4 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrixArray
(glUniformMatrix2x4fv, glUniform4fv, location, values, count,
QMatrix2x4, 2, 4);
@@ -2819,6 +3018,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x4 *
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x2 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrixArray
(glUniformMatrix3x2fv, glUniform2fv, location, values, count,
QMatrix3x2, 3, 2);
@@ -2845,6 +3046,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x2 *
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x3 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformMatrixArray
(glUniformMatrix3fv, location, values, count, QMatrix3x3, 3, 3);
}
@@ -2870,6 +3073,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x3 *
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x4 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrixArray
(glUniformMatrix3x4fv, glUniform4fv, location, values, count,
QMatrix3x4, 3, 4);
@@ -2896,6 +3101,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x4 *
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x2 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrixArray
(glUniformMatrix4x2fv, glUniform2fv, location, values, count,
QMatrix4x2, 4, 2);
@@ -2922,6 +3129,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x2 *
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x3 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformGenericMatrixArray
(glUniformMatrix4x3fv, glUniform3fv, location, values, count,
QMatrix4x3, 4, 3);
@@ -2948,6 +3157,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x3 *
*/
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x4 *values, int count)
{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
setUniformMatrixArray
(glUniformMatrix4fv, location, values, count, QMatrix4x4, 4, 4);
}
@@ -2993,6 +3204,7 @@ bool QGLShaderProgram::hasShaderPrograms(const QGLContext *context)
*/
void QGLShaderProgram::shaderDestroyed()
{
+ Q_D(QGLShaderProgram);
QGLShader *shader = qobject_cast<QGLShader *>(sender());
if (shader && !d->removingShaders)
removeShader(shader);
diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h
index f2d70fa..d8b9a0c 100644
--- a/src/opengl/qglshaderprogram.h
+++ b/src/opengl/qglshaderprogram.h
@@ -101,11 +101,12 @@ public:
GLuint shaderId() const;
private:
- QGLShaderPrivate *d;
-
friend class QGLShaderProgram;
Q_DISABLE_COPY(QGLShader)
+ Q_DECLARE_PRIVATE(QGLShader)
+
+ bool compile(const QList<QGLShader *>& shaders, QGLShader::ShaderType type);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType)
@@ -286,9 +287,8 @@ private Q_SLOTS:
void shaderDestroyed();
private:
- QGLShaderProgramPrivate *d;
-
Q_DISABLE_COPY(QGLShaderProgram)
+ Q_DECLARE_PRIVATE(QGLShaderProgram)
bool init();
};
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 4547416..42e1c1e 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -364,7 +364,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
if (ctxpriv->eglSurface == EGL_NO_SURFACE) {
qWarning() << "hijackWindow() could not create EGL surface";
}
- qDebug("QGLWindowSurface - using EGLConfig %d", ctxpriv->eglContext->config());
+ qDebug("QGLWindowSurface - using EGLConfig %d", reinterpret_cast<int>(ctxpriv->eglContext->config()));
#endif
widgetPrivate->extraData()->glContext = ctx;
diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp
index 8ef239d..db81be2 100644
--- a/src/opengl/qwindowsurface_x11gl.cpp
+++ b/src/opengl/qwindowsurface_x11gl.cpp
@@ -124,6 +124,9 @@ void QX11GLWindowSurface::setGeometry(const QRect &rect)
bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
+ Q_UNUSED(area);
+ Q_UNUSED(dx);
+ Q_UNUSED(dy);
return false;
}
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index da07c1d..94e0793 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3455,28 +3455,24 @@ void QVGCompositionHelper::blitWindow
// Set the image transform.
QTransform transform;
int y = screenSize.height() - (rect.bottom() + 1);
- transform.translate(rect.x() + 0.5f, y + 0.5f);
+ transform.translate(rect.x() - 0.5f, y - 0.5f);
d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
// Enable opacity for image drawing if necessary.
- if (opacity < 255) {
- if (opacity != d->paintOpacity) {
- VGfloat values[4];
- values[0] = 1.0f;
- values[1] = 1.0f;
- values[2] = 1.0f;
- values[3] = ((VGfloat)opacity) / 255.0f;
- vgSetParameterfv(d->opacityPaint, VG_PAINT_COLOR, 4, values);
- d->paintOpacity = values[3];
- }
- if (d->fillPaint != d->opacityPaint) {
- vgSetPaint(d->opacityPaint, VG_FILL_PATH);
- d->fillPaint = d->opacityPaint;
- }
- d->setImageMode(VG_DRAW_IMAGE_MULTIPLY);
- } else {
- d->setImageMode(VG_DRAW_IMAGE_NORMAL);
+ if (opacity != d->paintOpacity) {
+ VGfloat values[4];
+ values[0] = 1.0f;
+ values[1] = 1.0f;
+ values[2] = 1.0f;
+ values[3] = ((VGfloat)opacity) / 255.0f;
+ vgSetParameterfv(d->opacityPaint, VG_PAINT_COLOR, 4, values);
+ d->paintOpacity = values[3];
}
+ if (d->fillPaint != d->opacityPaint) {
+ vgSetPaint(d->opacityPaint, VG_FILL_PATH);
+ d->fillPaint = d->opacityPaint;
+ }
+ d->setImageMode(VG_DRAW_IMAGE_MULTIPLY);
// Draw the child image.
vgDrawImage(child);
@@ -3527,27 +3523,55 @@ static void fillBackgroundRect(const QRect& rect, QVGPaintEnginePrivate *d)
void QVGCompositionHelper::fillBackground
(const QRegion& region, const QBrush& brush)
{
- // Set the path transform to the default viewport transformation.
- VGfloat devh = screenSize.height() - 1;
- QTransform viewport(1.0f, 0.0f, 0.0f,
- 0.0f, -1.0f, 0.0f,
- 0.5f, devh + 0.5f, 1.0f);
- d->setTransform(VG_MATRIX_PATH_USER_TO_SURFACE, viewport);
-
- // Set the brush to use to fill the background.
- d->ensureBrush(brush);
- d->setFillRule(VG_EVEN_ODD);
+ if (brush.style() == Qt::SolidPattern) {
+ // Use vgClear() to quickly fill the background.
+ QColor color = brush.color();
+ if (d->clearColor != color || d->clearOpacity != 1.0f) {
+ VGfloat values[4];
+ values[0] = color.redF();
+ values[1] = color.greenF();
+ values[2] = color.blueF();
+ values[3] = color.alphaF();
+ vgSetfv(VG_CLEAR_COLOR, 4, values);
+ d->clearColor = color;
+ d->clearOpacity = 1.0f;
+ }
+ if (region.numRects() == 1) {
+ QRect r = region.boundingRect();
+ vgClear(r.x(), screenSize.height() - r.y() - r.height(),
+ r.width(), r.height());
+ } else {
+ const QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ QRect r = rects.at(i);
+ vgClear(r.x(), screenSize.height() - r.y() - r.height(),
+ r.width(), r.height());
+ }
+ }
- if (region.numRects() == 1) {
- fillBackgroundRect(region.boundingRect(), d);
} else {
- const QVector<QRect> rects = region.rects();
- for (int i = 0; i < rects.size(); ++i)
- fillBackgroundRect(rects.at(i), d);
- }
+ // Set the path transform to the default viewport transformation.
+ VGfloat devh = screenSize.height() - 1;
+ QTransform viewport(1.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f,
+ -0.5f, devh + 0.5f, 1.0f);
+ d->setTransform(VG_MATRIX_PATH_USER_TO_SURFACE, viewport);
+
+ // Set the brush to use to fill the background.
+ d->ensureBrush(brush);
+ d->setFillRule(VG_EVEN_ODD);
+
+ if (region.numRects() == 1) {
+ fillBackgroundRect(region.boundingRect(), d);
+ } else {
+ const QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ fillBackgroundRect(rects.at(i), d);
+ }
- // We will need to reset the path transform during the next paint.
- d->pathTransformSet = false;
+ // We will need to reset the path transform during the next paint.
+ d->pathTransformSet = false;
+ }
}
void QVGCompositionHelper::drawCursorImage
@@ -3584,7 +3608,7 @@ void QVGCompositionHelper::drawCursorPixmap
VGfloat devh = screenSize.height() - 1;
QTransform transform(1.0f, 0.0f, 0.0f,
0.0f, -1.0f, 0.0f,
- 0.5f, devh + 0.5f, 1.0f);
+ -0.5f, devh + 0.5f, 1.0f);
transform.translate(offset.x(), offset.y());
d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
diff --git a/src/qt3support/widgets/q3dockwindow.cpp b/src/qt3support/widgets/q3dockwindow.cpp
index 46ad86c..80d30c4 100644
--- a/src/qt3support/widgets/q3dockwindow.cpp
+++ b/src/qt3support/widgets/q3dockwindow.cpp
@@ -409,7 +409,7 @@ Q3DockWindowHandle::Q3DockWindowHandle(Q3DockWindow *dw)
ctrlDown = false;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(minimize()));
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN) && !defined(QT_NO_CURSOR)
setCursor(Qt::SizeAllCursor);
#endif
}
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 3f2c9b4..9288723 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -343,15 +343,10 @@ public:
namespace QScript
{
-struct GlobalClientData : public JSC::JSGlobalData::ClientData
+void GlobalClientData::mark(JSC::MarkStack& markStack)
{
- GlobalClientData(QScriptEnginePrivate *e)
- : engine(e) {}
- virtual ~GlobalClientData() {}
- virtual void mark(JSC::MarkStack& markStack) { engine->mark(markStack); }
-
- QScriptEnginePrivate *engine;
-};
+ engine->mark(markStack);
+}
class TimeoutCheckerProxy : public JSC::TimeoutChecker
{
@@ -452,11 +447,6 @@ qsreal integerFromString(const QString &str, int radix)
return integerFromString(ba.constData(), ba.size(), radix);
}
-QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec)
-{
- return static_cast<GlobalClientData*>(exec->globalData().clientData)->engine;
-}
-
bool isFunction(JSC::JSValue value)
{
if (!value || !value.isObject())
@@ -995,26 +985,6 @@ void QScriptEnginePrivate::setDefaultPrototype(int metaTypeId, JSC::JSValue prot
info->prototype = prototype;
}
-QScriptContext *QScriptEnginePrivate::contextForFrame(JSC::ExecState *frame)
-{
- if (frame && frame->callerFrame()->hasHostCallFrameFlag() && !frame->callee()
- && frame->callerFrame()->removeHostCallFrameFlag() == QScript::scriptEngineFromExec(frame)->globalExec()) {
- //skip the "fake" context created in Interpreter::execute.
- frame = frame->callerFrame()->removeHostCallFrameFlag();
- }
- return reinterpret_cast<QScriptContext *>(frame);
-}
-
-JSC::ExecState *QScriptEnginePrivate::frameForContext(QScriptContext *context)
-{
- return reinterpret_cast<JSC::ExecState*>(context);
-}
-
-const JSC::ExecState *QScriptEnginePrivate::frameForContext(const QScriptContext *context)
-{
- return reinterpret_cast<const JSC::ExecState*>(context);
-}
-
JSC::JSGlobalObject *QScriptEnginePrivate::originalGlobalObject() const
{
return globalData->head;
@@ -1056,11 +1026,6 @@ void QScriptEnginePrivate::setGlobalObject(JSC::JSObject *object)
}
}
-JSC::ExecState *QScriptEnginePrivate::globalExec() const
-{
- return originalGlobalObject()->globalExec();
-}
-
/*!
\internal
@@ -2543,63 +2508,50 @@ QScriptValue QScriptEngine::create(int type, const void *ptr)
QScriptValue QScriptEnginePrivate::create(int type, const void *ptr)
{
+ Q_Q(QScriptEngine);
Q_ASSERT(ptr != 0);
QScriptValue result;
QScriptTypeInfo *info = m_typeInfos.value(type);
if (info && info->marshal) {
- result = info->marshal(q_func(), ptr);
+ result = info->marshal(q, ptr);
} else {
// check if it's one of the types we know
switch (QMetaType::Type(type)) {
case QMetaType::Void:
- result = QScriptValue(QScriptValue::UndefinedValue);
- break;
+ return QScriptValue(q, QScriptValue::UndefinedValue);
case QMetaType::Bool:
- result = QScriptValue(*reinterpret_cast<const bool*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const bool*>(ptr));
case QMetaType::Int:
- result = QScriptValue(*reinterpret_cast<const int*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const int*>(ptr));
case QMetaType::UInt:
- result = QScriptValue(*reinterpret_cast<const uint*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const uint*>(ptr));
case QMetaType::LongLong:
- result = QScriptValue(qsreal(*reinterpret_cast<const qlonglong*>(ptr)));
- break;
+ return QScriptValue(q, qsreal(*reinterpret_cast<const qlonglong*>(ptr)));
case QMetaType::ULongLong:
#if defined(Q_OS_WIN) && defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 12008804
#pragma message("** NOTE: You need the Visual Studio Processor Pack to compile support for 64bit unsigned integers.")
- result = QScriptValue(qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
+ return QScriptValue(q, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
#elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
- result = QScriptValue(qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
+ return QScriptValue(q, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
#else
- result = QScriptValue(qsreal(*reinterpret_cast<const qulonglong*>(ptr)));
+ return QScriptValue(q, qsreal(*reinterpret_cast<const qulonglong*>(ptr)));
#endif
- break;
case QMetaType::Double:
- result = QScriptValue(qsreal(*reinterpret_cast<const double*>(ptr)));
- break;
+ return QScriptValue(q, qsreal(*reinterpret_cast<const double*>(ptr)));
case QMetaType::QString:
- result = QScriptValue(q_func(), *reinterpret_cast<const QString*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const QString*>(ptr));
case QMetaType::Float:
- result = QScriptValue(*reinterpret_cast<const float*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const float*>(ptr));
case QMetaType::Short:
- result = QScriptValue(*reinterpret_cast<const short*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const short*>(ptr));
case QMetaType::UShort:
- result = QScriptValue(*reinterpret_cast<const unsigned short*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const unsigned short*>(ptr));
case QMetaType::Char:
- result = QScriptValue(*reinterpret_cast<const char*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const char*>(ptr));
case QMetaType::UChar:
- result = QScriptValue(*reinterpret_cast<const unsigned char*>(ptr));
- break;
+ return QScriptValue(q, *reinterpret_cast<const unsigned char*>(ptr));
case QMetaType::QChar:
- result = QScriptValue((*reinterpret_cast<const QChar*>(ptr)).unicode());
- break;
+ return QScriptValue(q, (*reinterpret_cast<const QChar*>(ptr)).unicode());
case QMetaType::QStringList:
result = arrayFromStringList(*reinterpret_cast<const QStringList *>(ptr));
break;
@@ -2610,38 +2562,38 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr)
result = objectFromVariantMap(*reinterpret_cast<const QVariantMap *>(ptr));
break;
case QMetaType::QDateTime:
- result = q_func()->newDate(*reinterpret_cast<const QDateTime *>(ptr));
+ result = q->newDate(*reinterpret_cast<const QDateTime *>(ptr));
break;
case QMetaType::QDate:
- result = q_func()->newDate(QDateTime(*reinterpret_cast<const QDate *>(ptr)));
+ result = q->newDate(QDateTime(*reinterpret_cast<const QDate *>(ptr)));
break;
#ifndef QT_NO_REGEXP
case QMetaType::QRegExp:
- result = q_func()->newRegExp(*reinterpret_cast<const QRegExp *>(ptr));
+ result = q->newRegExp(*reinterpret_cast<const QRegExp *>(ptr));
break;
#endif
#ifndef QT_NO_QOBJECT
case QMetaType::QObjectStar:
case QMetaType::QWidgetStar:
- result = q_func()->newQObject(*reinterpret_cast<QObject* const *>(ptr));
+ result = q->newQObject(*reinterpret_cast<QObject* const *>(ptr));
break;
#endif
default:
if (type == qMetaTypeId<QScriptValue>()) {
result = *reinterpret_cast<const QScriptValue*>(ptr);
if (!result.isValid())
- result = QScriptValue(QScriptValue::UndefinedValue);
+ return QScriptValue(q, QScriptValue::UndefinedValue);
}
#ifndef QT_NO_QOBJECT
// lazy registration of some common list types
else if (type == qMetaTypeId<QObjectList>()) {
- qScriptRegisterSequenceMetaType<QObjectList>(q_func());
+ qScriptRegisterSequenceMetaType<QObjectList>(q);
return create(type, ptr);
}
#endif
else if (type == qMetaTypeId<QList<int> >()) {
- qScriptRegisterSequenceMetaType<QList<int> >(q_func());
+ qScriptRegisterSequenceMetaType<QList<int> >(q);
return create(type, ptr);
}
@@ -2650,9 +2602,9 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr)
if (typeName == "QVariant")
result = scriptValueFromVariant(*reinterpret_cast<const QVariant*>(ptr));
if (typeName.endsWith('*') && !*reinterpret_cast<void* const *>(ptr))
- result = QScriptValue(QScriptValue::NullValue);
+ return QScriptValue(q, QScriptValue::NullValue);
else
- result = q_func()->newVariant(QVariant(type, ptr));
+ result = q->newVariant(QVariant(type, ptr));
}
}
}
@@ -2667,8 +2619,8 @@ bool QScriptEnginePrivate::convert(const QScriptValue &value,
int type, void *ptr,
QScriptEnginePrivate *eng)
{
- if (!eng && value.engine())
- eng = QScriptEnginePrivate::get(value.engine());
+ if (!eng)
+ eng = QScriptValuePrivate::getEngine(value);
if (eng) {
QScriptTypeInfo *info = eng->m_typeInfos.value(type);
if (info && info->demarshal) {
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 3766559..ec7c144 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -101,11 +101,22 @@ namespace QScript
class TimeoutCheckerProxy;
//some conversion helper functions
- QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec);
+ inline QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec);
bool isFunction(JSC::JSValue value);
class UStringSourceProviderWithFeedback;
-}
+
+struct GlobalClientData : public JSC::JSGlobalData::ClientData
+{
+ GlobalClientData(QScriptEnginePrivate *e)
+ : engine(e) {}
+ virtual ~GlobalClientData() {}
+ virtual void mark(JSC::MarkStack& markStack);
+
+ QScriptEnginePrivate *engine;
+};
+
+} // namespace QScript
class QScriptEnginePrivate
#ifndef QT_NO_QOBJECT
@@ -147,16 +158,16 @@ public:
JSC::JSValue defaultPrototype(int metaTypeId) const;
void setDefaultPrototype(int metaTypeId, JSC::JSValue prototype);
- static QScriptContext *contextForFrame(JSC::ExecState *frame);
- static JSC::ExecState *frameForContext(QScriptContext *context);
- static const JSC::ExecState *frameForContext(const QScriptContext *context);
+ static inline QScriptContext *contextForFrame(JSC::ExecState *frame);
+ static inline JSC::ExecState *frameForContext(QScriptContext *context);
+ static inline const JSC::ExecState *frameForContext(const QScriptContext *context);
JSC::JSGlobalObject *originalGlobalObject() const;
JSC::JSObject *getOriginalGlobalObjectProxy();
JSC::JSObject *customGlobalObject() const;
JSC::JSObject *globalObject() const;
void setGlobalObject(JSC::JSObject *object);
- JSC::ExecState *globalExec() const;
+ inline JSC::ExecState *globalExec() const;
JSC::JSValue toUsableValue(JSC::JSValue value);
static JSC::JSValue thisForContext(JSC::ExecState *frame);
static JSC::Register *thisRegisterForFrame(JSC::ExecState *frame);
@@ -367,6 +378,11 @@ private:
JSC::ExecState *oldFrame;
};
+inline QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec)
+{
+ return static_cast<GlobalClientData*>(exec->globalData().clientData)->engine;
+}
+
} // namespace QScript
inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(size_t size)
@@ -473,6 +489,28 @@ inline QScriptValue QScriptValuePrivate::property(const QString &name, int resol
return property(JSC::Identifier(exec, name), resolveMode);
}
+inline QScriptValue QScriptValuePrivate::property(const JSC::Identifier &id, int resolveMode) const
+{
+ Q_ASSERT(isObject());
+ JSC::ExecState *exec = engine->currentFrame;
+ JSC::JSObject *object = JSC::asObject(jscValue);
+ JSC::PropertySlot slot(object);
+ if ((resolveMode & QScriptValue::ResolvePrototype) && object->getPropertySlot(exec, id, slot))
+ return engine->scriptValueFromJSCValue(slot.getValue(exec, id));
+ return propertyHelper(id, resolveMode);
+}
+
+inline QScriptValue QScriptValuePrivate::property(quint32 index, int resolveMode) const
+{
+ Q_ASSERT(isObject());
+ JSC::ExecState *exec = engine->currentFrame;
+ JSC::JSObject *object = JSC::asObject(jscValue);
+ JSC::PropertySlot slot(object);
+ if ((resolveMode & QScriptValue::ResolvePrototype) && object->getPropertySlot(exec, index, slot))
+ return engine->scriptValueFromJSCValue(slot.getValue(exec, index));
+ return propertyHelper(index, resolveMode);
+}
+
inline void* QScriptValuePrivate::operator new(size_t size, QScriptEnginePrivate *engine)
{
if (engine)
@@ -489,6 +527,22 @@ inline void QScriptValuePrivate::operator delete(void *ptr)
qFree(d);
}
+inline void QScriptValuePrivate::saveException(JSC::ExecState *exec, JSC::JSValue *val)
+{
+ if (exec) {
+ *val = exec->exception();
+ exec->clearException();
+ } else {
+ *val = JSC::JSValue();
+ }
+}
+
+inline void QScriptValuePrivate::restoreException(JSC::ExecState *exec, JSC::JSValue val)
+{
+ if (exec && val)
+ exec->setException(val);
+}
+
inline void QScriptEnginePrivate::registerScriptString(QScriptStringPrivate *value)
{
Q_ASSERT(value->type == QScriptStringPrivate::HeapAllocated);
@@ -512,6 +566,31 @@ inline void QScriptEnginePrivate::unregisterScriptString(QScriptStringPrivate *v
value->next = 0;
}
+inline QScriptContext *QScriptEnginePrivate::contextForFrame(JSC::ExecState *frame)
+{
+ if (frame && frame->callerFrame()->hasHostCallFrameFlag() && !frame->callee()
+ && frame->callerFrame()->removeHostCallFrameFlag() == QScript::scriptEngineFromExec(frame)->globalExec()) {
+ //skip the "fake" context created in Interpreter::execute.
+ frame = frame->callerFrame()->removeHostCallFrameFlag();
+ }
+ return reinterpret_cast<QScriptContext *>(frame);
+}
+
+inline JSC::ExecState *QScriptEnginePrivate::frameForContext(QScriptContext *context)
+{
+ return reinterpret_cast<JSC::ExecState*>(context);
+}
+
+inline const JSC::ExecState *QScriptEnginePrivate::frameForContext(const QScriptContext *context)
+{
+ return reinterpret_cast<const JSC::ExecState*>(context);
+}
+
+inline JSC::ExecState *QScriptEnginePrivate::globalExec() const
+{
+ return originalGlobalObject()->globalExec();
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp
index 2fb157f..1ede51c 100644
--- a/src/script/api/qscriptstring.cpp
+++ b/src/script/api/qscriptstring.cpp
@@ -139,8 +139,7 @@ QScriptString &QScriptString::operator=(const QScriptString &other)
*/
bool QScriptString::isValid() const
{
- Q_D(const QScriptString);
- return (d && d->engine);
+ return QScriptStringPrivate::isValid(*this);
}
/*!
diff --git a/src/script/api/qscriptstring_p.h b/src/script/api/qscriptstring_p.h
index d3bb47d..8e344e8 100644
--- a/src/script/api/qscriptstring_p.h
+++ b/src/script/api/qscriptstring_p.h
@@ -77,6 +77,8 @@ public:
inline void detachFromEngine();
+ static inline bool isValid(const QScriptString &q);
+
QBasicAtomicInt ref;
QScriptEnginePrivate *engine;
JSC::Identifier identifier;
@@ -114,6 +116,11 @@ inline void QScriptStringPrivate::detachFromEngine()
identifier = JSC::Identifier();
}
+inline bool QScriptStringPrivate::isValid(const QScriptString &q)
+{
+ return (q.d_ptr && q.d_ptr->engine);
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index 26cd314..52a1e6d 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -276,41 +276,36 @@ qsreal ToInteger(qsreal n)
} // namespace QScript
-QScriptValue QScriptValuePrivate::property(const JSC::Identifier &id, int resolveMode) const
+QScriptValue QScriptValuePrivate::propertyHelper(const JSC::Identifier &id, int resolveMode) const
{
- Q_ASSERT(isObject());
- JSC::ExecState *exec = engine->currentFrame;
- JSC::JSObject *object = JSC::asObject(jscValue);
- JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object));
JSC::JSValue result;
- if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) {
- result = slot.getValue(exec, id);
- } else {
- if ((resolveMode & QScriptValue::ResolvePrototype)
- && const_cast<JSC::JSObject*>(object)->getPropertySlot(exec, id, slot)) {
+ if (!(resolveMode & QScriptValue::ResolvePrototype)) {
+ // Look in the object's own properties
+ JSC::ExecState *exec = engine->currentFrame;
+ JSC::JSObject *object = JSC::asObject(jscValue);
+ JSC::PropertySlot slot(object);
+ if (object->getOwnPropertySlot(exec, id, slot))
result = slot.getValue(exec, id);
- } else if (resolveMode & QScriptValue::ResolveScope) {
- // ### check if it's a function object and look in the scope chain
- QScriptValue scope = property(QString::fromLatin1("__qt_scope__"), QScriptValue::ResolveLocal);
- if (scope.isObject())
- result = engine->scriptValueToJSCValue(QScriptValuePrivate::get(scope)->property(id, resolveMode));
- }
+ }
+ if (!result && (resolveMode & QScriptValue::ResolveScope)) {
+ // ### check if it's a function object and look in the scope chain
+ QScriptValue scope = property(QString::fromLatin1("__qt_scope__"), QScriptValue::ResolveLocal);
+ if (scope.isObject())
+ result = engine->scriptValueToJSCValue(QScriptValuePrivate::get(scope)->property(id, resolveMode));
}
return engine->scriptValueFromJSCValue(result);
}
-QScriptValue QScriptValuePrivate::property(quint32 index, int resolveMode) const
+QScriptValue QScriptValuePrivate::propertyHelper(quint32 index, int resolveMode) const
{
- Q_ASSERT(isObject());
- JSC::ExecState *exec = engine->currentFrame;
- JSC::JSObject *object = JSC::asObject(jscValue);
- JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object));
JSC::JSValue result;
- if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, index, slot)) {
- result = slot.getValue(exec, index);
- } else if ((resolveMode & QScriptValue::ResolvePrototype)
- && const_cast<JSC::JSObject*>(object)->getPropertySlot(exec, index, slot)) {
- result = slot.getValue(exec, index);
+ if (!(resolveMode & QScriptValue::ResolvePrototype)) {
+ // Look in the object's own properties
+ JSC::ExecState *exec = engine->currentFrame;
+ JSC::JSObject *object = JSC::asObject(jscValue);
+ JSC::PropertySlot slot(object);
+ if (object->getOwnPropertySlot(exec, index, slot))
+ result = slot.getValue(exec, index);
}
return engine->scriptValueFromJSCValue(result);
}
@@ -318,8 +313,8 @@ QScriptValue QScriptValuePrivate::property(quint32 index, int resolveMode) const
void QScriptValuePrivate::setProperty(const JSC::Identifier &id, const QScriptValue &value,
const QScriptValue::PropertyFlags &flags)
{
- QScriptEngine *valueEngine = value.engine();
- if (valueEngine && (QScriptEnginePrivate::get(valueEngine) != engine)) {
+ QScriptEnginePrivate *valueEngine = QScriptValuePrivate::getEngine(value);
+ if (valueEngine && (valueEngine != engine)) {
qWarning("QScriptValue::setProperty(%s) failed: "
"cannot set value created in a different engine",
qPrintable(QString(id.ustring())));
@@ -443,22 +438,6 @@ void QScriptValuePrivate::setVariantValue(const QVariant &value)
static_cast<QScript::QVariantDelegate*>(delegate)->setValue(value);
}
-void QScriptValuePrivate::saveException(JSC::ExecState *exec, JSC::JSValue *val)
-{
- if (exec) {
- *val = exec->exception();
- exec->clearException();
- } else {
- *val = JSC::JSValue();
- }
-}
-
-void QScriptValuePrivate::restoreException(JSC::ExecState *exec, JSC::JSValue val)
-{
- if (exec && val)
- exec->setException(val);
-}
-
void QScriptValuePrivate::detachFromEngine()
{
if (isJSC())
@@ -822,8 +801,8 @@ void QScriptValue::setPrototype(const QScriptValue &prototype)
Q_D(QScriptValue);
if (!d || !d->isObject())
return;
- if (prototype.isValid() && prototype.engine()
- && (prototype.engine() != engine())) {
+ if (prototype.isValid() && QScriptValuePrivate::getEngine(prototype)
+ && (QScriptValuePrivate::getEngine(prototype) != d->engine)) {
qWarning("QScriptValue::setPrototype() failed: "
"cannot set a prototype created in "
"a different engine");
@@ -864,8 +843,8 @@ void QScriptValue::setScope(const QScriptValue &scope)
Q_D(QScriptValue);
if (!d || !d->isObject())
return;
- if (scope.isValid() && scope.engine()
- && (scope.engine() != engine())) {
+ if (scope.isValid() && QScriptValuePrivate::getEngine(scope)
+ && (QScriptValuePrivate::getEngine(scope) != d->engine)) {
qWarning("QScriptValue::setScope() failed: "
"cannot set a scope object created in "
"a different engine");
@@ -896,7 +875,7 @@ bool QScriptValue::instanceOf(const QScriptValue &other) const
Q_D(const QScriptValue);
if (!d || !d->isObject() || !other.isObject())
return false;
- if (other.engine() != engine()) {
+ if (QScriptValuePrivate::getEngine(other) != d->engine) {
qWarning("QScriptValue::instanceof: "
"cannot perform operation on a value created in "
"a different engine");
@@ -1083,10 +1062,12 @@ static bool Equals(QScriptValue lhs, QScriptValue rhs)
*/
bool QScriptValue::lessThan(const QScriptValue &other) const
{
+ Q_D(const QScriptValue);
// no equivalent function in JSC? There's a jsLess() in VM/Machine.cpp
if (!isValid() || !other.isValid())
return false;
- if (other.engine() && engine() && (other.engine() != engine())) {
+ if (QScriptValuePrivate::getEngine(other) && d->engine
+ && (QScriptValuePrivate::getEngine(other) != d->engine)) {
qWarning("QScriptValue::lessThan: "
"cannot compare to a value created in "
"a different engine");
@@ -1124,7 +1105,8 @@ bool QScriptValue::equals(const QScriptValue &other) const
Q_D(const QScriptValue);
if (!d || !other.d_ptr)
return (d_ptr == other.d_ptr);
- if (other.engine() && engine() && (other.engine() != engine())) {
+ if (QScriptValuePrivate::getEngine(other) && d->engine
+ && (QScriptValuePrivate::getEngine(other) != d->engine)) {
qWarning("QScriptValue::equals: "
"cannot compare to a value created in "
"a different engine");
@@ -1173,7 +1155,8 @@ bool QScriptValue::strictlyEquals(const QScriptValue &other) const
Q_D(const QScriptValue);
if (!d || !other.d_ptr)
return (d_ptr == other.d_ptr);
- if (other.engine() && engine() && (other.engine() != engine())) {
+ if (QScriptValuePrivate::getEngine(other) && d->engine
+ && (QScriptValuePrivate::getEngine(other) != d->engine)) {
qWarning("QScriptValue::strictlyEquals: "
"cannot compare to a value created in "
"a different engine");
@@ -1725,7 +1708,8 @@ void QScriptValue::setProperty(quint32 arrayIndex, const QScriptValue &value,
Q_D(QScriptValue);
if (!d || !d->isObject())
return;
- if (value.engine() && (value.engine() != engine())) {
+ if (QScriptValuePrivate::getEngine(value)
+ && (QScriptValuePrivate::getEngine(value) != d->engine)) {
qWarning("QScriptValue::setProperty() failed: "
"cannot set value created in a different engine");
return;
@@ -1775,7 +1759,7 @@ QScriptValue QScriptValue::property(const QScriptString &name,
const ResolveFlags &mode) const
{
Q_D(const QScriptValue);
- if (!d || !d->isObject() || !name.isValid())
+ if (!d || !d->isObject() || !QScriptStringPrivate::isValid(name))
return QScriptValue();
return d->property(name.d_ptr->identifier, mode);
}
@@ -1798,7 +1782,7 @@ void QScriptValue::setProperty(const QScriptString &name,
const PropertyFlags &flags)
{
Q_D(QScriptValue);
- if (!d || !d->isObject() || !name.isValid())
+ if (!d || !d->isObject() || !QScriptStringPrivate::isValid(name))
return;
d->setProperty(name.d_ptr->identifier, value, flags);
}
@@ -1832,7 +1816,7 @@ QScriptValue::PropertyFlags QScriptValue::propertyFlags(const QScriptString &nam
const ResolveFlags &mode) const
{
Q_D(const QScriptValue);
- if (!d || !d->isObject() || !name.isValid())
+ if (!d || !d->isObject() || !QScriptStringPrivate::isValid(name))
return 0;
return d->propertyFlags(name.d_ptr->identifier, mode);
}
@@ -1872,7 +1856,8 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
if (callType == JSC::CallTypeNone)
return QScriptValue();
- if (thisObject.engine() && (thisObject.engine() != engine())) {
+ if (QScriptValuePrivate::getEngine(thisObject)
+ && (QScriptValuePrivate::getEngine(thisObject) != d->engine)) {
qWarning("QScriptValue::call() failed: "
"cannot call function with thisObject created in "
"a different engine");
@@ -1890,7 +1875,8 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
const QScriptValue &arg = args.at(i);
if (!arg.isValid()) {
argsVector[i] = JSC::jsUndefined();
- } else if (arg.engine() && (arg.engine() != engine())) {
+ } else if (QScriptValuePrivate::getEngine(arg)
+ && (QScriptValuePrivate::getEngine(arg) != d->engine)) {
qWarning("QScriptValue::call() failed: "
"cannot call function with argument created in "
"a different engine");
@@ -1947,7 +1933,8 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
if (callType == JSC::CallTypeNone)
return QScriptValue();
- if (thisObject.engine() && (thisObject.engine() != engine())) {
+ if (QScriptValuePrivate::getEngine(thisObject)
+ && (QScriptValuePrivate::getEngine(thisObject) != d->engine)) {
qWarning("QScriptValue::call() failed: "
"cannot call function with thisObject created in "
"a different engine");
diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h
index 9634515..c322a37 100644
--- a/src/script/api/qscriptvalue_p.h
+++ b/src/script/api/qscriptvalue_p.h
@@ -100,8 +100,17 @@ public:
return QScriptValue(d);
}
- QScriptValue property(const JSC::Identifier &id, int resolveMode) const;
- QScriptValue property(quint32 index, int resolveMode) const;
+ static inline QScriptEnginePrivate *getEngine(const QScriptValue &q)
+ {
+ if (!q.d_ptr)
+ return 0;
+ return q.d_ptr->engine;
+ }
+
+ inline QScriptValue property(const JSC::Identifier &id, int resolveMode) const;
+ QScriptValue propertyHelper(const JSC::Identifier &id, int resolveMode) const;
+ inline QScriptValue property(quint32 index, int resolveMode) const;
+ QScriptValue propertyHelper(quint32, int resolveMode) const;
inline QScriptValue property(const QString &, int resolveMode) const;
void setProperty(const JSC::Identifier &id, const QScriptValue &value,
const QScriptValue::PropertyFlags &flags);
@@ -118,8 +127,8 @@ public:
return -1;
}
- static void saveException(JSC::ExecState*, JSC::JSValue*);
- static void restoreException(JSC::ExecState*, JSC::JSValue);
+ static inline void saveException(JSC::ExecState*, JSC::JSValue*);
+ static inline void restoreException(JSC::ExecState*, JSC::JSValue);
QScriptEnginePrivate *engine;
Type type;
diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp
index 0d88532..1dde98b 100644
--- a/src/script/bridge/qscriptclassobject.cpp
+++ b/src/script/bridge/qscriptclassobject.cpp
@@ -70,17 +70,6 @@ ClassObjectDelegate::~ClassObjectDelegate()
{
}
-QScriptClass *ClassObjectDelegate::scriptClass() const
-{
- return m_scriptClass;
-}
-
-void ClassObjectDelegate::setScriptClass(QScriptClass *scriptClass)
-{
- Q_ASSERT(scriptClass != 0);
- m_scriptClass = scriptClass;
-}
-
QScriptObjectDelegate::Type ClassObjectDelegate::type() const
{
return ClassObject;
diff --git a/src/script/bridge/qscriptclassobject_p.h b/src/script/bridge/qscriptclassobject_p.h
index f5cce76..9b34244 100644
--- a/src/script/bridge/qscriptclassobject_p.h
+++ b/src/script/bridge/qscriptclassobject_p.h
@@ -70,8 +70,8 @@ public:
ClassObjectDelegate(QScriptClass *scriptClass);
~ClassObjectDelegate();
- QScriptClass *scriptClass() const;
- void setScriptClass(QScriptClass *scriptClass);
+ inline QScriptClass *scriptClass() const;
+ inline void setScriptClass(QScriptClass *scriptClass);
virtual Type type() const;
@@ -105,6 +105,17 @@ private:
QScriptClass *m_scriptClass;
};
+inline QScriptClass *ClassObjectDelegate::scriptClass() const
+{
+ return m_scriptClass;
+}
+
+inline void ClassObjectDelegate::setScriptClass(QScriptClass *scriptClass)
+{
+ Q_ASSERT(scriptClass != 0);
+ m_scriptClass = scriptClass;
+}
+
} // namespace QScript
QT_END_NAMESPACE
diff --git a/src/script/bridge/qscriptobject.cpp b/src/script/bridge/qscriptobject.cpp
index 55644fe..1fdf0b1 100644
--- a/src/script/bridge/qscriptobject.cpp
+++ b/src/script/bridge/qscriptobject.cpp
@@ -70,36 +70,6 @@ QScriptObject::~QScriptObject()
delete d;
}
-JSC::JSValue QScriptObject::data() const
-{
- if (!d)
- return JSC::JSValue();
- return d->data;
-}
-
-void QScriptObject::setData(JSC::JSValue data)
-{
- if (!d)
- d = new Data();
- d->data = data;
-}
-
-QScriptObjectDelegate *QScriptObject::delegate() const
-{
- if (!d)
- return 0;
- return d->delegate;
-}
-
-void QScriptObject::setDelegate(QScriptObjectDelegate *delegate)
-{
- if (!d)
- d = new Data();
- else
- delete d->delegate;
- d->delegate = delegate;
-}
-
bool QScriptObject::getOwnPropertySlot(JSC::ExecState* exec,
const JSC::Identifier& propertyName,
JSC::PropertySlot& slot)
diff --git a/src/script/bridge/qscriptobject_p.h b/src/script/bridge/qscriptobject_p.h
index c1cee31..9dd9d88 100644
--- a/src/script/bridge/qscriptobject_p.h
+++ b/src/script/bridge/qscriptobject_p.h
@@ -104,11 +104,11 @@ public:
return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance | JSC::OverridesHasInstance));
}
- JSC::JSValue data() const;
- void setData(JSC::JSValue data);
+ inline JSC::JSValue data() const;
+ inline void setData(JSC::JSValue data);
- QScriptObjectDelegate *delegate() const;
- void setDelegate(QScriptObjectDelegate *delegate);
+ inline QScriptObjectDelegate *delegate() const;
+ inline void setDelegate(QScriptObjectDelegate *delegate);
protected:
Data *d;
@@ -158,6 +158,36 @@ private:
Q_DISABLE_COPY(QScriptObjectDelegate)
};
+inline JSC::JSValue QScriptObject::data() const
+{
+ if (!d)
+ return JSC::JSValue();
+ return d->data;
+}
+
+inline void QScriptObject::setData(JSC::JSValue data)
+{
+ if (!d)
+ d = new Data();
+ d->data = data;
+}
+
+inline QScriptObjectDelegate *QScriptObject::delegate() const
+{
+ if (!d)
+ return 0;
+ return d->delegate;
+}
+
+inline void QScriptObject::setDelegate(QScriptObjectDelegate *delegate)
+{
+ if (!d)
+ d = new Data();
+ else
+ delete d->delegate;
+ d->delegate = delegate;
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp
index 468e02e..17f2c92 100644
--- a/src/sql/drivers/oci/qsql_oci.cpp
+++ b/src/sql/drivers/oci/qsql_oci.cpp
@@ -1257,7 +1257,11 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVector<QVariant> &boundValues, b
case QVariant::String: {
col.bindAs = SQLT_STR;
for (uint j = 0; j < col.recordCount; ++j) {
- uint len = boundValues.at(i).toList().at(j).toString().length() + 1;
+ uint len;
+ if(d->isOutValue(i))
+ len = boundValues.at(i).toList().at(j).toString().capacity() + 1;
+ else
+ len = boundValues.at(i).toList().at(j).toString().length() + 1;
if (len > col.maxLen)
col.maxLen = len;
}
@@ -1268,7 +1272,10 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVector<QVariant> &boundValues, b
default: {
col.bindAs = SQLT_LBI;
for (uint j = 0; j < col.recordCount; ++j) {
- col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().size();
+ if(d->isOutValue(i))
+ col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().capacity();
+ else
+ col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().size();
if (col.lengths[j] > col.maxLen)
col.maxLen = col.lengths[j];
}