From 5f8978a02bde7f84dc48b63d3722b925730790f0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Oct 2009 10:34:44 +0200 Subject: move default QAbstractButton font setup on Win mobile to QApplication The original approach of modifying the font for QAbstractButtons in QWindowsMobileStyle::polish broke the autotest tst_qstylesheetstyle::fontPropagation. Reviewed-by: thartman --- src/gui/kernel/qapplication_win.cpp | 2 ++ src/gui/styles/qwindowsmobilestyle.cpp | 25 +------------------------ 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 1babb69..5a4f4e6 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -624,6 +624,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_OS_WINCE } diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index 32e39b2..f04a4b2 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -3130,34 +3130,11 @@ void QWindowsMobileStyle::polish(QWidget *widget) { else #endif //QT_NO_TOOLBAR -#ifndef QT_NO_PROPERTIES - if (QAbstractButton *pushButton = qobject_cast(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(widget)) { - QVariant oldFont = widget->property("_q_styleWindowsMobileFont"); - if (oldFont.isValid()) { - widget->setFont(qVariantValue(oldFont)); - widget->setProperty("_q_styleWindowsMobileFont", QVariant()); - } - } -#endif QWindowsStyle::unpolish(widget); } -- cgit v0.12 From adc8f1b1e7a91c3807b074a43c18d2b0e31c9a9d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Oct 2009 11:00:25 +0200 Subject: QWindowsMobileStyle::drawPrimitive(PE_Frame) background color fixed The background color of PE_Frame was palette().light() and has been changed to use palette().background() now. This fixes the autotest tst_QStyleSheetStyle::task188195_baseBackground for Windows mobile. Reviewed-by: thartman --- src/gui/styles/qwindowsmobilestyle.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index f04a4b2..886301b 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -1460,10 +1460,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: -- cgit v0.12 From 079202d135908444c418b064928117b4a273e075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 22 Oct 2009 10:46:32 +0200 Subject: QWidget painting regression on Windows. Problem occurred on Windows due to a call to repaint() on a top-level window from setDisabledStyle() in qwidget.cpp. This function is called whenever a window is blocking. In this particular case the children of the repainted window are opaque, and should therefore not be repainted, which also means that the top-level have to subtract the region of the opaque children when filling the background. This region is cached, and the problem was that the cached region was wrong. It was wrong because it was not invalidated properly. Task: QTBUG-4245 Reviewed-by: Paul --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 3e65101..85c1955 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -6954,7 +6954,7 @@ void QWidget::setVisible(bool visible) break; parent = parent->parentWidget(); } - if (parent && !d->getOpaqueRegion().isEmpty()) + if (parent) parent->d_func()->setDirtyOpaqueRegion(); } -- cgit v0.12 From 8a15a24a8aa7faeb2c02944de6f97105f0424906 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 23 Oct 2009 12:09:05 +0200 Subject: doc: Relationship of QGraphicsObject::parent && QObject::parent QGraphicsObject::parent is actually about the QGraphicsItem hierarchy, not the QObject hierarchy. This is similar to QGraphicsWidget, where 'QObject::parent() should always return 0'. Maybe the explanation in QGraphicsWidget class documentation on this topic should be merged into QGraphicsObject, too? Reviewed-by: Andreas Aardal Hanssen --- src/gui/graphicsview/qgraphicsitem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 97979e5..f892bb4 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1228,7 +1228,7 @@ 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 \fn 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. @@ -7318,7 +7318,7 @@ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext co /*! \property QGraphicsObject::parent - \brief the parent of the item + \brief the parent of the item. It is independent from \fn QObject::parent. \sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject() */ -- cgit v0.12 From 6209eb29588801c55891401c82ec17efa310f7f3 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 15:37:08 +0200 Subject: Inline two internal QtScript functions (contextForFrame() and globalExec()) Makes QScriptEngine::currentContext() 25% faster. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 15 --------------- src/script/api/qscriptengine_p.h | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 3f2c9b4..0673f5b 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -995,16 +995,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(frame); -} - JSC::ExecState *QScriptEnginePrivate::frameForContext(QScriptContext *context) { return reinterpret_cast(context); @@ -1056,11 +1046,6 @@ void QScriptEnginePrivate::setGlobalObject(JSC::JSObject *object) } } -JSC::ExecState *QScriptEnginePrivate::globalExec() const -{ - return originalGlobalObject()->globalExec(); -} - /*! \internal diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 3766559..42c0444 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -147,7 +147,7 @@ public: JSC::JSValue defaultPrototype(int metaTypeId) const; void setDefaultPrototype(int metaTypeId, JSC::JSValue prototype); - static QScriptContext *contextForFrame(JSC::ExecState *frame); + static inline QScriptContext *contextForFrame(JSC::ExecState *frame); static JSC::ExecState *frameForContext(QScriptContext *context); static const JSC::ExecState *frameForContext(const QScriptContext *context); @@ -156,7 +156,7 @@ public: 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); @@ -512,6 +512,21 @@ 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(frame); +} + +inline JSC::ExecState *QScriptEnginePrivate::globalExec() const +{ + return originalGlobalObject()->globalExec(); +} + QT_END_NAMESPACE #endif -- cgit v0.12 From cb3544a0c33973cfb662e0215e1b130d23045814 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 15:51:37 +0200 Subject: Inline internal QtScript functions (frameForContext()) Makes QScriptContext::parentContext() 50% faster. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 10 ---------- src/script/api/qscriptengine_p.h | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 0673f5b..ceaeccb 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -995,16 +995,6 @@ void QScriptEnginePrivate::setDefaultPrototype(int metaTypeId, JSC::JSValue prot info->prototype = prototype; } -JSC::ExecState *QScriptEnginePrivate::frameForContext(QScriptContext *context) -{ - return reinterpret_cast(context); -} - -const JSC::ExecState *QScriptEnginePrivate::frameForContext(const QScriptContext *context) -{ - return reinterpret_cast(context); -} - JSC::JSGlobalObject *QScriptEnginePrivate::originalGlobalObject() const { return globalData->head; diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 42c0444..02cf100 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -148,8 +148,8 @@ public: void setDefaultPrototype(int metaTypeId, JSC::JSValue prototype); static inline QScriptContext *contextForFrame(JSC::ExecState *frame); - static JSC::ExecState *frameForContext(QScriptContext *context); - static const JSC::ExecState *frameForContext(const QScriptContext *context); + static inline JSC::ExecState *frameForContext(QScriptContext *context); + static inline const JSC::ExecState *frameForContext(const QScriptContext *context); JSC::JSGlobalObject *originalGlobalObject() const; JSC::JSObject *getOriginalGlobalObjectProxy(); @@ -522,6 +522,16 @@ inline QScriptContext *QScriptEnginePrivate::contextForFrame(JSC::ExecState *fra return reinterpret_cast(frame); } +inline JSC::ExecState *QScriptEnginePrivate::frameForContext(QScriptContext *context) +{ + return reinterpret_cast(context); +} + +inline const JSC::ExecState *QScriptEnginePrivate::frameForContext(const QScriptContext *context) +{ + return reinterpret_cast(context); +} + inline JSC::ExecState *QScriptEnginePrivate::globalExec() const { return originalGlobalObject()->globalExec(); -- cgit v0.12 From 4d318525c9663a46d36b27605143dab3250d2b9b Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 16:01:26 +0200 Subject: Inline scriptEngineFromExec() function Makes QScriptContext::engine() 80% faster. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 16 +++------------- src/script/api/qscriptengine_p.h | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index ceaeccb..a628578 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(exec->globalData().clientData)->engine; -} - bool isFunction(JSC::JSValue value) { if (!value || !value.isObject()) diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 02cf100..c9faa46 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 @@ -367,6 +378,11 @@ private: JSC::ExecState *oldFrame; }; +inline QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec) +{ + return static_cast(exec->globalData().clientData)->engine; +} + } // namespace QScript inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(size_t size) -- cgit v0.12 From 36d365458d54c6168c8003f7348e932e3a4ffc2c Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 16:47:04 +0200 Subject: Inline internal QtScript object delegate functions Makes QScriptValue::scriptClass() 20% faster. Reviewed-by: Olivier Goffart --- src/script/bridge/qscriptclassobject.cpp | 11 ----------- src/script/bridge/qscriptclassobject_p.h | 15 +++++++++++++-- src/script/bridge/qscriptobject.cpp | 16 ---------------- src/script/bridge/qscriptobject_p.h | 20 ++++++++++++++++++-- 4 files changed, 31 insertions(+), 31 deletions(-) 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..4808c7c 100644 --- a/src/script/bridge/qscriptobject.cpp +++ b/src/script/bridge/qscriptobject.cpp @@ -84,22 +84,6 @@ void QScriptObject::setData(JSC::JSValue 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..1170709 100644 --- a/src/script/bridge/qscriptobject_p.h +++ b/src/script/bridge/qscriptobject_p.h @@ -107,8 +107,8 @@ public: JSC::JSValue data() const; 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,22 @@ private: Q_DISABLE_COPY(QScriptObjectDelegate) }; +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 -- cgit v0.12 From 7e7b34fe5acab632c10814b591c80b0a9d613220 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 16:54:29 +0200 Subject: Inline internal QtScript object data() functions Makes QScriptValue::data() 15% faster. Reviewed-by: Olivier Goffart --- src/script/bridge/qscriptobject.cpp | 14 -------------- src/script/bridge/qscriptobject_p.h | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/script/bridge/qscriptobject.cpp b/src/script/bridge/qscriptobject.cpp index 4808c7c..1fdf0b1 100644 --- a/src/script/bridge/qscriptobject.cpp +++ b/src/script/bridge/qscriptobject.cpp @@ -70,20 +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; -} - 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 1170709..9dd9d88 100644 --- a/src/script/bridge/qscriptobject_p.h +++ b/src/script/bridge/qscriptobject_p.h @@ -104,8 +104,8 @@ 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); inline QScriptObjectDelegate *delegate() const; inline void setDelegate(QScriptObjectDelegate *delegate); @@ -158,6 +158,20 @@ 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) -- cgit v0.12 From 7bfa219ebd050523ecd0d72ad7154e1ce3b83ae9 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 17:09:04 +0200 Subject: Use an inline helper function to check if a QScriptString is valid Makes QScriptValue::property() ~10% faster. Reviewed-by: Olivier Goffart --- src/script/api/qscriptstring.cpp | 3 +-- src/script/api/qscriptstring_p.h | 7 +++++++ src/script/api/qscriptvalue.cpp | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) 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..21673d1 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1775,7 +1775,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 +1798,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 +1832,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); } -- cgit v0.12 From d610da0f40819213fd45bf77f6c2131769df693d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 18:27:50 +0200 Subject: Inline internal property lookup function Also avoid looking up the object's own properties twice (before we called getOwnPropertySlot() and then getPropertySlot() on the same object). Makes QScriptValue::property() ~20% faster when calling it on an "empty" object. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine_p.h | 22 +++++++++++++++++++ src/script/api/qscriptvalue.cpp | 47 ++++++++++++++++++---------------------- src/script/api/qscriptvalue_p.h | 6 +++-- 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index c9faa46..a16785c 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -489,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) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 21673d1..76b2636 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(object)); JSC::JSValue result; - if (const_cast(object)->getOwnPropertySlot(exec, id, slot)) { - result = slot.getValue(exec, id); - } else { - if ((resolveMode & QScriptValue::ResolvePrototype) - && const_cast(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(object)); JSC::JSValue result; - if (const_cast(object)->getOwnPropertySlot(exec, index, slot)) { - result = slot.getValue(exec, index); - } else if ((resolveMode & QScriptValue::ResolvePrototype) - && const_cast(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); } diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h index 9634515..b87b485 100644 --- a/src/script/api/qscriptvalue_p.h +++ b/src/script/api/qscriptvalue_p.h @@ -100,8 +100,10 @@ public: return QScriptValue(d); } - QScriptValue property(const JSC::Identifier &id, int resolveMode) const; - QScriptValue property(quint32 index, int resolveMode) const; + 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); -- cgit v0.12 From fb0af528ed52a90d422b95f6976e21fd670f40b0 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 19:04:22 +0200 Subject: Bind QScriptValue to engine when the value is created internally Makes creation+destruction of the QScriptValue a lot faster because it uses the engine's pool of QScriptValuePrivates instead of qMalloc()/qFree(). Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 53 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index a628578..654eea1 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2508,62 +2508,63 @@ 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); + result = QScriptValue(q, QScriptValue::UndefinedValue); break; case QMetaType::Bool: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::Int: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::UInt: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::LongLong: - result = QScriptValue(qsreal(*reinterpret_cast(ptr))); + result = QScriptValue(q, qsreal(*reinterpret_cast(ptr))); break; 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(ptr))); + result = QScriptValue(q, qsreal((qlonglong)*reinterpret_cast(ptr))); #elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - result = QScriptValue(qsreal((qlonglong)*reinterpret_cast(ptr))); + result = QScriptValue(q, qsreal((qlonglong)*reinterpret_cast(ptr))); #else - result = QScriptValue(qsreal(*reinterpret_cast(ptr))); + result = QScriptValue(q, qsreal(*reinterpret_cast(ptr))); #endif break; case QMetaType::Double: - result = QScriptValue(qsreal(*reinterpret_cast(ptr))); + result = QScriptValue(q, qsreal(*reinterpret_cast(ptr))); break; case QMetaType::QString: - result = QScriptValue(q_func(), *reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::Float: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::Short: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::UShort: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::Char: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::UChar: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(q, *reinterpret_cast(ptr)); break; case QMetaType::QChar: - result = QScriptValue((*reinterpret_cast(ptr)).unicode()); + result = QScriptValue(q, (*reinterpret_cast(ptr)).unicode()); break; case QMetaType::QStringList: result = arrayFromStringList(*reinterpret_cast(ptr)); @@ -2575,38 +2576,38 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) result = objectFromVariantMap(*reinterpret_cast(ptr)); break; case QMetaType::QDateTime: - result = q_func()->newDate(*reinterpret_cast(ptr)); + result = q->newDate(*reinterpret_cast(ptr)); break; case QMetaType::QDate: - result = q_func()->newDate(QDateTime(*reinterpret_cast(ptr))); + result = q->newDate(QDateTime(*reinterpret_cast(ptr))); break; #ifndef QT_NO_REGEXP case QMetaType::QRegExp: - result = q_func()->newRegExp(*reinterpret_cast(ptr)); + result = q->newRegExp(*reinterpret_cast(ptr)); break; #endif #ifndef QT_NO_QOBJECT case QMetaType::QObjectStar: case QMetaType::QWidgetStar: - result = q_func()->newQObject(*reinterpret_cast(ptr)); + result = q->newQObject(*reinterpret_cast(ptr)); break; #endif default: if (type == qMetaTypeId()) { result = *reinterpret_cast(ptr); if (!result.isValid()) - result = QScriptValue(QScriptValue::UndefinedValue); + result = QScriptValue(q, QScriptValue::UndefinedValue); } #ifndef QT_NO_QOBJECT // lazy registration of some common list types else if (type == qMetaTypeId()) { - qScriptRegisterSequenceMetaType(q_func()); + qScriptRegisterSequenceMetaType(q); return create(type, ptr); } #endif else if (type == qMetaTypeId >()) { - qScriptRegisterSequenceMetaType >(q_func()); + qScriptRegisterSequenceMetaType >(q); return create(type, ptr); } @@ -2615,9 +2616,9 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) if (typeName == "QVariant") result = scriptValueFromVariant(*reinterpret_cast(ptr)); if (typeName.endsWith('*') && !*reinterpret_cast(ptr)) - result = QScriptValue(QScriptValue::NullValue); + result = QScriptValue(q, QScriptValue::NullValue); else - result = q_func()->newVariant(QVariant(type, ptr)); + result = q->newVariant(QVariant(type, ptr)); } } } -- cgit v0.12 From 73b14bae17d1bb84c89ca2a908f2cc105dcda015 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 23 Oct 2009 07:20:33 +0200 Subject: Speed up QScriptValue creation by avoiding operator= to be called For non-object values, just return the value immediately; there is no way that the later check (result.isObject()) will be true anyway. This makes qScriptValueFromValue() ~50% faster. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 50 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 654eea1..bffca16 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2518,54 +2518,40 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) // check if it's one of the types we know switch (QMetaType::Type(type)) { case QMetaType::Void: - result = QScriptValue(q, QScriptValue::UndefinedValue); - break; + return QScriptValue(q, QScriptValue::UndefinedValue); case QMetaType::Bool: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::Int: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::UInt: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::LongLong: - result = QScriptValue(q, qsreal(*reinterpret_cast(ptr))); - break; + return QScriptValue(q, qsreal(*reinterpret_cast(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(q, qsreal((qlonglong)*reinterpret_cast(ptr))); + return QScriptValue(q, qsreal((qlonglong)*reinterpret_cast(ptr))); #elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - result = QScriptValue(q, qsreal((qlonglong)*reinterpret_cast(ptr))); + return QScriptValue(q, qsreal((qlonglong)*reinterpret_cast(ptr))); #else - result = QScriptValue(q, qsreal(*reinterpret_cast(ptr))); + return QScriptValue(q, qsreal(*reinterpret_cast(ptr))); #endif - break; case QMetaType::Double: - result = QScriptValue(q, qsreal(*reinterpret_cast(ptr))); - break; + return QScriptValue(q, qsreal(*reinterpret_cast(ptr))); case QMetaType::QString: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::Float: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::Short: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::UShort: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::Char: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::UChar: - result = QScriptValue(q, *reinterpret_cast(ptr)); - break; + return QScriptValue(q, *reinterpret_cast(ptr)); case QMetaType::QChar: - result = QScriptValue(q, (*reinterpret_cast(ptr)).unicode()); - break; + return QScriptValue(q, (*reinterpret_cast(ptr)).unicode()); case QMetaType::QStringList: result = arrayFromStringList(*reinterpret_cast(ptr)); break; @@ -2596,7 +2582,7 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) if (type == qMetaTypeId()) { result = *reinterpret_cast(ptr); if (!result.isValid()) - result = QScriptValue(q, QScriptValue::UndefinedValue); + return QScriptValue(q, QScriptValue::UndefinedValue); } #ifndef QT_NO_QOBJECT @@ -2616,7 +2602,7 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) if (typeName == "QVariant") result = scriptValueFromVariant(*reinterpret_cast(ptr)); if (typeName.endsWith('*') && !*reinterpret_cast(ptr)) - result = QScriptValue(q, QScriptValue::NullValue); + return QScriptValue(q, QScriptValue::NullValue); else result = q->newVariant(QVariant(type, ptr)); } -- cgit v0.12 From b119fd7f3fca35fba80b554778581ffba0a68a62 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 23 Oct 2009 08:08:56 +0200 Subject: Avoid calls to public QScriptValue::engine() function Calls to engine() are mostly done for checking that the "source" and "target" engines are the same, but we don't want those checks to slow us down. Use an inline getEngine() function instead. This makes e.g. QScriptValue::call() ~10% faster for a function like "function(a, b) { return a + b; }". Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 4 ++-- src/script/api/qscriptvalue.cpp | 36 ++++++++++++++++++++++-------------- src/script/api/qscriptvalue_p.h | 7 +++++++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index bffca16..9288723 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2619,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/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 76b2636..08a3176 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -313,8 +313,8 @@ QScriptValue QScriptValuePrivate::propertyHelper(quint32 index, int resolveMode) 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()))); @@ -817,8 +817,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"); @@ -859,8 +859,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"); @@ -891,7 +891,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"); @@ -1078,10 +1078,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"); @@ -1119,7 +1121,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"); @@ -1168,7 +1171,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"); @@ -1720,7 +1724,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; @@ -1867,7 +1872,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"); @@ -1885,7 +1891,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"); @@ -1942,7 +1949,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 b87b485..444c76a 100644 --- a/src/script/api/qscriptvalue_p.h +++ b/src/script/api/qscriptvalue_p.h @@ -100,6 +100,13 @@ public: return QScriptValue(d); } + 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; -- cgit v0.12 From d6af21c0c8c842b684064a63cd37575720bc0ed9 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 23 Oct 2009 08:31:50 +0200 Subject: Inline QtScript exception helper functions Makes QScriptValue::toNumber() ~50% faster. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine_p.h | 16 ++++++++++++++++ src/script/api/qscriptvalue.cpp | 16 ---------------- src/script/api/qscriptvalue_p.h | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index a16785c..ec7c144 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -527,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); diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 08a3176..52a1e6d 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -438,22 +438,6 @@ void QScriptValuePrivate::setVariantValue(const QVariant &value) static_cast(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()) diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h index 444c76a..c322a37 100644 --- a/src/script/api/qscriptvalue_p.h +++ b/src/script/api/qscriptvalue_p.h @@ -127,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; -- cgit v0.12 From c51f6afd07a55692e3f00c8e0a5d5c61b13ffefa Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 23 Oct 2009 13:16:28 +0200 Subject: Fix weird behavior when opening a QFileDialog for non-current directory. shouldShowFileName() can be called with an empty filename, but must not create and use a QFileInfo("") since that has known undefined behavior. So just return NO right away for empty filenames. Merge-request: 1765 Reviewed-by: Richard Moe Gustavsen --- src/gui/dialogs/qfiledialog_mac.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 8e4c461..637b852 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -280,6 +280,11 @@ QT_USE_NAMESPACE - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { Q_UNUSED(sender); + + // Don't bother with empty file names. + 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(); -- cgit v0.12 From 1b998b443ffe8252d8f4d9cc8427fabf9d345a15 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 23 Oct 2009 13:18:09 +0200 Subject: Mac: remove obvious comment Amending the previous merge request --- src/gui/dialogs/qfiledialog_mac.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 637b852..d9bec27 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -281,7 +281,6 @@ QT_USE_NAMESPACE { Q_UNUSED(sender); - // Don't bother with empty file names. if ([filename length] == 0) return NO; -- cgit v0.12 From 2c0921b667ec74df6ad3d749b30bb9b7c5843343 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 23 Oct 2009 14:03:08 +0200 Subject: Fixed crash in QGraphicsEffects Reviewed-by: Samuel --- src/gui/effects/qgraphicseffect_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- cgit v0.12 From 08cb2ac46791ef3abfd9d85eb6a75251b1f41336 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 23 Oct 2009 14:19:28 +0200 Subject: Doc: Reviewed and revised QGraphicsAnchorLayout documentation. Reviewed-by: Trust Me --- doc/src/images/simpleanchorlayout-example.png | Bin 0 -> 13463 bytes .../graphicsview/anchorlayout/anchorlayout.pro | 10 +- examples/graphicsview/simpleanchorlayout/main.cpp | 134 +++++++++++++++++++++ .../simpleanchorlayout/simpleanchorlayout.pro | 9 ++ src/gui/graphicsview/qgraphicsanchorlayout.cpp | 122 +++++++++++-------- 5 files changed, 216 insertions(+), 59 deletions(-) create mode 100644 doc/src/images/simpleanchorlayout-example.png create mode 100644 examples/graphicsview/simpleanchorlayout/main.cpp create mode 100644 examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro diff --git a/doc/src/images/simpleanchorlayout-example.png b/doc/src/images/simpleanchorlayout-example.png new file mode 100644 index 0000000..1d5c8ac Binary files /dev/null and b/doc/src/images/simpleanchorlayout-example.png differ diff --git a/examples/graphicsview/anchorlayout/anchorlayout.pro b/examples/graphicsview/anchorlayout/anchorlayout.pro index c2a1bea..fd085cc 100644 --- a/examples/graphicsview/anchorlayout/anchorlayout.pro +++ b/examples/graphicsview/anchorlayout/anchorlayout.pro @@ -1,9 +1,4 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue May 12 15:22:25 2009 -###################################################################### - -# Input -SOURCES += main.cpp +SOURCES = main.cpp # install target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout @@ -11,5 +6,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES anchorlayout.pro sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout INSTALLS += target sources -TARGET = anchorlayout_example -CONFIG+=console \ No newline at end of file +TARGET = anchorlayout diff --git a/examples/graphicsview/simpleanchorlayout/main.cpp b/examples/graphicsview/simpleanchorlayout/main.cpp new file mode 100644 index 0000000..493b00f --- /dev/null +++ b/examples/graphicsview/simpleanchorlayout/main.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class Widget : public QGraphicsWidget +{ +public: + Widget(const QColor &color, const QColor &textColor, const QString &caption, + QGraphicsItem *parent = 0) + : QGraphicsWidget(parent), caption(caption), color(color), textColor(textColor) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) + { + QFont font; + font.setPixelSize(0.75 * qMin(boundingRect().width(), boundingRect().height())); + + painter->fillRect(boundingRect(), color); + painter->save(); + painter->setFont(font); + painter->setPen(textColor); + painter->drawText(boundingRect(), Qt::AlignCenter, caption); + painter->restore(); + } + +private: + QString caption; + QColor color; + QColor textColor; +}; + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QGraphicsScene *scene = new QGraphicsScene(); + + Widget *a = new Widget(Qt::blue, Qt::white, "a"); + a->setPreferredSize(100, 100); + Widget *b = new Widget(Qt::green, Qt::black, "b"); + b->setPreferredSize(100, 100); + Widget *c = new Widget(Qt::red, Qt::black, "c"); + c->setPreferredSize(100, 100); + + QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout(); +/* + //! [adding a corner anchor in two steps] + layout->addAnchor(a, Qt::AnchorTop, layout, Qt::AnchorTop); + layout->addAnchor(a, Qt::AnchorLeft, layout, Qt::AnchorLeft); + //! [adding a corner anchor in two steps] +*/ + //! [adding a corner anchor] + layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner); + //! [adding a corner anchor] + + //! [adding anchors] + layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight); + layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom); + //! [adding anchors] + + // Place a third widget below the second. + layout->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + +/* + //! [adding anchors to match sizes in two steps] + layout->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); + layout->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight); + //! [adding anchors to match sizes in two steps] +*/ + + //! [adding anchors to match sizes] + layout->addAnchors(b, c, Qt::Horizontal); + //! [adding anchors to match sizes] + + // Anchor the bottom-right corner of the third widget to the bottom-right + // corner of the layout. + layout->addCornerAnchors(c, Qt::BottomRightCorner, layout, Qt::BottomRightCorner); + + QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint); + w->setPos(20, 20); + w->setMinimumSize(100, 100); + w->setPreferredSize(320, 240); + w->setLayout(layout); + w->setWindowTitle(QApplication::translate("simpleanchorlayout", "QGraphicsAnchorLayout in use")); + scene->addItem(w); + + QGraphicsView *view = new QGraphicsView(); + view->setScene(scene); + view->setWindowTitle(QApplication::translate("simpleanchorlayout", "Simple Anchor Layout")); + view->resize(360, 320); + view->show(); + + return app.exec(); +} diff --git a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro new file mode 100644 index 0000000..e1c7aeb --- /dev/null +++ b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro @@ -0,0 +1,9 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/simpleanchorlayout +sources.files = $$SOURCES $$HEADERS $$RESOURCES simpleanchorlayout.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/simpleanchorlayout +INSTALLS += target sources + +TARGET = simpleanchorlayout 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, -- cgit v0.12 From 05aaab72d69a7fa9c23811c1d3ee7d91a9174e46 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 23 Oct 2009 14:39:57 +0200 Subject: qdoc3: Added the \qmlattachedsignal and \qmlattachedmethod. They works just like the \qmlsignal and \qmlmethod commands. --- tools/qdoc3/cppcodemarker.cpp | 38 ++++++++++++++++++++++++++++++++++---- tools/qdoc3/cppcodeparser.cpp | 20 ++++++++++++++++---- tools/qdoc3/node.cpp | 12 ++++++++---- tools/qdoc3/node.h | 16 ++++++++++++++-- 4 files changed, 72 insertions(+), 14 deletions(-) diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index 36293f8..a32f92b 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -1120,10 +1120,18 @@ QList
CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, "QML Signals", "signal", "signals"); + FastSection qmlattachedsignals(qmlClassNode, + "QML Attached Signals", + "signal", + "signals"); FastSection qmlmethods(qmlClassNode, "QML Methods", "method", "methods"); + FastSection qmlattachedmethods(qmlClassNode, + "QML Attached Methods", + "method", + "methods"); NodeList::ConstIterator c = qmlClassNode->childNodes().begin(); while (c != qmlClassNode->childNodes().end()) { @@ -1142,23 +1150,35 @@ QList
CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, } } else if ((*c)->type() == Node::QmlSignal) { - insert(qmlsignals,*c,style,Okay); + const QmlSignalNode* sn = static_cast(*c); + if (sn->isAttached()) + insert(qmlattachedsignals,*c,style,Okay); + else + insert(qmlsignals,*c,style,Okay); } else if ((*c)->type() == Node::QmlMethod) { - insert(qmlmethods,*c,style,Okay); + const QmlMethodNode* mn = static_cast(*c); + if (mn->isAttached()) + insert(qmlattachedmethods,*c,style,Okay); + else + insert(qmlmethods,*c,style,Okay); } ++c; } append(sections,qmlproperties); append(sections,qmlattachedproperties); append(sections,qmlsignals); + append(sections,qmlattachedsignals); append(sections,qmlmethods); + append(sections,qmlattachedmethods); } else if (style == Detailed) { FastSection qmlproperties(qmlClassNode,"QML Property Documentation"); FastSection qmlattachedproperties(qmlClassNode,"QML Attached Property Documentation"); FastSection qmlsignals(qmlClassNode,"QML Signal Documentation"); + FastSection qmlattachedsignals(qmlClassNode,"QML Attached Signal Documentation"); FastSection qmlmethods(qmlClassNode,"QML Method Documentation"); + FastSection qmlattachedmethods(qmlClassNode,"QML Attached Method Documentation"); NodeList::ConstIterator c = qmlClassNode->childNodes().begin(); while (c != qmlClassNode->childNodes().end()) { if ((*c)->subType() == Node::QmlPropertyGroup) { @@ -1169,17 +1189,27 @@ QList
CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, insert(qmlproperties,*c,style,Okay); } else if ((*c)->type() == Node::QmlSignal) { - insert(qmlsignals,*c,style,Okay); + const QmlSignalNode* sn = static_cast(*c); + if (sn->isAttached()) + insert(qmlattachedsignals,*c,style,Okay); + else + insert(qmlsignals,*c,style,Okay); } else if ((*c)->type() == Node::QmlMethod) { - insert(qmlmethods,*c,style,Okay); + const QmlMethodNode* mn = static_cast(*c); + if (mn->isAttached()) + insert(qmlattachedmethods,*c,style,Okay); + else + insert(qmlmethods,*c,style,Okay); } ++c; } append(sections,qmlproperties); append(sections,qmlattachedproperties); append(sections,qmlsignals); + append(sections,qmlattachedsignals); append(sections,qmlmethods); + append(sections,qmlattachedmethods); } } diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index ad43b2b..84ec3f4 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -91,7 +91,9 @@ QT_BEGIN_NAMESPACE #define COMMAND_QMLATTACHEDPROPERTY Doc::alias("qmlattachedproperty") #define COMMAND_QMLINHERITS Doc::alias("inherits") #define COMMAND_QMLSIGNAL Doc::alias("qmlsignal") +#define COMMAND_QMLATTACHEDSIGNAL Doc::alias("qmlattachedsignal") #define COMMAND_QMLMETHOD Doc::alias("qmlmethod") +#define COMMAND_QMLATTACHEDMETHOD Doc::alias("qmlattachedmethod") #define COMMAND_QMLDEFAULT Doc::alias("default") #endif @@ -485,7 +487,9 @@ QSet CppCodeParser::topicCommands() << COMMAND_QMLPROPERTY << COMMAND_QMLATTACHEDPROPERTY << COMMAND_QMLSIGNAL - << COMMAND_QMLMETHOD; + << COMMAND_QMLATTACHEDSIGNAL + << COMMAND_QMLMETHOD + << COMMAND_QMLATTACHEDMETHOD; #else << COMMAND_VARIABLE; #endif @@ -678,7 +682,9 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, return new QmlClassNode(tre->root(), names[0], classNode); } else if ((command == COMMAND_QMLSIGNAL) || - (command == COMMAND_QMLMETHOD)) { + (command == COMMAND_QMLMETHOD) || + (command == COMMAND_QMLATTACHEDSIGNAL) || + (command == COMMAND_QMLATTACHEDMETHOD)) { QString element; QString name; QmlClassNode* qmlClass = 0; @@ -687,9 +693,15 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, if (n && n->subType() == Node::QmlClass) { qmlClass = static_cast(n); if (command == COMMAND_QMLSIGNAL) - return new QmlSignalNode(qmlClass,name); + return new QmlSignalNode(qmlClass,name,false); + else if (command == COMMAND_QMLATTACHEDSIGNAL) + return new QmlSignalNode(qmlClass,name,true); + else if (command == COMMAND_QMLMETHOD) + return new QmlMethodNode(qmlClass,name,false); + else if (command == COMMAND_QMLATTACHEDMETHOD) + return new QmlMethodNode(qmlClass,name,true); else - return new QmlMethodNode(qmlClass,name); + return 0; // never get here. } } } diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 49f2cc9..61855bc 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -1210,8 +1210,10 @@ bool QmlPropertyNode::fromTrool(Trool troolean, bool defaultValue) /*! Constructor for the QML signal node. */ -QmlSignalNode::QmlSignalNode(QmlClassNode *parent, const QString& name) - : LeafNode(QmlSignal, parent, name) +QmlSignalNode::QmlSignalNode(QmlClassNode *parent, + const QString& name, + bool attached) + : LeafNode(QmlSignal, parent, name), att(attached) { // nothing. } @@ -1219,8 +1221,10 @@ QmlSignalNode::QmlSignalNode(QmlClassNode *parent, const QString& name) /*! Constructor for the QML method node. */ -QmlMethodNode::QmlMethodNode(QmlClassNode *parent, const QString& name) - : LeafNode(QmlMethod, parent, name) +QmlMethodNode::QmlMethodNode(QmlClassNode *parent, + const QString& name, + bool attached) + : LeafNode(QmlMethod, parent, name), att(attached) { // nothing. } diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index fed4ea1..20ccb95 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -420,19 +420,31 @@ class QmlPropertyNode : public LeafNode class QmlSignalNode : public LeafNode { public: - QmlSignalNode(QmlClassNode* parent, const QString& name); + QmlSignalNode(QmlClassNode* parent, + const QString& name, + bool attached); virtual ~QmlSignalNode() { } const QString& element() const { return parent()->name(); } + bool isAttached() const { return att; } + + private: + bool att; }; class QmlMethodNode : public LeafNode { public: - QmlMethodNode(QmlClassNode* parent, const QString& name); + QmlMethodNode(QmlClassNode* parent, + const QString& name, + bool attached); virtual ~QmlMethodNode() { } const QString& element() const { return parent()->name(); } + bool isAttached() const { return att; } + + private: + bool att; }; #endif -- cgit v0.12 From 4e6bb8c2d952d95ef0546d63db1c3c7c2026f6c9 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 23 Oct 2009 14:24:15 +0200 Subject: Doc: Changed the text slightly. Reviewed-by: Trust Me --- src/gui/kernel/qgesturerecognizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. -- cgit v0.12 From 2cbb76f62e49ca995f17fa455ce4cc900f724869 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 23 Oct 2009 14:24:58 +0200 Subject: Doc: Updated an external link. Reviewed-by: Trust Me --- doc/src/qt-webpages.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/qt-webpages.qdoc b/doc/src/qt-webpages.qdoc index 7287656..1eee805 100644 --- a/doc/src/qt-webpages.qdoc +++ b/doc/src/qt-webpages.qdoc @@ -165,7 +165,7 @@ */ /*! - \externalpage http://qt.nokia.com/products/qtopia/ + \externalpage http://www.qtextended.org/ \title Qt Extended */ -- cgit v0.12 From 49a5f414bf31d31e1c0a2650ab0030782face987 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 23 Oct 2009 14:25:36 +0200 Subject: Doc: Updated the modules for the "Desktop" (Full Framework) edition. Reviewed-by: Trust Me --- tools/qdoc3/test/qt-build-docs.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index 8da7442..d1733e5 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -8,7 +8,7 @@ project = Qt description = Qt Reference Documentation url = http://qt.nokia.com/doc/4.6 -edition.Desktop.modules = QtCore QtDBus QtGui QtNetwork QtOpenGL QtScript QtSql QtSvg \ +edition.Desktop.modules = QtCore QtDBus QtGui QtNetwork QtOpenGL QtScript QtScriptTools QtSql QtSvg \ QtWebKit QtXml QtXmlPatterns Qt3Support QtHelp \ QtDesigner QtAssistant QAxContainer Phonon \ QAxServer QtUiTools QtTest QtDBus -- cgit v0.12 From 37dc859e7e2e0f135e4c40bc7f6f824fcdb21e86 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 23 Oct 2009 14:51:48 +0200 Subject: Doc: Fixed and synchronized QWebView related documentation. Reviewed-by: Trust Me --- .../webkit/WebKit/qt/Api/qgraphicswebview.cpp | 96 ++++++++++++++++++++-- src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp | 2 +- 2 files changed, 91 insertions(+), 7 deletions(-) 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/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. */ /*! -- cgit v0.12 From 04d18b38c38c5ff623b30366ea08d56128b9b7d0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Oct 2009 12:28:27 +0200 Subject: Line spacing fixes QTextEdit (via QTextLayout) and QPlainTextEdit in Qt used to ignore any font leading but added one extra pixel in QFontMetrics. With many freetype fonts, this resulted in a "spacy" text layout. The necessary fixes on X11 and Windows were to take (positive) leading into account, to make the font database convert point sizes to pixel sizes without rounding to plain integer values, and to subtract the extra pixel from QFontMetrics from the font engines' descent value. The change also fixes several places in styles and widgets, where QFontMetrics::lineSpacing() was wrongly used instead of QFontMetrics::height(). Ideally we should also handle negative leading, which would require additional and bigger code changes in QTextLayout and QPlainTextEdit. In addition, all other editors we have tested seem to ignore leading on X11. If we choose to believe the values provided by freetype, our text layout would be one pixel smaller than everybody else's. On the Mac, this change does nothing. There our layout is still too spacy, and for smaller fonts quite ugly compared to native Mac applications. Done with mae. Reviewed-by: mae --- src/gui/embedded/qdecorationdefault_qws.cpp | 2 +- src/gui/embedded/qdecorationwindows_qws.cpp | 2 +- src/gui/itemviews/qheaderview.cpp | 2 +- src/gui/styles/qcleanlooksstyle.cpp | 2 +- src/gui/styles/qcommonstyle.cpp | 6 +-- src/gui/styles/qmotifstyle.cpp | 4 +- src/gui/styles/qplastiquestyle.cpp | 8 +-- src/gui/styles/qstylesheetstyle.cpp | 2 +- src/gui/text/qfont.cpp | 2 +- src/gui/text/qfont_p.h | 2 +- src/gui/text/qfontdatabase.cpp | 2 +- src/gui/text/qfontdatabase_win.cpp | 12 +++-- src/gui/text/qfontdatabase_x11.cpp | 14 ++++-- src/gui/text/qfontengine_ft.cpp | 10 ++-- src/gui/text/qfontengine_win.cpp | 4 +- src/gui/text/qtextdocumentlayout.cpp | 5 +- src/gui/text/qtextengine.cpp | 22 ++++++--- src/gui/text/qtextengine_mac.cpp | 2 +- src/gui/text/qtextengine_p.h | 17 +++++-- src/gui/text/qtextlayout.cpp | 76 ++++++++++++++++++++++++----- src/gui/text/qtextlayout.h | 4 ++ src/gui/text/text.pri | 1 + src/gui/widgets/qcombobox.cpp | 2 +- src/gui/widgets/qdockwidget.cpp | 2 +- src/gui/widgets/qfontcombobox.cpp | 2 +- src/gui/widgets/qlineedit.cpp | 2 +- src/gui/widgets/qplaintextedit.cpp | 5 +- 27 files changed, 149 insertions(+), 65 deletions(-) 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/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/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(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(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(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(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/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 #include #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..b582e4a 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -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(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_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 ¤t = 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 0e888d6..05e1e74 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); -- cgit v0.12 From 0e917ae9587aa0727e6b26ba3eb0157362748fb7 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 23 Oct 2009 16:44:24 +0200 Subject: Correct line ending chars imported from webkit. Reviewed-by: TrustMe --- .../webkit/WebCore/bindings/js/JSExceptionBase.cpp | 128 ++++++++++----------- .../webkit/WebCore/bindings/js/JSExceptionBase.h | 86 +++++++------- 2 files changed, 107 insertions(+), 107 deletions(-) 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(domException); - if (RangeException* rangeException = toRangeException(value)) - return reinterpret_cast(rangeException); - if (EventException* eventException = toEventException(value)) - return reinterpret_cast(eventException); - if (XMLHttpRequestException* xmlHttpException = toXMLHttpRequestException(value)) - return reinterpret_cast(xmlHttpException); -#if ENABLE(SVG) - if (SVGException* svgException = toSVGException(value)) - return reinterpret_cast(svgException); -#endif -#if ENABLE(XPATH) - if (XPathException* pathException = toXPathException(value)) - return reinterpret_cast(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(domException); + if (RangeException* rangeException = toRangeException(value)) + return reinterpret_cast(rangeException); + if (EventException* eventException = toEventException(value)) + return reinterpret_cast(eventException); + if (XMLHttpRequestException* xmlHttpException = toXMLHttpRequestException(value)) + return reinterpret_cast(xmlHttpException); +#if ENABLE(SVG) + if (SVGException* svgException = toSVGException(value)) + return reinterpret_cast(svgException); +#endif +#if ENABLE(XPATH) + if (XPathException* pathException = toXPathException(value)) + return reinterpret_cast(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 -- cgit v0.12 From afcffc4e0bdbac7850bcef9e67332c7cbd1ea611 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 23 Oct 2009 17:26:29 +0200 Subject: QT_NO_CURSOR build fix on windows. Random corrections for it on mac. Reviewed-by: Denis Dzyubenko --- src/gui/dialogs/qwizard.cpp | 2 ++ src/gui/dialogs/qwizard_win.cpp | 2 ++ src/gui/kernel/qwidget_mac.mm | 2 ++ src/gui/kernel/qwidget_win.cpp | 4 ++++ src/qt3support/widgets/q3dockwindow.cpp | 2 +- 5 files changed, 11 insertions(+), 1 deletion(-) 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/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/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 } -- cgit v0.12 From 36fc92485e9d627a925c66ca313a64a0ee6881bd Mon Sep 17 00:00:00 2001 From: Donald Carr Date: Fri, 23 Oct 2009 16:44:25 +0000 Subject: Add cross compiling pkg-config disabled warning We have historically silently disabled pkg-config when cross compiling in order to avoid host pkg-config contamination of the target build. pkg-config files are present on many embedded targets, and make the correct detection/configuration of dependencies far more convenient for the developer. It is therefor valuable to advertise that pkg-config functionality is available but disabled barring direct involvement on their parts, rather than silently disabling it. Reviewed-by: Thiago Macieira --- configure | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure b/configure index 485c71c..d97149d 100755 --- a/configure +++ b/configure @@ -2841,6 +2841,11 @@ if [ "$QT_CROSS_COMPILE" = "yes" ]; then echo >&2 "" fi else + echo >&2 "" + echo >&2 "You have not explicitly asked to use pkg-config and are cross-compiling." + echo >&2 "pkg-config will not be used to automatically query cflag/lib parameters for" + echo >&2 "dependencies" + echo >&2 "" PKG_CONFIG="" fi fi -- cgit v0.12 From 076ab884591448cae5f029683401722e417a7c9c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 23 Oct 2009 10:31:11 -0700 Subject: Compile on QWS After 04d18b38c38c5ff623b30366ea08d56128b9b7d0 Qt didn't compile for QWS. Will email original committer to verify that original intent is maintained. Reviewed-by: Donald Carr --- src/gui/text/qfontengine_qpf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { -- cgit v0.12 From 48df46cd38e69fed9454d97eeaf8cf0c0489acfa Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 08:04:23 +1000 Subject: Add an extra overload for QMatrix4x4::toTransform() Change 100afe8d fixed a bug in QGraphicsRotation related to when the "distance to plane" projection needed to be performed. As a side effect it made the toTransform() API not do the expected thing when the function is called with no argument. This change makes the default no-argument version of toTransform() do the simple "drop row 3 and column 3" orthographic transformation that normal users of the class expect, and adds a new overload for the "distance to plane" projection case for the special case. Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- src/gui/graphicsview/qgraphicstransform.cpp | 2 +- src/gui/math3d/qmatrix4x4.cpp | 22 ++++++++++++++++++++-- src/gui/math3d/qmatrix4x4.h | 3 ++- 4 files changed, 24 insertions(+), 5 deletions(-) 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..a0b5493 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -549,7 +549,7 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const matrix->translate(d->origin); QMatrix4x4 m; m.rotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z()); - *matrix *= m.toTransform(); + *matrix *= m.toTransform(1024.0f); // Project back to 2D. matrix->translate(-d->origin); } diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index ed1b13d..00e8f15 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1430,6 +1430,24 @@ QMatrix QMatrix4x4::toAffine() const m[3][0], m[3][1]); } +/*! + 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]); +} + static const qreal inv_dist_to_plane = 1. / 1024.; /*! @@ -1437,8 +1455,8 @@ static const qreal inv_dist_to_plane = 1. / 1024.; 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..42d992e 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; -- cgit v0.12 From f78d8cce8fc78b0233237e5d1414a1fd4b23e37a Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 08:14:26 +1000 Subject: Issue a warning if bindAttributeLocation() is used after shaders linked Attribute locations must be bound before a shader program is linked according to the GLSL specification. Issue a warning to the user if they do it in the wrong order, which should help to isolate hard to find bugs much quicker. Reviewed-by: trustme --- src/opengl/qglshaderprogram.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index dfa6c40..34114e4 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -1265,7 +1265,12 @@ GLuint QGLShaderProgram::programId() const */ void QGLShaderProgram::bindAttributeLocation(const char *name, int location) { - glBindAttribLocation(d->programGuard.id(), location, name); + if (!d->linked) { + glBindAttribLocation(d->programGuard.id(), location, name); + } else { + qWarning() << "QGLShaderProgram::bindAttributeLocation(" << name + << "): cannot bind after shader program is linked"; + } } /*! @@ -1280,7 +1285,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 +1300,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); } /*! -- cgit v0.12 From 9aa00de1d277763c0f7a380fde27face60e5f686 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 08:25:38 +1000 Subject: Fix a crash in shutdown of QGraphicsEffect Reviewed-by: trustme --- src/gui/effects/qgraphicseffect_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- cgit v0.12 From 0d6104d763f4cb32ac6117b3f951afcb73fc50e6 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 10:33:38 +1000 Subject: Make compile on X11 systems where qreal == float Reviewed-by: Sarah Smith --- src/gui/text/qfontdatabase_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index b582e4a..f184811 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1456,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; -- cgit v0.12 From 1a299a9631a2d1b4e07cedfece7af5318a766fe6 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 10:36:45 +1000 Subject: Optimize QGraphicsRotation's use of QMatrix4x4 Previous code was creating a full 3D rotation matrix and then projecting back to 2D. This change combines the two steps into one to avoid calculating matrix components that will be dropped. Reviewed-by: Sarah Smith --- src/gui/graphicsview/qgraphicstransform.cpp | 4 +- src/gui/math3d/qmatrix4x4.cpp | 108 ++++++++++++++++++++- src/gui/math3d/qmatrix4x4.h | 4 + .../qgraphicstransform/tst_qgraphicstransform.cpp | 69 ++++++++++++- 4 files changed, 179 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index a0b5493..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(1024.0f); // Project back to 2D. + matrix->projectedRotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z()); matrix->translate(-d->origin); } diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 00e8f15..fa3826f 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,6 +1105,110 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z) return *this; } +/*! + \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_VECTOR4D /*! @@ -1448,8 +1554,6 @@ QTransform QMatrix4x4::toTransform() const m[3][0], m[3][1], m[3][3]); } -static const qreal inv_dist_to_plane = 1. / 1024.; - /*! Returns the conventional Qt 2D transformation matrix that corresponds to this matrix. diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 42d992e..ba74b89 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -207,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/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index eb5c099..d8ab06e 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -59,6 +59,8 @@ private slots: void rotation(); void rotation3d_data(); void rotation3d(); + void rotation3dArbitraryAxis_data(); + void rotation3dArbitraryAxis(); }; @@ -88,7 +90,7 @@ static QTransform transform2D(const QGraphicsTransform& t) { QMatrix4x4 m; t.applyTo(&m); - return m.toTransform(0); + return m.toTransform(); } void tst_QGraphicsTransform::scale() @@ -255,6 +257,19 @@ void tst_QGraphicsTransform::rotation3d() QVERIFY(fuzzyCompare(transform2D(rotation), expected)); + // Check that "rotation" produces the 4x4 form of the 3x3 matrix. + // i.e. third row and column are 0 0 1 0. + t.setIdentity(); + rotation.applyTo(&t); + QMatrix4x4 r(expected); + if (sizeof(qreal) == sizeof(float) && angle == 268) { + // This test fails, on only this angle, when qreal == float + // because the deg2rad value in QTransform is not accurate + // enough to match what QMatrix4x4 is doing. + } else { + QVERIFY(qFuzzyCompare(t, r)); + } + //now let's check that a null vector will not change the transform rotation.setAxis(QVector3D(0, 0, 0)); rotation.setOrigin(QVector3D(10, 10, 0)); @@ -276,6 +291,58 @@ void tst_QGraphicsTransform::rotation3d() QVERIFY(transform2D(rotation).isIdentity()); } +void tst_QGraphicsTransform::rotation3dArbitraryAxis_data() +{ + QTest::addColumn("axis"); + QTest::addColumn("angle"); + + QVector3D axis1 = QVector3D(1.0f, 1.0f, 1.0f); + QVector3D axis2 = QVector3D(2.0f, -3.0f, 0.5f); + QVector3D axis3 = QVector3D(-2.0f, 0.0f, -0.5f); + QVector3D axis4 = QVector3D(0.0001f, 0.0001f, 0.0001f); + QVector3D axis5 = QVector3D(0.01f, 0.01f, 0.01f); + + for (int angle = 0; angle <= 360; angle++) { + QTest::newRow("test rotation on (1, 1, 1)") << axis1 << qreal(angle); + QTest::newRow("test rotation on (2, -3, .5)") << axis2 << qreal(angle); + QTest::newRow("test rotation on (-2, 0, -.5)") << axis3 << qreal(angle); + QTest::newRow("test rotation on (.0001, .0001, .0001)") << axis4 << qreal(angle); + QTest::newRow("test rotation on (.01, .01, .01)") << axis5 << qreal(angle); + } +} + +void tst_QGraphicsTransform::rotation3dArbitraryAxis() +{ + QFETCH(QVector3D, axis); + QFETCH(qreal, angle); + + QGraphicsRotation rotation; + rotation.setAxis(axis); + + QMatrix4x4 t; + rotation.applyTo(&t); + + QVERIFY(t.isIdentity()); + QVERIFY(transform2D(rotation).isIdentity()); + + rotation.setAngle(angle); + + // Compute the expected answer using QMatrix4x4 and a projection. + // These two steps are performed in one hit by QGraphicsRotation. + QMatrix4x4 exp; + exp.rotate(angle, axis); + QTransform expected = exp.toTransform(1024.0f); + + QVERIFY(fuzzyCompare(transform2D(rotation), expected)); + + // Check that "rotation" produces the 4x4 form of the 3x3 matrix. + // i.e. third row and column are 0 0 1 0. + t.setIdentity(); + rotation.applyTo(&t); + QMatrix4x4 r(expected); + QVERIFY(qFuzzyCompare(t, r)); +} + QTEST_MAIN(tst_QGraphicsTransform) #include "tst_qgraphicstransform.moc" -- cgit v0.12 From e7c6757f53f81442c138f4354db958a893d9e611 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 11:19:12 +1000 Subject: Fix ifdef around QMatrix4x4::rotate(QQuaternion) Reviewed-by: trustme --- src/gui/math3d/qmatrix4x4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index fa3826f..5d624d8 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1209,7 +1209,7 @@ QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z) return *this; } -#ifndef QT_NO_VECTOR4D +#ifndef QT_NO_QUATERNION /*! Multiples this matrix by another that rotates coordinates according -- cgit v0.12 From 91462fa3ac02aa88e3aeeacfa9fc4d4dbb8fe2a1 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 11:47:54 +1000 Subject: Optimize concatenation of partial shaders Reviewed-by: Sarah Smith --- src/opengl/qglshaderprogram.cpp | 123 ++++++++++++++++++++++++++++++---------- src/opengl/qglshaderprogram.h | 2 + 2 files changed, 95 insertions(+), 30 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 34114e4..ecb2566 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -444,7 +444,8 @@ bool QGLShader::compile(const char *source) d->hasPartialSource = true; return d->compile(this); } else if (d->shaderGuard.id()) { - QVarLengthArray src; + QVarLengthArray src; + QVarLengthArray srclen; int headerLen = 0; while (source && source[headerLen] == '#') { // Skip #version and #extension directives at the start of @@ -459,21 +460,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 +485,60 @@ bool QGLShader::compile(const char *source) } /*! + \internal +*/ +bool QGLShader::compile + (const QList& shaders, QGLShader::ShaderType type) +{ + QVarLengthArray src; + QVarLengthArray srclen; + if (!d->shaderGuard.id()) + return false; + foreach (QGLShader *shader, shaders) { + if (shader->shaderType() != type) + continue; + const char *source = shader->d->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. @@ -713,6 +771,8 @@ public: QList anonShaders; QGLShader *vertexShader; QGLShader *fragmentShader; + + bool hasShader(QGLShader::ShaderType type) const; }; QGLShaderProgramPrivate::~QGLShaderProgramPrivate() @@ -723,6 +783,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() @@ -1118,47 +1187,41 @@ bool QGLShaderProgram::link() 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; - } } else { + if (d->vertexShader) { + glDetachShader(program, d->vertexShader->d->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()); + } else { + if (d->fragmentShader) { + glDetachShader(program, d->fragmentShader->d->shaderGuard.id()); + delete d->fragmentShader; + d->fragmentShader = 0; + } } } glLinkProgram(program); diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h index f2d70fa..2848b5f 100644 --- a/src/opengl/qglshaderprogram.h +++ b/src/opengl/qglshaderprogram.h @@ -106,6 +106,8 @@ private: friend class QGLShaderProgram; Q_DISABLE_COPY(QGLShader) + + bool compile(const QList& shaders, QGLShader::ShaderType type); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType) -- cgit v0.12 From a161143b81d8b4cfce06d2566dbbd129a2e1b0e1 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 12:14:58 +1000 Subject: Use QObjectPrivate within QGLShaderPrivate and QGLShaderProgramPrivate Reviewed-by: Sarah Smith --- src/opengl/qglshaderprogram.cpp | 175 ++++++++++++++++++++++++++++++---------- src/opengl/qglshaderprogram.h | 6 +- 2 files changed, 134 insertions(+), 47 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index ecb2566..7fcd6f7 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 #include #include #include @@ -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,6 +450,7 @@ static const char redefineHighp[] = */ bool QGLShader::compile(const char *source) { + Q_D(QGLShader); if (d->isPartial) { d->partialSource = QByteArray(source); d->hasPartialSource = true; @@ -490,6 +502,7 @@ bool QGLShader::compile(const char *source) bool QGLShader::compile (const QList& shaders, QGLShader::ShaderType type) { + Q_D(QGLShader); QVarLengthArray src; QVarLengthArray srclen; if (!d->shaderGuard.id()) @@ -497,7 +510,7 @@ bool QGLShader::compile foreach (QGLShader *shader, shaders) { if (shader->shaderType() != type) continue; - const char *source = shader->d->partialSource.constData(); + const char *source = shader->d_func()->partialSource.constData(); int headerLen = 0; if (src.isEmpty()) { // First shader: handle the #version and #extension tags @@ -613,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; @@ -646,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; } @@ -692,6 +707,7 @@ QList QGLShader::shaderBinaryFormats() */ QByteArray QGLShader::sourceCode() const { + Q_D(const QGLShader); if (d->isPartial) return d->partialSource; GLuint shader = d->shaderGuard.id(); @@ -716,6 +732,7 @@ QByteArray QGLShader::sourceCode() const */ bool QGLShader::isCompiled() const { + Q_D(const QGLShader); return d->compiled; } @@ -726,6 +743,7 @@ bool QGLShader::isCompiled() const */ QString QGLShader::log() const { + Q_D(const QGLShader); return d->log; } @@ -740,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) @@ -804,9 +824,8 @@ bool QGLShaderProgramPrivate::hasShader(QGLShader::ShaderType type) const \sa addShader() */ QGLShaderProgram::QGLShaderProgram(QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderProgramPrivate(QGLContext::currentContext()), parent) { - d = new QGLShaderProgramPrivate(QGLContext::currentContext()); } /*! @@ -818,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); } /*! @@ -828,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; @@ -870,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; } @@ -912,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); @@ -977,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); @@ -996,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) { @@ -1016,6 +1038,7 @@ void QGLShaderProgram::removeShader(QGLShader *shader) */ QList QGLShaderProgram::shaders() const { + Q_D(const QGLShaderProgram); return d->shaders; } @@ -1029,10 +1052,11 @@ QList 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. @@ -1078,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(); @@ -1113,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(const QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; @@ -1182,6 +1208,7 @@ QList QGLShaderProgram::programBinaryFormats() */ bool QGLShaderProgram::link() { + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; @@ -1197,10 +1224,10 @@ bool QGLShaderProgram::link() d->log = d->vertexShader->log(); return false; } - glAttachShader(program, d->vertexShader->d->shaderGuard.id()); + glAttachShader(program, d->vertexShader->d_func()->shaderGuard.id()); } else { if (d->vertexShader) { - glDetachShader(program, d->vertexShader->d->shaderGuard.id()); + glDetachShader(program, d->vertexShader->d_func()->shaderGuard.id()); delete d->vertexShader; d->vertexShader = 0; } @@ -1215,10 +1242,10 @@ bool QGLShaderProgram::link() 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->shaderGuard.id()); + glDetachShader(program, d->fragmentShader->d_func()->shaderGuard.id()); delete d->fragmentShader; d->fragmentShader = 0; } @@ -1253,6 +1280,7 @@ bool QGLShaderProgram::link() */ bool QGLShaderProgram::isLinked() const { + Q_D(const QGLShaderProgram); return d->linked; } @@ -1264,6 +1292,7 @@ bool QGLShaderProgram::isLinked() const */ QString QGLShaderProgram::log() const { + Q_D(const QGLShaderProgram); return d->log; } @@ -1277,6 +1306,7 @@ QString QGLShaderProgram::log() const */ bool QGLShaderProgram::enable() { + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; @@ -1315,6 +1345,7 @@ void QGLShaderProgram::disable() */ GLuint QGLShaderProgram::programId() const { + Q_D(const QGLShaderProgram); return d->programGuard.id(); } @@ -1328,6 +1359,7 @@ GLuint QGLShaderProgram::programId() const */ void QGLShaderProgram::bindAttributeLocation(const char *name, int location) { + Q_D(QGLShaderProgram); if (!d->linked) { glBindAttribLocation(d->programGuard.id(), location, name); } else { @@ -1375,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 { @@ -1419,6 +1452,7 @@ int QGLShaderProgram::attributeLocation(const QString& name) const */ void QGLShaderProgram::setAttributeValue(int location, GLfloat value) { + Q_D(QGLShaderProgram); if (location != -1) glVertexAttrib1fv(location, &value); } @@ -1443,6 +1477,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat value) */ void QGLShaderProgram::setAttributeValue(int location, GLfloat x, GLfloat y) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[2] = {x, y}; glVertexAttrib2fv(location, values); @@ -1471,6 +1506,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat x, GLfloat y) void QGLShaderProgram::setAttributeValue (int location, GLfloat x, GLfloat y, GLfloat z) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[3] = {x, y, z}; glVertexAttrib3fv(location, values); @@ -1500,6 +1536,7 @@ void QGLShaderProgram::setAttributeValue void QGLShaderProgram::setAttributeValue (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {x, y, z, w}; glVertexAttrib4fv(location, values); @@ -1527,6 +1564,7 @@ void QGLShaderProgram::setAttributeValue */ void QGLShaderProgram::setAttributeValue(int location, const QVector2D& value) { + Q_D(QGLShaderProgram); if (location != -1) glVertexAttrib2fv(location, reinterpret_cast(&value)); } @@ -1550,6 +1588,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector2D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QVector3D& value) { + Q_D(QGLShaderProgram); if (location != -1) glVertexAttrib3fv(location, reinterpret_cast(&value)); } @@ -1573,6 +1612,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector3D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QVector4D& value) { + Q_D(QGLShaderProgram); if (location != -1) glVertexAttrib4fv(location, reinterpret_cast(&value)); } @@ -1596,6 +1636,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector4D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QColor& value) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {value.redF(), value.greenF(), value.blueF(), value.alphaF()}; glVertexAttrib4fv(location, values); @@ -1626,6 +1667,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QColor& value) void QGLShaderProgram::setAttributeValue (int location, const GLfloat *values, int columns, int rows) { + Q_D(QGLShaderProgram); if (rows < 1 || rows > 4) { qWarning() << "QGLShaderProgram::setAttributeValue: rows" << rows << "not supported"; return; @@ -1675,6 +1717,7 @@ void QGLShaderProgram::setAttributeValue void QGLShaderProgram::setAttributeArray (int location, const GLfloat *values, int size, int stride) { + Q_D(QGLShaderProgram); if (location != -1) { glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE, stride, values); @@ -1693,6 +1736,7 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector2D *values, int stride) { + Q_D(QGLShaderProgram); if (location != -1) { glVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, stride, values); @@ -1711,6 +1755,7 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector3D *values, int stride) { + Q_D(QGLShaderProgram); if (location != -1) { glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE, stride, values); @@ -1729,6 +1774,7 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector4D *values, int stride) { + Q_D(QGLShaderProgram); if (location != -1) { glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, stride, values); @@ -1809,6 +1855,7 @@ void QGLShaderProgram::setAttributeArray */ void QGLShaderProgram::disableAttributeArray(int location) { + Q_D(QGLShaderProgram); if (location != -1) glDisableVertexAttribArray(location); } @@ -1835,6 +1882,7 @@ void QGLShaderProgram::disableAttributeArray(const char *name) */ int QGLShaderProgram::uniformLocation(const char *name) const { + Q_D(const QGLShaderProgram); if (d->linked) { return glGetUniformLocation(d->programGuard.id(), name); } else { @@ -1879,6 +1927,7 @@ int QGLShaderProgram::uniformLocation(const QString& name) const */ void QGLShaderProgram::setUniformValue(int location, GLfloat value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1fv(location, 1, &value); } @@ -1903,6 +1952,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat value) */ void QGLShaderProgram::setUniformValue(int location, GLint value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1i(location, value); } @@ -1928,6 +1978,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLint value) */ void QGLShaderProgram::setUniformValue(int location, GLuint value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1i(location, value); } @@ -1953,6 +2004,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLuint value) */ void QGLShaderProgram::setUniformValue(int location, GLfloat x, GLfloat y) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[2] = {x, y}; glUniform2fv(location, 1, values); @@ -1981,6 +2033,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat x, GLfloat y) void QGLShaderProgram::setUniformValue (int location, GLfloat x, GLfloat y, GLfloat z) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[3] = {x, y, z}; glUniform3fv(location, 1, values); @@ -2010,6 +2063,7 @@ void QGLShaderProgram::setUniformValue void QGLShaderProgram::setUniformValue (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {x, y, z, w}; glUniform4fv(location, 1, values); @@ -2037,6 +2091,7 @@ void QGLShaderProgram::setUniformValue */ void QGLShaderProgram::setUniformValue(int location, const QVector2D& value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform2fv(location, 1, reinterpret_cast(&value)); } @@ -2061,6 +2116,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector2D& value) */ void QGLShaderProgram::setUniformValue(int location, const QVector3D& value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform3fv(location, 1, reinterpret_cast(&value)); } @@ -2085,6 +2141,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector3D& value) */ void QGLShaderProgram::setUniformValue(int location, const QVector4D& value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform4fv(location, 1, reinterpret_cast(&value)); } @@ -2110,6 +2167,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector4D& value) */ void QGLShaderProgram::setUniformValue(int location, const QColor& color) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {color.redF(), color.greenF(), color.blueF(), color.alphaF()}; glUniform4fv(location, 1, values); @@ -2137,6 +2195,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QColor& color) */ void QGLShaderProgram::setUniformValue(int location, const QPoint& point) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {point.x(), point.y()}; glUniform2fv(location, 1, values); @@ -2164,6 +2223,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPoint& point) */ void QGLShaderProgram::setUniformValue(int location, const QPointF& point) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {point.x(), point.y()}; glUniform2fv(location, 1, values); @@ -2191,6 +2251,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPointF& point) */ void QGLShaderProgram::setUniformValue(int location, const QSize& size) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {size.width(), size.width()}; glUniform2fv(location, 1, values); @@ -2218,6 +2279,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSize& size) */ void QGLShaderProgram::setUniformValue(int location, const QSizeF& size) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {size.width(), size.height()}; glUniform2fv(location, 1, values); @@ -2297,6 +2359,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size) */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value) { + Q_D(QGLShaderProgram); setUniformMatrix(glUniformMatrix2fv, location, value, 2, 2); } @@ -2321,6 +2384,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix2x3fv, glUniform3fv, location, value, 2, 3); } @@ -2346,6 +2410,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix2x4fv, glUniform4fv, location, value, 2, 4); } @@ -2371,6 +2436,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x4& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix3x2fv, glUniform2fv, location, value, 3, 2); } @@ -2396,6 +2462,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value) { + Q_D(QGLShaderProgram); setUniformMatrix(glUniformMatrix3fv, location, value, 3, 3); } @@ -2420,6 +2487,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix3x4fv, glUniform4fv, location, value, 3, 4); } @@ -2445,6 +2513,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x4& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix4x2fv, glUniform2fv, location, value, 4, 2); } @@ -2470,6 +2539,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix4x3fv, glUniform3fv, location, value, 4, 3); } @@ -2495,6 +2565,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value) { + Q_D(QGLShaderProgram); setUniformMatrix(glUniformMatrix4fv, location, value, 4, 4); } @@ -2522,6 +2593,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value */ void QGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4]) { + Q_D(QGLShaderProgram); if (location != -1) glUniformMatrix4fv(location, 1, GL_FALSE, value[0]); } @@ -2549,6 +2621,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[4][ */ void QGLShaderProgram::setUniformValue(int location, const QTransform& value) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat mat[3][3] = { {value.m11(), value.m12(), value.m13()}, @@ -2582,6 +2655,7 @@ void QGLShaderProgram::setUniformValue */ void QGLShaderProgram::setUniformValueArray(int location, const GLint *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1iv(location, count, values); } @@ -2609,6 +2683,7 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1iv(location, count, reinterpret_cast(values)); } @@ -2637,6 +2712,7 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int size) { + Q_D(QGLShaderProgram); if (location != -1) { if (size == 1) glUniform1fv(location, count, values); @@ -2674,6 +2750,7 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const QVector2D *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform2fv(location, count, reinterpret_cast(values)); } @@ -2699,6 +2776,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector2D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QVector3D *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform3fv(location, count, reinterpret_cast(values)); } @@ -2724,6 +2802,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector3D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QVector4D *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform4fv(location, count, reinterpret_cast(values)); } @@ -2810,6 +2889,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector4D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x2 *values, int count) { + Q_D(QGLShaderProgram); setUniformMatrixArray (glUniformMatrix2fv, location, values, count, QMatrix2x2, 2, 2); } @@ -2835,6 +2915,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x3 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix2x3fv, glUniform3fv, location, values, count, QMatrix2x3, 2, 3); @@ -2861,6 +2942,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x4 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix2x4fv, glUniform4fv, location, values, count, QMatrix2x4, 2, 4); @@ -2887,6 +2969,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x4 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x2 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix3x2fv, glUniform2fv, location, values, count, QMatrix3x2, 3, 2); @@ -2913,6 +2996,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x3 *values, int count) { + Q_D(QGLShaderProgram); setUniformMatrixArray (glUniformMatrix3fv, location, values, count, QMatrix3x3, 3, 3); } @@ -2938,6 +3022,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x4 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix3x4fv, glUniform4fv, location, values, count, QMatrix3x4, 3, 4); @@ -2964,6 +3049,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x4 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x2 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix4x2fv, glUniform2fv, location, values, count, QMatrix4x2, 4, 2); @@ -2990,6 +3076,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x3 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix4x3fv, glUniform3fv, location, values, count, QMatrix4x3, 4, 3); @@ -3016,6 +3103,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x4 *values, int count) { + Q_D(QGLShaderProgram); setUniformMatrixArray (glUniformMatrix4fv, location, values, count, QMatrix4x4, 4, 4); } @@ -3061,6 +3149,7 @@ bool QGLShaderProgram::hasShaderPrograms(const QGLContext *context) */ void QGLShaderProgram::shaderDestroyed() { + Q_D(QGLShaderProgram); QGLShader *shader = qobject_cast(sender()); if (shader && !d->removingShaders) removeShader(shader); diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h index 2848b5f..d8b9a0c 100644 --- a/src/opengl/qglshaderprogram.h +++ b/src/opengl/qglshaderprogram.h @@ -101,11 +101,10 @@ public: GLuint shaderId() const; private: - QGLShaderPrivate *d; - friend class QGLShaderProgram; Q_DISABLE_COPY(QGLShader) + Q_DECLARE_PRIVATE(QGLShader) bool compile(const QList& shaders, QGLShader::ShaderType type); }; @@ -288,9 +287,8 @@ private Q_SLOTS: void shaderDestroyed(); private: - QGLShaderProgramPrivate *d; - Q_DISABLE_COPY(QGLShaderProgram) + Q_DECLARE_PRIVATE(QGLShaderProgram) bool init(); }; -- cgit v0.12 From f97cbb44be9e6195ee5a15a687a963ea5bb2f547 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 12:41:19 +1000 Subject: Fix OpenGL/ES 2.0 bug in previous QGLShaderProgram check-in --- src/opengl/qglshaderprogram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 7fcd6f7..b20c6e9 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -1138,7 +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(const QGLShaderProgram); + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; -- cgit v0.12 From ded1dbb7e898364dd1cd2b1b129673569805a786 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 13:02:06 +1000 Subject: Suppress warnings under OpenGL/ES 2.0 in QGLShaderProgram --- src/opengl/qglshaderprogram.cpp | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index b20c6e9..d028522 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -1453,6 +1453,7 @@ 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); } @@ -1478,6 +1479,7 @@ 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); @@ -1507,6 +1509,7 @@ 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); @@ -1537,6 +1540,7 @@ 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); @@ -1565,6 +1569,7 @@ void QGLShaderProgram::setAttributeValue void QGLShaderProgram::setAttributeValue(int location, const QVector2D& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib2fv(location, reinterpret_cast(&value)); } @@ -1589,6 +1594,7 @@ 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(&value)); } @@ -1613,6 +1619,7 @@ 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(&value)); } @@ -1637,6 +1644,7 @@ 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); @@ -1668,6 +1676,7 @@ 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; @@ -1718,6 +1727,7 @@ 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); @@ -1737,6 +1747,7 @@ 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); @@ -1756,6 +1767,7 @@ 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); @@ -1775,6 +1787,7 @@ 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); @@ -1856,6 +1869,7 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::disableAttributeArray(int location) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glDisableVertexAttribArray(location); } @@ -1883,6 +1897,7 @@ 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 { @@ -1928,6 +1943,7 @@ 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); } @@ -1953,6 +1969,7 @@ 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); } @@ -1979,6 +1996,7 @@ 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); } @@ -2005,6 +2023,7 @@ 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); @@ -2034,6 +2053,7 @@ 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); @@ -2064,6 +2084,7 @@ 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); @@ -2092,6 +2113,7 @@ 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(&value)); } @@ -2117,6 +2139,7 @@ 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(&value)); } @@ -2142,6 +2165,7 @@ 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(&value)); } @@ -2168,6 +2192,7 @@ 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); @@ -2196,6 +2221,7 @@ 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); @@ -2224,6 +2250,7 @@ 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); @@ -2252,6 +2279,7 @@ 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); @@ -2280,6 +2308,7 @@ 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); @@ -2360,6 +2389,7 @@ 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); } @@ -2385,6 +2415,7 @@ 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); } @@ -2411,6 +2442,7 @@ 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); } @@ -2437,6 +2469,7 @@ 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); } @@ -2463,6 +2496,7 @@ 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); } @@ -2488,6 +2522,7 @@ 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); } @@ -2514,6 +2549,7 @@ 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); } @@ -2540,6 +2576,7 @@ 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); } @@ -2566,6 +2603,7 @@ 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); } @@ -2594,6 +2632,7 @@ 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]); } @@ -2622,6 +2661,7 @@ 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()}, @@ -2656,6 +2696,7 @@ 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); } @@ -2684,6 +2725,7 @@ 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(values)); } @@ -2713,6 +2755,7 @@ 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); @@ -2751,6 +2794,7 @@ 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(values)); } @@ -2777,6 +2821,7 @@ 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(values)); } @@ -2803,6 +2848,7 @@ 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(values)); } @@ -2890,6 +2936,7 @@ 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); } @@ -2916,6 +2963,7 @@ 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); @@ -2943,6 +2991,7 @@ 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); @@ -2970,6 +3019,7 @@ 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); @@ -2997,6 +3047,7 @@ 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); } @@ -3023,6 +3074,7 @@ 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); @@ -3050,6 +3102,7 @@ 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); @@ -3077,6 +3130,7 @@ 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); @@ -3104,6 +3158,7 @@ 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); } -- cgit v0.12 From 35c8033ff51ab6d0567e786b790b8cc49852803b Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 13:09:05 +1000 Subject: Suppress warnings in QtOpenGL code --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 1 + src/opengl/qwindowsurface_gl.cpp | 2 +- src/opengl/qwindowsurface_x11gl.cpp | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) 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/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(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; } -- cgit v0.12 From d2c9895fbc116ef87f9cc1161258fd4bba727c6c Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 26 Oct 2009 11:09:18 +0100 Subject: Fixed typo in configure usage (superfluous hyphen). Reviewed-by: Thiago Macieira --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index d97149d..035bd4a 100755 --- a/configure +++ b/configure @@ -3223,7 +3223,7 @@ Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir [-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libtiff] [-qt-libtiff] [-system-libtiff] [-no-libpng] [-qt-libpng] [-system-libpng] [-no-libmng] [-qt-libmng] [-system-libmng] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg] [-make ] - [-no-make ] [-R ] [-l ] [-no-rpath] [-rpath] [-continue] + [-nomake ] [-R ] [-l ] [-no-rpath] [-rpath] [-continue] [-verbose] [-v] [-silent] [-no-nis] [-nis] [-no-cups] [-cups] [-no-iconv] [-iconv] [-no-pch] [-pch] [-no-dbus] [-dbus] [-dbus-linked] [-no-separate-debug-info] [-no-mmx] [-no-3dnow] [-no-sse] [-no-sse2] -- cgit v0.12 From 3f7a99565de7ed17d7ac4c0a25b02997b094b1a9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2009 10:56:57 +0100 Subject: Fix linking of WebKit on Linux 32-bit. It was missing the ".text" directive at the top of the file, indicating that code would follow. Without it, the assembler created "NOTYPE" symbols, which would result in linker errors. --- src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index 90ea807..2cbc13d 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -75,7 +75,7 @@ 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) @@ -93,6 +93,7 @@ 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" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" -- cgit v0.12 From e2ef97128c006ac2a5c99c67bb54eebaa3b45720 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2009 11:04:21 +0100 Subject: Implement symbol hiding for JSC's JIT functions. These functions are implemented directly in assembly, so they need the proper directives to enable/disable visibility. On ELF systems, it's .hidden, whereas on Mach-O systems (Mac) it's .private_extern. On Windows, it's not necessary since you have to explicitly export. I also implemented the AIX idiom, though it's unlikely anyone will implement AIX/POWER JIT. That leaves only HP-UX on PA-RISC unimplemented, from the platforms that Qt supports. It's also unlikely that we'll imlpement JIT for it. Reviewed-by: Kent Hansen (this commit was 26d0990c66068bfc92a2ec77512b26d4a0c11b02, but was lost during a WebKit update) --- .../webkit/JavaScriptCore/jit/JITStubs.cpp | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index 2cbc13d..457518c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -81,6 +81,19 @@ namespace JSC { #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) @@ -95,6 +108,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_ asm volatile ( ".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" "movl %esp, %ebp" "\n" @@ -115,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" @@ -130,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" @@ -154,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" @@ -180,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" @@ -195,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" @@ -216,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" @@ -242,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" @@ -347,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" @@ -368,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" @@ -383,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" @@ -405,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" @@ -439,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" @@ -454,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" @@ -475,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" @@ -501,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" @@ -518,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" @@ -532,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" @@ -556,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" @@ -565,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" @@ -899,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" \ -- cgit v0.12 From 96b18246c4930332cadc80f97202e44110e22a4d Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 26 Oct 2009 13:58:03 +0100 Subject: QPixmap::loadFromData: Do not crash on empty/invalid data/length Task-number: 262636 Reviewed-by: gunnar --- src/gui/image/qpixmap.cpp | 3 +++ tests/auto/qpixmap/tst_qpixmap.cpp | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) 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/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 9f5aee2..53b6230 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -166,6 +166,7 @@ private slots: void fromImage_crash(); void fromData(); + void loadFromDataNullValues(); void preserveDepth(); }; @@ -1436,6 +1437,26 @@ void tst_QPixmap::fromData() QCOMPARE(img.pixel(0, 1), QRgb(0xff000000)); } +void tst_QPixmap::loadFromDataNullValues() +{ + { + QPixmap pixmap; + pixmap.loadFromData(QByteArray()); + QVERIFY(pixmap.isNull()); + } + { + QPixmap pixmap; + pixmap.loadFromData(0, 123); + QVERIFY(pixmap.isNull()); + } + { + QPixmap pixmap; + const uchar bla[] = "bla"; + pixmap.loadFromData(bla, 0); + QVERIFY(pixmap.isNull()); + } +} + void tst_QPixmap::task_246446() { // This crashed without the bugfix in 246446 -- cgit v0.12 From 1fe977fde34b29207c285ed37456c4277b348b2a Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 26 Oct 2009 14:43:15 +0100 Subject: tst_qtcpsocket: Increased some of the timeouts to increase stability Reviewed-by: TrustMe --- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 8ea137e..5577903 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -2096,7 +2096,7 @@ void tst_QTcpSocket::connectToMultiIP() stopWatch.restart(); socket->connectToHost("multi.dev.troll.no", 81); - QVERIFY(!socket->waitForConnected(1000)); + QVERIFY(!socket->waitForConnected(2000)); QVERIFY(stopWatch.elapsed() < 2000); QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError); @@ -2116,7 +2116,7 @@ void tst_QTcpSocket::moveToThread0() QTcpSocket *socket = newSocket();; socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->moveToThread(0); - QVERIFY(socket->waitForConnected(1000)); + QVERIFY(socket->waitForConnected(2000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(socket->waitForDisconnected()); @@ -2127,7 +2127,7 @@ void tst_QTcpSocket::moveToThread0() QTcpSocket *socket = newSocket(); socket->moveToThread(0); socket->connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket->waitForConnected(1000)); + QVERIFY(socket->waitForConnected(2000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(socket->waitForDisconnected()); @@ -2137,7 +2137,7 @@ void tst_QTcpSocket::moveToThread0() // Case 3: Moved after writing, while waiting for bytes to be written. QTcpSocket *socket = newSocket(); socket->connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket->waitForConnected(1000)); + QVERIFY(socket->waitForConnected(2000)); socket->write("XXX LOGOUT\r\n"); socket->moveToThread(0); QVERIFY(socket->waitForBytesWritten(5000)); @@ -2148,7 +2148,7 @@ void tst_QTcpSocket::moveToThread0() // Case 4: Moved after writing, while waiting for response. QTcpSocket *socket = newSocket(); socket->connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket->waitForConnected(1000)); + QVERIFY(socket->waitForConnected(2000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); socket->moveToThread(0); @@ -2263,7 +2263,7 @@ void tst_QTcpSocket::invalidProxy() QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } else { QCOMPARE(socket->state(), QAbstractSocket::ConnectingState); - QVERIFY(!socket->waitForConnected(1000)); + QVERIFY(!socket->waitForConnected(2000)); } QVERIFY(!socket->errorString().isEmpty()); @@ -2382,7 +2382,7 @@ void tst_QTcpSocket::proxyFactory() QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } else { QCOMPARE(socket->state(), QAbstractSocket::ConnectingState); - QVERIFY(socket->waitForConnected(10000)); + QVERIFY(socket->waitForConnected(2000)); QCOMPARE(proxyAuthCalled, 1); } QVERIFY(!socket->errorString().isEmpty()); -- cgit v0.12 From 17bf093fa0fb041c2b9a6fec71b90a8630fba1ff Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 26 Oct 2009 15:16:32 +0100 Subject: QSslSocket: Add \reimp to the socket option functions Reviewed-by: Thiago --- src/network/ssl/qsslsocket.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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); -- cgit v0.12 From 755b4b9db0fdb6caec8ccc43aba30e7cdd3909f1 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 23 Oct 2009 15:09:25 +0200 Subject: Doc: Fixed whitespace issue. Reviewed-by: Trust Me --- doc/src/platforms/qt-embedded.qdoc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/src/platforms/qt-embedded.qdoc b/doc/src/platforms/qt-embedded.qdoc index c39a967..e0c35cc 100644 --- a/doc/src/platforms/qt-embedded.qdoc +++ b/doc/src/platforms/qt-embedded.qdoc @@ -68,10 +68,9 @@ environment and use native features, such as menus, to conform to the native style guidelines. \o \l{Symbian platform - Introduction to using Qt}{Qt for the Symbian -platform} is used to create - applications running in existing Symbian platform environments. - Applications use the appropriate style for the embedded - environment and use native features, such as menus, to conform + platform} is used to create applications running in existing Symbian + platform environments. Applications use the appropriate style for the + embedded environment and use native features, such as menus, to conform to the native style guidelines. \endtable */ -- cgit v0.12 From b5254a2500afebf74d5772c3ec0e03dc5c9243b6 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 26 Oct 2009 15:57:20 +0100 Subject: Doc: Fixed qdoc warnings. Reviewed-by: Trust Me --- src/gui/graphicsview/qgraphicsitem.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f892bb4..edd2d7c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1228,7 +1228,8 @@ void QGraphicsItemCache::purge() } /*! - Constructs a QGraphicsItem, passing \a item to QGraphicsItem's constructor. It does not modify \fn QObject::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 */ /*! @@ -7318,7 +7334,10 @@ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext co /*! \property QGraphicsObject::parent - \brief the parent of the item. It is independent from \fn QObject::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() */ -- cgit v0.12 From aa290742462819d6d6dd9b08675dc8d59d824787 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 26 Oct 2009 15:58:46 +0100 Subject: Doc: Fixed qdoc warnings. Reviewed-by: Trust Me --- src/corelib/global/qnamespace.qdoc | 3 +++ src/gui/kernel/qgesture.cpp | 6 ------ src/gui/kernel/qstandardgestures.cpp | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) 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/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/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) { -- cgit v0.12 From 6f36d0aafaccbb9affe8ac1b82c225d985aa7491 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 26 Oct 2009 17:35:17 +0100 Subject: Doc: Added internal or hidden placeholder documentation. Reviewed-by: Trust Me To-be-completed-by: QtWebKit developers --- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 -- cgit v0.12 From 83aa359398a8a510ac732410c918d31eedeeb4f8 Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 23 Oct 2009 15:43:28 +0200 Subject: Revert "Re-apply change 8e0fbc2caa3edefb78d6667721235b783bc1a850 by Iain" This reverts commit f4abf627a8d097e095022d2709718a681b54bd7e. DEF file was unconditionally enabled for Webkit, ignoring setting in qtbase.pri, which was supposed to be the global place to enable/disable DEF file usage. Remove this workaround since we still haven't got DEF files switched on by default. (cherry picked from commit 3b7f570e6f296ef0a5c9c581ed06cb19986164a0) --- src/3rdparty/webkit/WebCore/WebCore.pro | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index f321aad..a835fc7 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -87,19 +87,6 @@ win32-g++ { QMAKE_LIBDIR_POST += $$split(TMPPATH,";") } -# Temporary workaround to pick up the DEF file from the same place as all the others -symbian { - shared { - MMP_RULES -= defBlock - - MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ - "DEFFILE ../../../s60installs/bwins/$${TARGET}.def" \ - "$${LITERAL_HASH}elif defined EABI" \ - "DEFFILE ../../../s60installs/eabi/$${TARGET}.def" \ - "$${LITERAL_HASH}endif" - } -} - # Assume that symbian OS always comes with sqlite symbian:!CONFIG(QTDIR_build): CONFIG += system-sqlite -- cgit v0.12 From b5efa250a6706821cf9969752a8fd063d1f206d6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2009 19:24:13 +0100 Subject: Autotest: fix building tst_qsqlquery. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'का' is not valid, since it encodes to more than 1 byte. Reviewed-by: Trust Me --- tests/auto/qsqlquery/tst_qsqlquery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 8fe6f2e..a9b522f 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -396,7 +396,7 @@ void tst_QSqlQuery::char1SelectUnicode() QSKIP("Needs someone with more Unicode knowledge than I have to fix", SkipSingle); if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) { - QString uniStr( QChar( 'का' ) ); + QString uniStr( QChar(0x0915) ); // DEVANAGARI LETTER KA QSqlQuery q( db ); if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 ) -- cgit v0.12 From 55ee937db840b69d100905b08d8f645fe79f9571 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 27 Oct 2009 14:49:07 +1000 Subject: Fixes Oracle batchExec using strings as out params. reserve() affects capacity(), not length(). Task-number: QTBUG-551 --- src/sql/drivers/oci/qsql_oci.cpp | 11 +++++-- tests/auto/qsqlquery/tst_qsqlquery.cpp | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) 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 &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 &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]; } diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index a9b522f..4d9e50f 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -193,6 +193,8 @@ private slots: void sqlServerReturn0_data() { generic_data(); } void sqlServerReturn0(); + void QTBUG_551_data() { generic_data("QOCI"); } + void QTBUG_551(); private: // returns all database connections @@ -322,6 +324,11 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) tablenames << qTableName("test141895"); tst_Databases::safeDropTables( db, tablenames ); + + if ( db.driverName().startsWith( "QOCI" ) ) { + QSqlQuery q( db ); + q.exec( "DROP PACKAGE " + qTableName("pkg") ); + } } void tst_QSqlQuery::createTestTables( QSqlDatabase db ) @@ -2847,5 +2854,52 @@ void tst_QSqlQuery::sqlServerReturn0() QVERIFY_SQL(q, next()); } +void tst_QSqlQuery::QTBUG_551() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + QSqlQuery q(db); + QString pkgname=qTableName("pkg"); + QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE "+pkgname+" IS \n\ + \n\ + TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\ + TYPE VCType IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;\n\ + PROCEDURE P (Inp IN IntType, Outp OUT VCType);\n\ + END "+pkgname+";")); + + QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE BODY "+pkgname+" IS\n\ + PROCEDURE P (Inp IN IntType, Outp OUT VCType)\n\ + IS\n\ + BEGIN\n\ + Outp(1) := '1. Value is ' ||TO_CHAR(Inp(1));\n\ + Outp(2) := '2. Value is ' ||TO_CHAR(Inp(2));\n\ + Outp(3) := '3. Value is ' ||TO_CHAR(Inp(3));\n\ + END p;\n\ + END "+pkgname+";")); + + QVariantList inLst, outLst, res_outLst; + + q.prepare("begin "+pkgname+".p(:inp, :outp); end;"); + + QString StVal; + StVal.reserve(60); + + // loading arrays + for (int Cnt=0; Cnt < 3; Cnt++) { + inLst << Cnt; + outLst << StVal; + } + + q.bindValue(":inp", inLst); + q.bindValue(":outp", outLst, QSql::Out); + + QVERIFY_SQL(q, execBatch(QSqlQuery::ValuesAsColumns) ); + res_outLst = qVariantValue(q.boundValues()[":outp"]); + QCOMPARE(res_outLst[0].toString(), QLatin1String("1. Value is 0")); + QCOMPARE(res_outLst[1].toString(), QLatin1String("2. Value is 1")); + QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2")); +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" -- cgit v0.12 From f06d7a128bf6b231fde521f7008db48138783731 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 27 Oct 2009 15:32:19 +1000 Subject: Use vgClear() to clear the background during screen compositing. This fixes an "off by 1" bug in screen compositing with OpenVG that left lines all over the background when windows were moved. Task-number: QT-2322 Reviewed-by: Sarah Smith --- src/openvg/qpaintengine_vg.cpp | 64 ++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index da07c1d..f8dd8a5 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -3527,27 +3527,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 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 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 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 -- cgit v0.12 From 5a4909d9f87b9abf471908a085c0e9f31b7e0a50 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 27 Oct 2009 16:38:24 +1000 Subject: Fix OpenVG window composition when opacity != 1 Task-number: QT-2322 Reviewed-by: Sarah Smith --- src/openvg/qpaintengine_vg.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index f8dd8a5..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); @@ -3558,7 +3554,7 @@ void QVGCompositionHelper::fillBackground 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); + -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. @@ -3612,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); -- cgit v0.12