diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 1 | ||||
-rw-r--r-- | src/corelib/tools/qscopedpointer.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qshareddata.cpp | 13 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 4 | ||||
-rw-r--r-- | src/opengl/qglshaderprogram.cpp | 197 | ||||
-rw-r--r-- | src/svg/qsvghandler.cpp | 150 |
6 files changed, 249 insertions, 120 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 099fdf4..58f6537 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1589,6 +1589,7 @@ QVariant::QVariant(const char *val) \fn QVariant::QVariant(float val) Constructs a new variant with a floating point value, \a val. + \since 4.6 */ /*! diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index 7efd979..44238a8 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -119,6 +119,10 @@ QT_BEGIN_NAMESPACE \sa QSharedPointer */ +/*! \typedef QScopedPointer::pointer + \internal + */ + /*! \fn QScopedPointer::QScopedPointer(T *p = 0) diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp index 3d1a339..85b8244 100644 --- a/src/corelib/tools/qshareddata.cpp +++ b/src/corelib/tools/qshareddata.cpp @@ -231,6 +231,15 @@ QT_BEGIN_NAMESPACE \sa QSharedData, QExplicitlySharedDataPointer, QScopedPointer, QSharedPointer */ +/*! \typedef QSharedDataPointer::Type + This is the type of the shared data object. The \e{d pointer} + points to an object of this type. + */ + +/*! \typedef QSharedDataPointer::pointer + \internal + */ + /*! \fn T& QSharedDataPointer::operator*() Provides access to the shared data object's members. This function calls detach(). @@ -552,4 +561,8 @@ QT_BEGIN_NAMESPACE points to an object of this type. */ +/*! \typedef QExplicitlySharedDataPointer::pointer + \internal + */ + QT_END_NAMESPACE diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 14502c7..2fd3070 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -275,13 +275,17 @@ public: GLuint current_fbo; QPaintEngine *active_engine; + static inline QGLContextGroupResources *qt_get_context_group(const QGLContext *ctx) { return ctx->d_ptr->groupResources; } + #ifdef Q_WS_WIN static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *ctx) { return ctx->d_ptr->groupResources->extensionFuncs; } + static inline QGLExtensionFuncs& qt_get_extension_funcs(QGLContextGroupResources *ctx) { return ctx->extensionFuncs; } #endif #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) static QGLExtensionFuncs qt_extensionFuncs; static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *) { return qt_extensionFuncs; } + static inline QGLExtensionFuncs& qt_get_extension_funcs(QGLContextGroupResources *ctx) { return qt_extensionFuncs; } #endif QPixmapFilter *createPixmapFilter(int type) const; diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 88e8fb0..c9bfd08 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -246,11 +246,17 @@ QT_BEGIN_NAMESPACE #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #endif +inline bool qt_check_sharing_with_current_context(QGLContextGroupResources *group) +{ + const QGLContext *context = QGLContext::currentContext(); + return context && QGLContextPrivate::qt_get_context_group(context) == group; +} + class QGLShaderPrivate { public: - QGLShaderPrivate(QGLShader::ShaderType type, const QGLContext *ctx) - : context(ctx) + QGLShaderPrivate(QGLShader::ShaderType type) + : ctx(0) , shader(0) , shaderType(type) , compiled(false) @@ -259,7 +265,7 @@ public: { } - const QGLContext *context; + QGLContextGroupResources *ctx; GLuint shader; QGLShader::ShaderType shaderType; bool compiled; @@ -268,20 +274,19 @@ public: QString log; QByteArray partialSource; - bool create(); + bool create(const QGLContext *context); bool compile(QGLShader *q); }; -#define ctx context - -bool QGLShaderPrivate::create() +bool QGLShaderPrivate::create(const QGLContext *context) { - if (isPartial) - return true; if (!context) context = QGLContext::currentContext(); if (!context) return false; + ctx = QGLContextPrivate::qt_get_context_group(context); + if (isPartial) + return true; if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(context))) { if (shaderType == QGLShader::VertexShader) shader = glCreateShader(GL_VERTEX_SHADER); @@ -327,9 +332,6 @@ bool QGLShaderPrivate::compile(QGLShader *q) return compiled; } -#undef ctx -#define ctx d->context - /*! Constructs a new QGLShader object of the specified \a type and attaches it to \a parent. If shader programs are not supported, @@ -345,8 +347,8 @@ bool QGLShaderPrivate::compile(QGLShader *q) QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) : QObject(parent) { - d = new QGLShaderPrivate(type, QGLContext::currentContext()); - d->create(); + d = new QGLShaderPrivate(type); + d->create(QGLContext::currentContext()); } /*! @@ -362,10 +364,12 @@ QGLShader::QGLShader (const QString& fileName, QGLShader::ShaderType type, QObject *parent) : QObject(parent) { - d = new QGLShaderPrivate(type, QGLContext::currentContext()); - if (d->create() && !compileFile(fileName)) { - if (d->shader) + d = new QGLShaderPrivate(type); + if (d->create(QGLContext::currentContext()) && !compileFile(fileName)) { + if (d->shader) { + QGLContextGroupResources *ctx = d->ctx; glDeleteShader(d->shader); + } d->shader = 0; } } @@ -385,8 +389,14 @@ QGLShader::QGLShader QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent) : QObject(parent) { - d = new QGLShaderPrivate(type, context); - d->create(); + d = new QGLShaderPrivate(type); +#ifndef QT_NO_DEBUG + if (context && !qgl_share_reg()->checkSharing(context, QGLContext::currentContext())) { + qWarning("QGLShader::QGLShader: \'context\' must be the currect context or sharing with it."); + return; + } +#endif + d->create(context); } /*! @@ -402,10 +412,18 @@ QGLShader::QGLShader (const QString& fileName, QGLShader::ShaderType type, const QGLContext *context, QObject *parent) : QObject(parent) { - d = new QGLShaderPrivate(type, context); - if (d->create() && !compileFile(fileName)) { - if (d->shader) + d = new QGLShaderPrivate(type); +#ifndef QT_NO_DEBUG + if (context && !qgl_share_reg()->checkSharing(context, QGLContext::currentContext())) { + qWarning("QGLShader::QGLShader: \'context\' must be currect context or sharing with it."); + return; + } +#endif + if (d->create(context) && !compileFile(fileName)) { + if (d->shader) { + QGLContextGroupResources *ctx = d->ctx; glDeleteShader(d->shader); + } d->shader = 0; } } @@ -417,8 +435,15 @@ QGLShader::QGLShader */ QGLShader::~QGLShader() { - if (d->shader) + if (d->shader) { + QGLContextGroupResources *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) + qWarning("QGLShader::~QGLShader: Shader is not associated with current context."); + else +#endif glDeleteShader(d->shader); + } delete d; } @@ -464,6 +489,12 @@ static const char redefineHighp[] = */ bool QGLShader::compile(const char *source) { +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(d->ctx)) { + qWarning("QGLShader::compile: Shader is not associated with current context."); + return false; + } +#endif if (d->isPartial) { d->partialSource = QByteArray(source); d->hasPartialSource = true; @@ -479,6 +510,7 @@ bool QGLShader::compile(const char *source) src.append(redefineHighp); #endif src.append(source); + QGLContextGroupResources *ctx = d->ctx; glShaderSource(d->shader, src.size(), src.data(), 0); return d->compile(this); } else { @@ -561,6 +593,14 @@ bool QGLShader::compileFile(const QString& fileName) */ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) { + QGLContextGroupResources *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) { + qWarning("QGLShader::setShaderBinary: Shader is not associated with current context."); + return false; + } +#endif + #if !defined(QT_OPENGL_ES_2) if (!glShaderBinary) return false; @@ -593,6 +633,14 @@ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) bool QGLShader::setShaderBinary (QGLShader& otherShader, GLenum format, const void *binary, int length) { + QGLContextGroupResources *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) { + qWarning("QGLShader::setShaderBinary: Shader is not associated with current context."); + return false; + } +#endif + #if !defined(QT_OPENGL_ES_2) if (!glShaderBinary) return false; @@ -639,11 +687,19 @@ QList<GLenum> QGLShader::shaderBinaryFormats() */ QByteArray QGLShader::sourceCode() const { +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(d->ctx)) { + qWarning("QGLShader::sourceCode: Shader is not associated with current context."); + return false; + } +#endif + if (d->isPartial) return d->partialSource; if (!d->shader) return QByteArray(); GLint size = 0; + QGLContextGroupResources *ctx = d->ctx; glGetShaderiv(d->shader, GL_SHADER_SOURCE_LENGTH, &size); if (size <= 0) return QByteArray(); @@ -689,14 +745,11 @@ GLuint QGLShader::shaderId() const return d->shader; } -#undef ctx -#define ctx context - class QGLShaderProgramPrivate { public: - QGLShaderProgramPrivate(const QGLContext *ctx) - : context(ctx) + QGLShaderProgramPrivate(const QGLContext *context) + : ctx(context ? QGLContextPrivate::qt_get_context_group(context) : 0) , program(0) , linked(false) , inited(false) @@ -706,13 +759,9 @@ public: , fragmentShader(0) { } - ~QGLShaderProgramPrivate() - { - if (program) - glDeleteProgram(program); - } + ~QGLShaderProgramPrivate(); - const QGLContext *context; + QGLContextGroupResources *ctx; GLuint program; bool linked; bool inited; @@ -725,8 +774,18 @@ public: QGLShader *fragmentShader; }; -#undef ctx -#define ctx d->context +QGLShaderProgramPrivate::~QGLShaderProgramPrivate() +{ + if (program) { +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) + qWarning("QGLShaderProgram: Shader program is not associated with current context."); + else +#endif + glDeleteProgram(program); + } +} + /*! Constructs a new shader program and attaches it to \a parent. @@ -769,11 +828,19 @@ bool QGLShaderProgram::init() if (d->program || d->inited) return true; d->inited = true; - if (!d->context) - d->context = QGLContext::currentContext(); - if (!d->context) + const QGLContext *context = QGLContext::currentContext(); + if (!context) + return false; + if (!d->ctx) + d->ctx = QGLContextPrivate::qt_get_context_group(context); +#ifndef QT_NO_DEBUG + else if (!qt_check_sharing_with_current_context(d->ctx)) { + qWarning("QGLShaderProgram: Shader program is not associated with current context."); return false; - if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(d->context))) { + } +#endif + if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(context))) { + QGLContextGroupResources *ctx = d->ctx; d->program = glCreateProgram(); if (!(d->program)) { qWarning() << "QGLShaderProgram: could not create shader program"; @@ -804,11 +871,22 @@ bool QGLShaderProgram::addShader(QGLShader *shader) if (d->shaders.contains(shader)) return true; // Already added to this shader program. if (d->program && shader) { +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(d->ctx)) { + qWarning("QGLShaderProgram::addShader: Program is not associated with current context."); + return false; + } +#endif + if (shader->d->ctx != d->ctx) { + qWarning("QGLShaderProgram::addShader: Program and shader are not associated with same context."); + return false; + } if (!shader->d->compiled) return false; if (!shader->d->isPartial) { if (!shader->d->shader) return false; + QGLContextGroupResources *ctx = d->ctx; glAttachShader(d->program, shader->d->shader); } else { d->hasPartialShaders = true; @@ -920,8 +998,15 @@ bool QGLShaderProgram::addShaderFromFile */ void QGLShaderProgram::removeShader(QGLShader *shader) { - if (d->program && shader && shader->d->shader) + if (d->program && shader && shader->d->shader) { + QGLContextGroupResources *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) + qWarning("QGLShaderProgram::removeShader: Program is not associated with current context."); + else +#endif glDetachShader(d->program, shader->d->shader); + } d->linked = false; // Program needs to be relinked. if (shader) { d->shaders.removeAll(shader); @@ -952,6 +1037,12 @@ QList<QGLShader *> QGLShaderProgram::shaders() const void QGLShaderProgram::removeAllShaders() { d->removingShaders = true; + QGLContextGroupResources *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) + qWarning("QGLShaderProgram::removeAllShaders: Program is not associated with current context."); + else +#endif foreach (QGLShader *shader, d->shaders) { if (d->program && shader && shader->d->shader) glDetachShader(d->program, shader->d->shader); @@ -1102,6 +1193,14 @@ bool QGLShaderProgram::link() { if (!d->program) return false; + QGLContextGroupResources *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) { + qWarning("QGLShaderProgram::link: Program is not associated with current context."); + return false; + } +#endif + if (d->hasPartialShaders) { // Compile the partial vertex and fragment shaders. QByteArray vertexSource; @@ -1204,13 +1303,17 @@ bool QGLShaderProgram::enable() return false; if (!d->linked && !link()) return false; + QGLContextGroupResources *ctx = d->ctx; +#ifndef QT_NO_DEBUG + if (!qt_check_sharing_with_current_context(ctx)) { + qWarning("QGLShaderProgram::enable: Program is not associated with current context."); + return false; + } +#endif glUseProgram(d->program); return true; } -#undef ctx -#define ctx QGLContext::currentContext() - /*! Disables the active shader program in the current QGLContext. This is equivalent to calling \c{glUseProgram(0)}. @@ -1219,6 +1322,7 @@ bool QGLShaderProgram::enable() */ void QGLShaderProgram::disable() { + const QGLContext *ctx = QGLContext::currentContext(); #if defined(QT_OPENGL_ES_2) glUseProgram(0); #else @@ -1227,8 +1331,7 @@ void QGLShaderProgram::disable() #endif } -#undef ctx -#define ctx d->context +#define ctx d->ctx /*! Returns the OpenGL identifier associated with this shader program. @@ -2963,6 +3066,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x4 * setUniformValueArray(uniformLocation(name), values, count); } +#undef ctx + /*! Returns true if shader programs written in the OpenGL Shading Language (GLSL) are supported on this system; false otherwise. diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 11a5e97..d0b52da 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -179,22 +179,25 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa break; case 's': - if (name == QLatin1String("stroke")) - stroke = value; - else if (name == QLatin1String("stroke-dasharray")) - strokeDashArray = value; - else if (name == QLatin1String("stroke-dashoffset")) - strokeDashOffset = value; - else if (name == QLatin1String("stroke-linecap")) - strokeLineCap = value; - else if (name == QLatin1String("stroke-linejoin")) - strokeLineJoin = value; - else if (name == QLatin1String("stroke-miterlimit")) - strokeMiterLimit = value; - else if (name == QLatin1String("stroke-opacity")) - strokeOpacity = value; - else if (name == QLatin1String("stroke-width")) - strokeWidth = value; + if (name.length() > 5 && QStringRef(name.string(), name.position() + 1, 5) == QLatin1String("troke")) { + QStringRef strokeRef(name.string(), name.position() + 6, name.length() - 6); + if (name.isEmpty()) + stroke = value; + else if (name == QLatin1String("-dasharray")) + strokeDashArray = value; + else if (name == QLatin1String("-dashoffset")) + strokeDashOffset = value; + else if (name == QLatin1String("-linecap")) + strokeLineCap = value; + else if (name == QLatin1String("-linejoin")) + strokeLineJoin = value; + else if (name == QLatin1String("-miterlimit")) + strokeMiterLimit = value; + else if (name == QLatin1String("-opacity")) + strokeOpacity = value; + else if (name == QLatin1String("-width")) + strokeWidth = value; + } else if (name == QLatin1String("stop-color")) stopColor = value; else if (name == QLatin1String("stop-opacity")) @@ -271,22 +274,25 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa break; case 's': - if (name == QLatin1String("stroke")) - stroke = value; - else if (name == QLatin1String("stroke-dasharray")) - strokeDashArray = value; - else if (name == QLatin1String("stroke-dashoffset")) - strokeDashOffset = value; - else if (name == QLatin1String("stroke-linecap")) - strokeLineCap = value; - else if (name == QLatin1String("stroke-linejoin")) - strokeLineJoin = value; - else if (name == QLatin1String("stroke-miterlimit")) - strokeMiterLimit = value; - else if (name == QLatin1String("stroke-opacity")) - strokeOpacity = value; - else if (name == QLatin1String("stroke-width")) - strokeWidth = value; + if (name.length() > 5 && QStringRef(name.string(), name.position() + 1, 5) == QLatin1String("troke")) { + QStringRef strokeRef(name.string(), name.position() + 6, name.length() - 6); + if (name.isEmpty()) + stroke = value; + else if (name == QLatin1String("-dasharray")) + strokeDashArray = value; + else if (name == QLatin1String("-dashoffset")) + strokeDashOffset = value; + else if (name == QLatin1String("-linecap")) + strokeLineCap = value; + else if (name == QLatin1String("-linejoin")) + strokeLineJoin = value; + else if (name == QLatin1String("-miterlimit")) + strokeMiterLimit = value; + else if (name == QLatin1String("-opacity")) + strokeOpacity = value; + else if (name == QLatin1String("-width")) + strokeWidth = value; + } else if (name == QLatin1String("stop-color")) stopColor = value; else if (name == QLatin1String("stop-opacity")) @@ -1101,95 +1107,88 @@ static void parseFont(QSvgNode *node, const QSvgAttributes &attributes, QSvgHandler *handler) { - QString family = attributes.fontFamily.toString(); - QString size = attributes.fontSize.toString(); - QString style = attributes.fontStyle.toString(); - QString weight = attributes.fontWeight.toString(); - QString variant = attributes.fontVariant.toString(); - QString anchor = attributes.textAnchor.toString(); - - if (family.isEmpty() && size.isEmpty() && style.isEmpty() && weight.isEmpty() && variant.isEmpty() && anchor.isEmpty()) + if (attributes.fontFamily.isEmpty() && attributes.fontSize.isEmpty() && attributes.fontStyle.isEmpty() && + attributes.fontWeight.isEmpty() && attributes.fontVariant.isEmpty() && attributes.textAnchor.isEmpty()) return; - QString id = someId(attributes); QSvgTinyDocument *doc = node->document(); QSvgFontStyle *fontStyle = 0; - if (!family.isEmpty()) { - QSvgFont *svgFont = doc->svgFont(family); + if (!attributes.fontFamily.isEmpty()) { + QSvgFont *svgFont = doc->svgFont(attributes.fontFamily.toString()); if (svgFont) fontStyle = new QSvgFontStyle(svgFont, doc); } if (!fontStyle) fontStyle = new QSvgFontStyle; - if (!family.isEmpty() && family != QT_INHERIT) - fontStyle->setFamily(family.trimmed()); + if (!attributes.fontFamily.isEmpty() && attributes.fontFamily != QT_INHERIT) + fontStyle->setFamily(attributes.fontFamily.toString().trimmed()); - if (!size.isEmpty() && size != QT_INHERIT) { + if (!attributes.fontSize.isEmpty() && attributes.fontSize != QT_INHERIT) { QSvgHandler::LengthType dummy; // should always be pixel size - fontStyle->setSize(parseLength(size, dummy, handler)); + fontStyle->setSize(parseLength(attributes.fontSize.toString(), dummy, handler)); } - if (!style.isEmpty() && style != QT_INHERIT) { - if (style == QLatin1String("normal")) { + if (!attributes.fontStyle.isEmpty() && attributes.fontStyle != QT_INHERIT) { + if (attributes.fontStyle == QLatin1String("normal")) { fontStyle->setStyle(QFont::StyleNormal); - } else if (style == QLatin1String("italic")) { + } else if (attributes.fontStyle == QLatin1String("italic")) { fontStyle->setStyle(QFont::StyleItalic); - } else if (style == QLatin1String("oblique")) { + } else if (attributes.fontStyle == QLatin1String("oblique")) { fontStyle->setStyle(QFont::StyleOblique); } } - if (!weight.isEmpty() && weight != QT_INHERIT) { + if (!attributes.fontWeight.isEmpty() && attributes.fontWeight != QT_INHERIT) { bool ok = false; - int weightNum = weight.toInt(&ok); + int weightNum = attributes.fontWeight.toString().toInt(&ok); if (ok) { fontStyle->setWeight(weightNum); } else { - if (weight == QLatin1String("normal")) { + if (attributes.fontWeight == QLatin1String("normal")) { fontStyle->setWeight(400); - } else if (weight == QLatin1String("bold")) { + } else if (attributes.fontWeight == QLatin1String("bold")) { fontStyle->setWeight(700); - } else if (weight == QLatin1String("bolder")) { + } else if (attributes.fontWeight == QLatin1String("bolder")) { fontStyle->setWeight(QSvgFontStyle::BOLDER); - } else if (weight == QLatin1String("lighter")) { + } else if (attributes.fontWeight == QLatin1String("lighter")) { fontStyle->setWeight(QSvgFontStyle::LIGHTER); } } } - if (!variant.isEmpty() && variant != QT_INHERIT) { - if (variant == QLatin1String("normal")) + if (!attributes.fontVariant.isEmpty() && attributes.fontVariant != QT_INHERIT) { + if (attributes.fontVariant == QLatin1String("normal")) fontStyle->setVariant(QFont::MixedCase); - else if (variant == QLatin1String("small-caps")) + else if (attributes.fontVariant == QLatin1String("small-caps")) fontStyle->setVariant(QFont::SmallCaps); } - if (!anchor.isEmpty() && anchor != QT_INHERIT) { - if (anchor == QLatin1String("start")) + if (!attributes.textAnchor.isEmpty() && attributes.textAnchor != QT_INHERIT) { + if (attributes.textAnchor == QLatin1String("start")) fontStyle->setTextAnchor(Qt::AlignLeft); - if (anchor == QLatin1String("middle")) + if (attributes.textAnchor == QLatin1String("middle")) fontStyle->setTextAnchor(Qt::AlignHCenter); - else if (anchor == QLatin1String("end")) + else if (attributes.textAnchor == QLatin1String("end")) fontStyle->setTextAnchor(Qt::AlignRight); } - node->appendStyleProperty(fontStyle, id); + node->appendStyleProperty(fontStyle, someId(attributes)); } static void parseTransform(QSvgNode *node, const QSvgAttributes &attributes, QSvgHandler *) { - QString value = attributes.transform.toString(); - QString myId = someId(attributes); - value = value.trimmed(); + if (attributes.transform.isEmpty()) + return; + QString value = attributes.transform.toString().trimmed(); if (value.isEmpty()) return; QMatrix matrix = parseTransformationMatrix(value); if (!matrix.isIdentity()) { - node->appendStyleProperty(new QSvgTransformStyle(QTransform(matrix)), myId); + node->appendStyleProperty(new QSvgTransformStyle(QTransform(matrix)), someId(attributes)); } } @@ -1198,12 +1197,11 @@ static void parseVisibility(QSvgNode *node, const QSvgAttributes &attributes, QSvgHandler *) { - QString value = attributes.visibility.toString(); QSvgNode *parent = node->parent(); - if (parent && (value.isEmpty() || value == QT_INHERIT)) + if (parent && (attributes.visibility.isEmpty() || attributes.visibility == QT_INHERIT)) node->setVisible(parent->isVisible()); - else if (value == QLatin1String("hidden") || value == QLatin1String("collapse")) { + else if (attributes.visibility == QLatin1String("hidden") || attributes.visibility == QLatin1String("collapse")) { node->setVisible(false); } else node->setVisible(true); @@ -1851,6 +1849,9 @@ static void parseOpacity(QSvgNode *node, const QSvgAttributes &attributes, QSvgHandler *) { + if (attributes.opacity.isEmpty()) + return; + const QString value = attributes.opacity.toString().trimmed(); bool ok = false; @@ -1924,8 +1925,9 @@ static void parseCompOp(QSvgNode *node, const QSvgAttributes &attributes, QSvgHandler *) { - QString value = attributes.compOp.toString(); - value = value.trimmed(); + if (attributes.compOp.isEmpty()) + return; + QString value = attributes.compOp.toString().trimmed(); if (!value.isEmpty()) { QSvgCompOpStyle *compop = new QSvgCompOpStyle(svgToQtCompositionMode(value)); |