From ef682d7d0043d5054818908ffe1ba573ef6cb01b Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Sat, 15 Aug 2009 08:33:18 +1000 Subject: Fixed compile. Put QString::toReal back to QString::toDouble, there is no QString::toReal. --- src/svg/qsvghandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 5e07181..a79e4a0 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1743,7 +1743,7 @@ static void parseOpacity(QSvgNode *node, const QString value = attributes.value(QLatin1String("opacity")).toString().trimmed(); bool ok = false; - qreal op = value.toReal(&ok); + qreal op = value.toDouble(&ok); if (ok) { QSvgOpacityStyle *opacity = new QSvgOpacityStyle(qBound(qreal(0.0), op, qreal(1.0))); -- cgit v0.12 From aa09d4f9c2d47348e6eac76e66500f4807b132a3 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Sat, 15 Aug 2009 09:18:23 +1000 Subject: Fixed compile. Put EffectParameter::userType back to EffectParameter::type. --- src/3rdparty/phonon/phonon/effectwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/phonon/effectwidget.cpp b/src/3rdparty/phonon/phonon/effectwidget.cpp index 8f105f2..fb9cf6e 100644 --- a/src/3rdparty/phonon/phonon/effectwidget.cpp +++ b/src/3rdparty/phonon/phonon/effectwidget.cpp @@ -111,7 +111,7 @@ void EffectWidgetPrivate::autogenerateUi() #endif QWidget *control = 0; - switch (para.userType()) { + switch (para.type()) { case QVariant::String: { QComboBox *cb = new QComboBox(q); @@ -161,9 +161,9 @@ void EffectWidgetPrivate::autogenerateUi() case QVariant::Double: { const qreal minValue = para.minimumValue().canConvert(QVariant::Double) ? - para.minimumValue().toReal(&ok) : DEFAULT_MIN; + para.minimumValue().toReal() : DEFAULT_MIN; const qreal maxValue = para.maximumValue().canConvert(QVariant::Double) ? - para.maximumValue().toReal(&ok) : DEFAULT_MAX; + para.maximumValue().toReal() : DEFAULT_MAX; if (minValue == -1. && maxValue == 1.) { //Special case values between -1 and 1.0 to use a slider for improved usability -- cgit v0.12 From 72c1cb2ffdfb2742985e12025d4578aa2fe80ce7 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sun, 16 Aug 2009 13:00:53 +0200 Subject: Doc: Fix links and silence qdoc warnings. --- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp | 6 ++--- src/gui/image/qicon.cpp | 28 ++++++++++++----------- src/gui/text/qfontmetrics.cpp | 15 ++++++------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp index dd90f39..3ef969e 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp @@ -393,7 +393,7 @@ QString QWebElement::attribute(const QString &name, const QString &defaultValue) Returns the attribute with the given \a name in \a namespaceUri. If the attribute does not exist, \a defaultValue is returned. - \sa setAtributeNS(), setAttribute(), attribute() + \sa setAttributeNS(), setAttribute(), attribute() */ QString QWebElement::attributeNS(const QString &namespaceUri, const QString &name, const QString &defaultValue) const { @@ -976,7 +976,7 @@ QStringList QWebElement::scriptableProperties() const /*! Returns the value of the style with the given \a name. If a style with - \name does not exist, an empty string is returned. + \a name does not exist, an empty string is returned. If \a rule is IgnoreCascadingStyles, the value defined inside the element (inline in CSS terminology) is returned. @@ -1099,7 +1099,7 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value, St /*! Returns the computed value for style with the given \a name. If a style - with \name does not exist, an empty string is returned. + with \a name does not exist, an empty string is returned. */ QString QWebElement::computedStyleProperty(const QString &name) const { diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 0d854d0..677cc44 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -871,7 +871,7 @@ QList QIcon::availableSizes(Mode mode, State state) const \since 4.6 Sets the search paths for icon themes to \a paths. - \sa themeSearchPaths(), fromTheme() + \sa themeSearchPaths(), fromTheme(), setThemeName() */ void QIcon::setThemeSearchPaths(const QStringList &paths) { @@ -893,7 +893,7 @@ void QIcon::setThemeSearchPaths(const QStringList &paths) On Mac the default search path will search in the [Contents/Resources/icons] part of the application bundle. - \sa setThemeSearchPaths(), fromTheme() + \sa setThemeSearchPaths(), fromTheme(), setThemeName() */ QStringList QIcon::themeSearchPaths() { @@ -903,16 +903,17 @@ QStringList QIcon::themeSearchPaths() /*! \since 4.6 - Sets the current icon theme. + Sets the current icon theme to \a name. - The name should correspond to a directory name in the - current \ themeSearchPath() containing an index.theme - file describing it's contents.. + The \a name should correspond to a directory name in the + current themeSearchPath() containing an index.theme + file describing it's contents. + \sa themeSearchPaths(), themeName() */ -void QIcon::setThemeName(const QString &path) +void QIcon::setThemeName(const QString &name) { - QIconLoader::instance()->setThemeName(path); + QIconLoader::instance()->setThemeName(name); } /*! @@ -923,7 +924,8 @@ void QIcon::setThemeName(const QString &path) On X11, the current icon theme depends on your desktop settings. On other platforms it is not set by default. - \sa themeSearchPaths(), fromTheme(), hasThemeIcon() + \sa setThemeName(), themeSearchPaths(), fromTheme(), + hasThemeIcon() */ QString QIcon::themeName() { @@ -960,7 +962,7 @@ QString QIcon::themeName() compliant theme in one of your themeSearchPaths() and set the appropriate themeName(). - \sa themeName(), themeSearchPaths() + \sa themeName(), setThemeName(), themeSearchPaths() */ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) { @@ -994,10 +996,10 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) /*! \since 4.6 - Returns true if there is an icon available for a \a name in the current - icon theme, otherwise returns false. + Returns true if there is an icon available for \a name in the + current icon theme, otherwise returns false. - \sa themeSearchPaths(), fromTheme() + \sa themeSearchPaths(), fromTheme(), setThemeName() */ bool QIcon::hasThemeIcon(const QString &name) { diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 3e074a7..b3d1a5f 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -859,24 +859,23 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const right-to-left layouts, and on the left side for right-to-left layouts. Note that this behavior is independent of the text language. - */ -QString QFontMetrics::elidedText(const QString &_text, Qt::TextElideMode mode, int width, int flags) const +QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags) const { - QString text = _text; + QString _text = text; if (!(flags & Qt::TextLongestVariant)) { int posA = 0; - int posB = text.indexOf(QLatin1Char('\x9c')); + int posB = _text.indexOf(QLatin1Char('\x9c')); while (posB >= 0) { - QString portion = text.mid(posA, posB - posA); + QString portion = _text.mid(posA, posB - posA); if (size(flags, portion).width() <= width) return portion; posA = posB + 1; - posB = text.indexOf(QLatin1Char('\x9c'), posA); + posB = _text.indexOf(QLatin1Char('\x9c'), posA); } - text = text.mid(posA); + _text = _text.mid(posA); } - QStackTextEngine engine(text, QFont(d)); + QStackTextEngine engine(_text, QFont(d)); return engine.elidedText(mode, width, flags); } -- cgit v0.12 From caef9533a860941701745e221e719438ea6870d8 Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Mon, 17 Aug 2009 15:34:39 +1000 Subject: Snippet files for gesture overview documentation --- .../snippets/gestures/imageviewer/imagewidget.cpp | 364 +++++++++++++++++++++ .../snippets/gestures/imageviewer/imagewidget.h | 137 ++++++++ .../gestures/imageviewer/tapandholdgesture.cpp | 159 +++++++++ .../gestures/imageviewer/tapandholdgesture.h | 74 +++++ 4 files changed, 734 insertions(+) create mode 100644 doc/src/snippets/gestures/imageviewer/imagewidget.cpp create mode 100644 doc/src/snippets/gestures/imageviewer/imagewidget.h create mode 100644 doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp create mode 100644 doc/src/snippets/gestures/imageviewer/tapandholdgesture.h diff --git a/doc/src/snippets/gestures/imageviewer/imagewidget.cpp b/doc/src/snippets/gestures/imageviewer/imagewidget.cpp new file mode 100644 index 0000000..f9d6a77 --- /dev/null +++ b/doc/src/snippets/gestures/imageviewer/imagewidget.cpp @@ -0,0 +1,364 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "imagewidget.h" + +#include + +ImageWidget::ImageWidget(QWidget *parent) + : QWidget(parent) +{ + setAttribute(Qt::WA_AcceptTouchEvents); + setAttribute(Qt::WA_PaintOnScreen); + setAttribute(Qt::WA_OpaquePaintEvent); + setAttribute(Qt::WA_NoSystemBackground); + + setObjectName("ImageWidget"); + + setMinimumSize(QSize(100,100)); + + position = 0; + zoomed = rotated = false; + + zoomedIn = false; + horizontalOffset = 0; + verticalOffset = 0; + +//! [imagewidget-connect] + panGesture = new QPanGesture(this); + connect(panGesture, SIGNAL(triggered()), this, SLOT(gestureTriggered())); + + tapAndHoldGesture = new TapAndHoldGesture(this); + connect(tapAndHoldGesture, SIGNAL(triggered()), this, SLOT(gestureTriggered())); + connect(tapAndHoldGesture, SIGNAL(finished()), this, SLOT(gestureFinished())); +//! [imagewidget-connect] +} + +void ImageWidget::paintEvent(QPaintEvent*) +{ + QPainter p(this); + if (currentImage.isNull()) { + p.fillRect(geometry(), Qt::white); + return; + } + int hoffset = 0; + int voffset = 0; + const int w = pixmap.width(); + const int h = pixmap.height(); + p.save(); + if (zoomedIn) { + hoffset = horizontalOffset; + voffset = verticalOffset; + if (horizontalOffset > 0) + p.fillRect(0, 0, horizontalOffset, height(), Qt::white); + if (verticalOffset > 0) + p.fillRect(0, 0, width(), verticalOffset, Qt::white); + } + p.drawPixmap(hoffset, voffset, pixmap); + if (hoffset + w < width()) + p.fillRect(hoffset + w, 0, width() - w - hoffset, height(), Qt::white); + if (voffset + h < height()) + p.fillRect(0, voffset + h, width(), height() - h - voffset, Qt::white); + + // paint touch feedback + if (touchFeedback.tapped || touchFeedback.doubleTapped) { + p.setPen(QPen(Qt::gray, 2)); + p.drawEllipse(touchFeedback.position, 5, 5); + if (touchFeedback.doubleTapped) { + p.setPen(QPen(Qt::darkGray, 2, Qt::DotLine)); + p.drawEllipse(touchFeedback.position, 15, 15); + } else if (touchFeedback.tapAndHoldState != 0) { + QPoint pts[8] = { + touchFeedback.position + QPoint( 0, -15), + touchFeedback.position + QPoint( 10, -10), + touchFeedback.position + QPoint( 15, 0), + touchFeedback.position + QPoint( 10, 10), + touchFeedback.position + QPoint( 0, 15), + touchFeedback.position + QPoint(-10, 10), + touchFeedback.position + QPoint(-15, 0) + }; + for (int i = 0; i < touchFeedback.tapAndHoldState/5; ++i) + p.drawEllipse(pts[i], 3, 3); + } + } else if (touchFeedback.sliding) { + p.setPen(QPen(Qt::red, 3)); + QPoint endPos = QPoint(touchFeedback.position.x(), touchFeedback.slidingStartPosition.y()); + p.drawLine(touchFeedback.slidingStartPosition, endPos); + int dx = 10; + if (touchFeedback.slidingStartPosition.x() < endPos.x()) + dx = -1*dx; + p.drawLine(endPos, endPos + QPoint(dx, 5)); + p.drawLine(endPos, endPos + QPoint(dx, -5)); + } + + for (int i = 0; i < TouchFeedback::MaximumNumberOfTouches; ++i) { + if (touchFeedback.touches[i].isNull()) + break; + p.drawEllipse(touchFeedback.touches[i], 10, 10); + } + p.restore(); +} + +void ImageWidget::mousePressEvent(QMouseEvent *event) +{ + touchFeedback.tapped = true; + touchFeedback.position = event->pos(); +} + +void ImageWidget::mouseDoubleClickEvent(QMouseEvent *event) +{ + touchFeedback.doubleTapped = true; + const QPoint p = event->pos(); + touchFeedback.position = p; + horizontalOffset = p.x() - currentImage.width()*1.0*p.x()/width(); + verticalOffset = p.y() - currentImage.height()*1.0*p.y()/height(); + setZoomedIn(!zoomedIn); + zoomed = rotated = false; + updateImage(); + + feedbackFadeOutTimer.start(500, this); +} + +//! [imagewidget-triggered-1] +void ImageWidget::gestureTriggered() +{ + if (sender() == panGesture) { +//! [imagewidget-triggered-1] + touchFeedback.tapped = false; + touchFeedback.doubleTapped = false; + QPanGesture *pg = qobject_cast(sender()); + if (zoomedIn) { +#ifndef QT_NO_CURSOR + switch (pg->state()) { + case Qt::GestureStarted: + case Qt::GestureUpdated: + setCursor(Qt::SizeAllCursor); + break; + default: + setCursor(Qt::ArrowCursor); + } +#endif + horizontalOffset += pg->lastOffset().width(); + verticalOffset += pg->lastOffset().height(); + } else { + // only slide gesture should be accepted + if (pg->state() == Qt::GestureFinished) { + touchFeedback.sliding = false; + zoomed = rotated = false; + if (pg->totalOffset().width() > 0) + goNextImage(); + else + goPrevImage(); + updateImage(); + } + } + update(); + feedbackFadeOutTimer.start(500, this); + } else if (sender() == tapAndHoldGesture) { + if (tapAndHoldGesture->state() == Qt::GestureFinished) { + qDebug() << "tap and hold detected"; + touchFeedback.reset(); + update(); + + QMenu menu; + menu.addAction("Action 1"); + menu.addAction("Action 2"); + menu.addAction("Action 3"); + menu.exec(mapToGlobal(tapAndHoldGesture->pos())); + } else { + ++touchFeedback.tapAndHoldState; + update(); + } + feedbackFadeOutTimer.start(500, this); + } +} + +void ImageWidget::gestureFinished() +{ + qDebug() << "gesture finished" << sender(); +} + +void ImageWidget::gestureCancelled() +{ + qDebug() << "gesture cancelled" << sender(); +} + +void ImageWidget::resizeEvent(QResizeEvent*) +{ + updateImage(); +} + +void ImageWidget::updateImage() +{ + // should use qtconcurrent here? + transformation = QTransform(); + if (zoomedIn) { + } else { + if (currentImage.isNull()) + return; + if (zoomed) { + transformation = transformation.scale(zoom, zoom); + } else { + double xscale = (double)width()/currentImage.width(); + double yscale = (double)height()/currentImage.height(); + if (xscale < yscale) + yscale = xscale; + else + xscale = yscale; + transformation = transformation.scale(xscale, yscale); + } + if (rotated) + transformation = transformation.rotate(angle); + } + pixmap = QPixmap::fromImage(currentImage).transformed(transformation); + update(); +} + +void ImageWidget::openDirectory(const QString &path) +{ + this->path = path; + QDir dir(path); + QStringList nameFilters; + nameFilters << "*.jpg" << "*.png"; + files = dir.entryList(nameFilters, QDir::Files|QDir::Readable, QDir::Name); + + position = 0; + goToImage(0); + updateImage(); +} + +QImage ImageWidget::loadImage(const QString &fileName) +{ + QImageReader reader(fileName); + if (!reader.canRead()) { + qDebug() << fileName << ": can't load image"; + return QImage(); + } + QImage image; + if (!reader.read(&image)) { + qDebug() << fileName << ": corrupted image"; + return QImage(); + } + return image; +} + +void ImageWidget::setZoomedIn(bool zoomed) +{ + zoomedIn = zoomed; +} + +void ImageWidget::goNextImage() +{ + if (files.isEmpty()) + return; + if (position < files.size()-1) { + ++position; + prevImage = currentImage; + currentImage = nextImage; + if (position+1 < files.size()) + nextImage = loadImage(path+QLatin1String("/")+files.at(position+1)); + else + nextImage = QImage(); + } + setZoomedIn(false); + updateImage(); +} + +void ImageWidget::goPrevImage() +{ + if (files.isEmpty()) + return; + if (position > 0) { + --position; + nextImage = currentImage; + currentImage = prevImage; + if (position > 0) + prevImage = loadImage(path+QLatin1String("/")+files.at(position-1)); + else + prevImage = QImage(); + } + setZoomedIn(false); + updateImage(); +} + +void ImageWidget::goToImage(int index) +{ + if (files.isEmpty()) + return; + if (index < 0 || index >= files.size()) { + qDebug() << "goToImage: invalid index: " << index; + return; + } + if (index == position+1) { + goNextImage(); + return; + } + if (position > 0 && index == position-1) { + goPrevImage(); + return; + } + position = index; + pixmap = QPixmap(); + if (index > 0) + prevImage = loadImage(path+QLatin1String("/")+files.at(position-1)); + else + prevImage = QImage(); + currentImage = loadImage(path+QLatin1String("/")+files.at(position)); + if (position+1 < files.size()) + nextImage = loadImage(path+QLatin1String("/")+files.at(position+1)); + else + nextImage = QImage(); + setZoomedIn(false); + updateImage(); +} + +void ImageWidget::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == touchFeedback.tapTimer.timerId()) { + touchFeedback.tapTimer.stop(); + } else if (event->timerId() == feedbackFadeOutTimer.timerId()) { + feedbackFadeOutTimer.stop(); + touchFeedback.reset(); + } + update(); +} + +#include "moc_imagewidget.cpp" diff --git a/doc/src/snippets/gestures/imageviewer/imagewidget.h b/doc/src/snippets/gestures/imageviewer/imagewidget.h new file mode 100644 index 0000000..fcad5b9 --- /dev/null +++ b/doc/src/snippets/gestures/imageviewer/imagewidget.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef IMAGEWIDGET_H +#define IMAGEWIDGET_H + +#include +#include +#include + +#include + +#include "tapandholdgesture.h" + +class ImageWidget : public QWidget +{ + Q_OBJECT + +public: + ImageWidget(QWidget *parent = 0); + + void openDirectory(const QString &path); + +protected: + void paintEvent(QPaintEvent*); + void resizeEvent(QResizeEvent*); + void timerEvent(QTimerEvent*); + void mousePressEvent(QMouseEvent*); + void mouseDoubleClickEvent(QMouseEvent*); + +//! [imagewidget-slots] +private slots: + void gestureTriggered(); + void gestureFinished(); + void gestureCancelled(); +//! [imagewidget-slots] + +private: + void updateImage(); + QImage loadImage(const QString &fileName); + void loadImage(); + void setZoomedIn(bool zoomed); + void goNextImage(); + void goPrevImage(); + void goToImage(int index); + + QPanGesture *panGesture; + TapAndHoldGesture *tapAndHoldGesture; + + QString path; + QStringList files; + int position; + + QImage prevImage, nextImage; + QImage currentImage; + QPixmap pixmap; + QTransform transformation; + + bool zoomedIn; + int horizontalOffset; + int verticalOffset; + + bool zoomed; + qreal zoom; + bool rotated; + qreal angle; + + struct TouchFeedback + { + bool tapped; + QPoint position; + bool sliding; + QPoint slidingStartPosition; + QBasicTimer tapTimer; + int tapState; + bool doubleTapped; + int tapAndHoldState; + + enum { MaximumNumberOfTouches = 5 }; + QPoint touches[MaximumNumberOfTouches]; + + inline TouchFeedback() { reset(); } + inline void reset() + { + tapped = false; + sliding = false; + tapTimer.stop(); + tapState = 0; + doubleTapped = false; + tapAndHoldState = 0; + for (int i = 0; i < MaximumNumberOfTouches; ++i) { + touches[i] = QPoint(); + } + } + } touchFeedback; + QBasicTimer feedbackFadeOutTimer; +}; + +#endif diff --git a/doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp b/doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp new file mode 100644 index 0000000..03898dc --- /dev/null +++ b/doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tapandholdgesture.h" + +#include + +// #define TAPANDHOLD_USING_MOUSE + +/*! + \class TapAndHoldGesture + \since 4.6 + + \brief The TapAndHoldGesture class represents a Tap-and-Hold gesture, + providing additional information. +*/ + +const int TapAndHoldGesture::iterationCount = 40; +const int TapAndHoldGesture::iterationTimeout = 50; + +/*! + Creates a new Tap and Hold gesture handler object and marks it as a child + of \a parent. + + On some platforms like Windows there is a system-wide tap and hold gesture + that cannot be overriden, hence the gesture might never trigger and default + context menu will be shown instead. +*/ +TapAndHoldGesture::TapAndHoldGesture(QWidget *parent) + : QGesture(parent), iteration(0) +{ +} + +/*! \internal */ +bool TapAndHoldGesture::filterEvent(QEvent *event) +{ + if (!event->spontaneous()) + return false; + const QTouchEvent *ev = static_cast(event); + switch (event->type()) { + case QEvent::TouchBegin: { + if (timer.isActive()) + timer.stop(); + timer.start(TapAndHoldGesture::iterationTimeout, this); + const QPoint p = ev->touchPoints().at(0).pos().toPoint(); + position = p; + break; + } + case QEvent::TouchUpdate: + if (ev->touchPoints().size() == 1) { + const QPoint startPos = ev->touchPoints().at(0).startPos().toPoint(); + const QPoint pos = ev->touchPoints().at(0).pos().toPoint(); + if ((startPos - pos).manhattanLength() > 15) + reset(); + } else { + reset(); + } + break; + case QEvent::TouchEnd: + reset(); + break; +#ifdef TAPANDHOLD_USING_MOUSE + case QEvent::MouseButtonPress: { + if (timer.isActive()) + timer.stop(); + timer.start(TapAndHoldGesture::iterationTimeout, this); + const QPoint p = static_cast(event)->pos(); + position = startPosition = p; + break; + } + case QEvent::MouseMove: { + const QPoint startPos = startPosition; + const QPoint pos = static_cast(event)->pos(); + if ((startPos - pos).manhattanLength() > 15) + reset(); + break; + } + case QEvent::MouseButtonRelease: + reset(); + break; +#endif // TAPANDHOLD_USING_MOUSE + default: + break; + } + return false; +} + +/*! \internal */ +void TapAndHoldGesture::timerEvent(QTimerEvent *event) +{ + if (event->timerId() != timer.timerId()) + return; + if (iteration == TapAndHoldGesture::iterationCount) { + timer.stop(); + updateState(Qt::GestureFinished); + } else { + updateState(Qt::GestureUpdated); + } + ++iteration; +} + +/*! \internal */ +//! [tapandhold-reset] +void TapAndHoldGesture::reset() +{ + timer.stop(); + iteration = 0; + position = startPosition = QPoint(); + updateState(Qt::NoGesture); +} +//! [tapandhold-reset] + +/*! + \property TapAndHoldGesture::pos + + \brief The position of the gesture. +*/ +QPoint TapAndHoldGesture::pos() const +{ + return position; +} diff --git a/doc/src/snippets/gestures/imageviewer/tapandholdgesture.h b/doc/src/snippets/gestures/imageviewer/tapandholdgesture.h new file mode 100644 index 0000000..bf0f867 --- /dev/null +++ b/doc/src/snippets/gestures/imageviewer/tapandholdgesture.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TAPANDHOLDGESTURE_H +#define TAPANDHOLDGESTURE_H + +#include +#include +#include + +class TapAndHoldGesture : public QGesture +{ + Q_OBJECT + Q_PROPERTY(QPoint pos READ pos) + +public: + TapAndHoldGesture(QWidget *parent); + + bool filterEvent(QEvent *event); + void reset(); + + QPoint pos() const; + +protected: + void timerEvent(QTimerEvent *event); + +private: + QBasicTimer timer; + int iteration; + QPoint position; + QPoint startPosition; + static const int iterationCount; + static const int iterationTimeout; +}; + +#endif // TAPANDHOLDGESTURE_H -- cgit v0.12 From c09c9704a934000425a1f4a0db0c59f09eaee041 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 17 Aug 2009 09:45:01 +0200 Subject: Doc: Mention that destroying an item that belongs to a QGraphicsScene is inneficient As the virtual functions (such as the boundingRect()) are not available anymore in the destructor, the view has to refresh everything. Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 74b8fe2..f454d7c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1183,6 +1183,9 @@ QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent, Destroys the QGraphicsItem and all its children. If this item is currently associated with a scene, the item will be removed from the scene before it is deleted. + + \note It is more efficient to remove the item from the QGraphicsScene before + destroying the item. */ QGraphicsItem::~QGraphicsItem() { -- cgit v0.12 From 58e5dbb977bf7f52c2a374e589de2faaa336dbb9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 13:49:22 +0200 Subject: qpdf: fix memory leak detected by coverity --- src/gui/painting/qpdf.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 9b3b289..6a7889a 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1773,6 +1773,9 @@ bool QPdfBaseEnginePrivate::openPrintDevice() (void)execv("/bin/lpr", lprargs); (void)execv("/usr/bin/lp", lpargs); (void)execv("/usr/bin/lpr", lprargs); + + delete []lpargs; + delete []lprargs; } // if we couldn't exec anything, close the fd, // wait for a second so the parent process (the -- cgit v0.12 From 8096d2bbbb1f4becaaefe2219560f8dd558235de Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 17 Aug 2009 12:26:00 +0200 Subject: doc: Eliminated two qdoc error reports. --- src/corelib/tools/qshareddata.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp index dd98499..9f49898 100644 --- a/src/corelib/tools/qshareddata.cpp +++ b/src/corelib/tools/qshareddata.cpp @@ -285,6 +285,11 @@ QT_BEGIN_NAMESPACE \sa data() */ +/*! \fn void QSharedDataPointer::swap(QSharedDataPointer &other) + Swap this instance's shared data pointer with the shared + data pointer in \a other. + */ + /*! \fn bool QSharedDataPointer::operator==(const QSharedDataPointer& other) const Returns true if \a other and \e this have the same \e{d pointer}. This function does \e not call detach(). @@ -436,6 +441,11 @@ QT_BEGIN_NAMESPACE \sa data() */ +/*! \fn void QExplicitlySharedDataPointer::swap(QExplicitlySharedDataPointer &other) + Swap this instance's explicitly shared data pointer with + the explicitly shared data pointer in \a other. + */ + /*! \fn bool QExplicitlySharedDataPointer::operator==(const QExplicitlySharedDataPointer& other) const Returns true if \a other and \e this have the same \e{d pointer}. */ -- cgit v0.12 From 5bc8c27e9406fd55693e3a3963030c6d9a89b08a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 20 Oct 2008 09:59:51 +0200 Subject: Add LIBS_PRIVATE to qmake. The difference between LIBS and LIBS_PRIVATE is that private libraries are those that are not part of the public interface of a library. For example, if you're writing a Qt application and link to QtGui, you definitely need the development files for QtCore, but not necessarily for Glib and GThread, or maybe even X11. The private libraries are necessary only in static builds, so the information should still be published in .prl and pkg-config files. Reviewed-By: Marius Storm-Olsen --- qmake/generators/makefile.cpp | 2 ++ qmake/generators/unix/unixmake.cpp | 3 ++- qmake/generators/unix/unixmake2.cpp | 18 ++++++++++-------- qmake/generators/win32/mingw_make.cpp | 11 +++++++++-- qmake/generators/win32/mingw_make.h | 1 + qmake/generators/win32/msvc_nmake.cpp | 1 + qmake/generators/win32/winmakefile.cpp | 2 +- qmake/generators/win32/winmakefile.h | 2 +- 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 9580101..bf0e6df 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -967,6 +967,8 @@ MakefileGenerator::writePrlFile(QTextStream &t) libs = project->values("QMAKE_INTERNAL_PRL_LIBS"); else libs << "QMAKE_LIBS"; //obvious one + if(project->isActiveConfig("staticlib")) + libs << "QMAKE_LIBS_PRIVATE"; t << "QMAKE_PRL_LIBS = "; for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) t << project->values((*it)).join(" ") << " "; diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 36470f2..626b955a5 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -127,6 +127,7 @@ UnixMakefileGenerator::init() project->values("QMAKE_ORIG_TARGET") = project->values("TARGET"); project->values("QMAKE_ORIG_DESTDIR") = project->values("DESTDIR"); project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); if((!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib")) || (project->isActiveConfig("qt") && project->isActiveConfig("plugin"))) { if(configs.indexOf("dll") == -1) configs.append("dll"); @@ -441,7 +442,7 @@ UnixMakefileGenerator::findLibraries() QList libdirs, frameworkdirs; frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks")); frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks")); - const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", QString() }; + const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", QString() }; for(int i = 0; !lflags[i].isNull(); i++) { QStringList &l = project->values(lflags[i]); for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index b8252b8..07c7d38 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -149,7 +149,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "LINK = " << var("QMAKE_LINK") << endl; t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_FRAMEWORKDIR_FLAGS") << " " - << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl; + << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << " " << var("QMAKE_LIBS_PRIVATE") << endl; } t << "AR = " << var("QMAKE_AR") << endl; @@ -1424,13 +1424,6 @@ UnixMakefileGenerator::writePkgConfigFile() t << "Version: " << project->first("VERSION") << endl; // libs - QStringList libs; - if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) { - libs = project->values("QMAKE_INTERNAL_PRL_LIBS"); - } else { - libs << "QMAKE_LIBS"; //obvious one - } - libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread? t << "Libs: "; QString pkgConfiglibDir; QString pkgConfiglibName; @@ -1450,6 +1443,15 @@ UnixMakefileGenerator::writePkgConfigFile() pkgConfiglibName = "-l" + lname.left(lname.length()-Option::libtool_ext.length()); } t << pkgConfiglibDir << " " << pkgConfiglibName << " " << endl; + + QStringList libs; + if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) { + libs = project->values("QMAKE_INTERNAL_PRL_LIBS"); + } else { + libs << "QMAKE_LIBS"; //obvious one + } + libs << "QMAKE_LIBS_PRIVATE"; + libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread? t << "Libs.private: "; for(QStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it) { t << project->values((*it)).join(" ") << " "; diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 84104fd..fb0f48d 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -82,7 +82,12 @@ QString MingwMakefileGenerator::getLibTarget() bool MingwMakefileGenerator::findLibraries() { - QStringList &l = project->values("QMAKE_LIBS"); + return findLibraries("QMAKE_LIBS") && findLibraries("QMAKE_LIBS_PRIVATE"); +} + +bool MingwMakefileGenerator::findLibraries(const QString &where) +{ + QStringList &l = project->values(where); QList dirs; { @@ -258,6 +263,7 @@ void MingwMakefileGenerator::init() // LIBS defined in Profile comes first for gcc project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); QString targetfilename = project->values("TARGET").first(); QStringList &configs = project->values("CONFIG"); @@ -344,7 +350,8 @@ void MingwMakefileGenerator::writeLibsPart(QTextStream &t) t << "LIBS = "; if(!project->values("QMAKE_LIBDIR").isEmpty()) writeLibDirPart(t); - t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl; + t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << ' ' + << var("QMAKE_LIBS_PRIVATE").replace(QRegExp("(\\slib|^lib)")," -l") << endl; } } diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h index c95beff..8640bbc 100644 --- a/qmake/generators/win32/mingw_make.h +++ b/qmake/generators/win32/mingw_make.h @@ -72,6 +72,7 @@ private: QString preCompHeaderOut; virtual bool findLibraries(); + bool findLibraries(const QString &where); void fixTargetExt(); bool init_flag; diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 7613ef2..3a0ca6f 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -172,6 +172,7 @@ void NmakeMakefileGenerator::init() } project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); processVars(); if (!project->values("RES_FILE").isEmpty()) { diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index e3923c6..3a4329c 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -708,7 +708,7 @@ void Win32MakefileGenerator::writeLibsPart(QTextStream &t) if(!project->values("QMAKE_LIBDIR").isEmpty()) writeLibDirPart(t); t << var("QMAKE_LFLAGS") << endl; - t << "LIBS = " << var("QMAKE_LIBS") << endl; + t << "LIBS = " << var("QMAKE_LIBS") << " " << var("QMAKE_LIBS_PRIVATE") << endl; } } diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h index e2b6608..7032251 100644 --- a/qmake/generators/win32/winmakefile.h +++ b/qmake/generators/win32/winmakefile.h @@ -89,7 +89,7 @@ inline Win32MakefileGenerator::~Win32MakefileGenerator() { } inline bool Win32MakefileGenerator::findLibraries() -{ return findLibraries("QMAKE_LIBS"); } +{ return findLibraries("QMAKE_LIBS") && findLibraries("QMAKE_LIBS_PRIVATE"); } QT_END_NAMESPACE -- cgit v0.12 From 83940f25dba51a9942ab55ed8475fc7fc8a8da84 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 17 Aug 2009 10:43:48 +0200 Subject: Use LIBS_PRIVATE on Mac and X11. On the Mac, it means "-framework ApplicationServices -framework Carbon -framework AppKit" are no longer part of the default LIBS in Qt applications. This required a lot of fixes where we used Mac-specific code in Qt. On X11, it was very straightforward, because we apparently use very little of X11 outside QtGui. I haven't changed the Windows-specific LIBS paths, because I don't know how Windows behaves. Windows has DLLs, but it links to static "import" libraries. So is it static linking or dynamic linking? Reviewed-By: Marius Storm-Olsen --- config.tests/unix/clock-gettime/clock-gettime.pri | 2 +- demos/macmainwindow/macmainwindow.pro | 2 +- mkspecs/features/unix/dylib.prf | 2 +- mkspecs/features/unix/opengl.prf | 2 +- mkspecs/features/unix/x11lib.prf | 2 +- mkspecs/features/unix/x11sm.prf | 2 +- src/3rdparty/webkit/WebCore/WebCore.pro | 1 + src/corelib/codecs/codecs.pri | 2 +- src/corelib/corelib.pro | 2 +- src/corelib/kernel/kernel.pri | 2 +- src/corelib/plugin/plugin.pri | 2 ++ src/corelib/tools/tools.pri | 5 +++-- src/dbus/dbus.pro | 10 +++++----- src/gui/egl/egl.pri | 2 +- src/gui/embedded/embedded.pri | 2 +- src/gui/image/image.pri | 2 +- src/gui/kernel/kernel.pri | 4 ++-- src/gui/kernel/mac.pri | 2 +- src/gui/kernel/x11.pri | 2 +- src/gui/painting/painting.pri | 7 ++++++- src/gui/styles/styles.pri | 2 +- src/gui/text/text.pri | 2 +- src/multimedia/audio/audio.pri | 4 ++-- src/network/access/access.pri | 2 +- src/network/kernel/kernel.pri | 2 +- src/network/ssl/ssl.pri | 2 +- src/opengl/opengl.pro | 14 ++++++++++++-- src/openvg/openvg.pro | 12 ++++++------ src/plugins/phonon/qt7/qt7.pro | 2 +- src/qt3support/network/network.pri | 2 +- src/qt3support/qt3support.pro | 2 +- src/svg/svg.pro | 2 +- src/testlib/testlib.pro | 7 +++---- tools/assistant/lib/lib.pro | 8 +++----- 34 files changed, 68 insertions(+), 52 deletions(-) diff --git a/config.tests/unix/clock-gettime/clock-gettime.pri b/config.tests/unix/clock-gettime/clock-gettime.pri index 2a6160b..65b49fb 100644 --- a/config.tests/unix/clock-gettime/clock-gettime.pri +++ b/config.tests/unix/clock-gettime/clock-gettime.pri @@ -1,2 +1,2 @@ # clock_gettime() is implemented in librt on these systems -linux-*|hpux-*|solaris-*:LIBS *= -lrt +linux-*|hpux-*|solaris-*:LIBS_PRIVATE *= -lrt diff --git a/demos/macmainwindow/macmainwindow.pro b/demos/macmainwindow/macmainwindow.pro index f5165a7..ba6ffbb 100644 --- a/demos/macmainwindow/macmainwindow.pro +++ b/demos/macmainwindow/macmainwindow.pro @@ -12,7 +12,7 @@ build_all:!build_pass { CONFIG += release } -LIBS += -framework Cocoa +LIBS += -framework Cocoa -framework Carbon # install mac { diff --git a/mkspecs/features/unix/dylib.prf b/mkspecs/features/unix/dylib.prf index 1268fae..8b13789 100644 --- a/mkspecs/features/unix/dylib.prf +++ b/mkspecs/features/unix/dylib.prf @@ -1 +1 @@ -LIBS += $$QMAKE_LIBS_DYNLOAD + diff --git a/mkspecs/features/unix/opengl.prf b/mkspecs/features/unix/opengl.prf index 231d0aa..2fdf324 100644 --- a/mkspecs/features/unix/opengl.prf +++ b/mkspecs/features/unix/opengl.prf @@ -1,4 +1,4 @@ INCLUDEPATH += $$QMAKE_INCDIR_OPENGL !isEmpty(QMAKE_LIBDIR_OPENGL):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL -target_qt:LIBS += $$QMAKE_LIBS_OPENGL_QT +target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_QT else:LIBS += $$QMAKE_LIBS_OPENGL diff --git a/mkspecs/features/unix/x11lib.prf b/mkspecs/features/unix/x11lib.prf index 521518a..b661d53 100644 --- a/mkspecs/features/unix/x11lib.prf +++ b/mkspecs/features/unix/x11lib.prf @@ -1,2 +1,2 @@ !isEmpty(QMAKE_LIBDIR_X11):QMAKE_LIBDIR += $$QMAKE_LIBDIR_X11 -LIBS += $$QMAKE_LIBS_X11 +LIBS_PRIVATE += $$QMAKE_LIBS_X11 diff --git a/mkspecs/features/unix/x11sm.prf b/mkspecs/features/unix/x11sm.prf index b455b01..5176147 100644 --- a/mkspecs/features/unix/x11sm.prf +++ b/mkspecs/features/unix/x11sm.prf @@ -1,2 +1,2 @@ !isEmpty(QMAKE_LIBDIR_X11):QMAKE_LIBDIR += $$QMAKE_LIBDIR_X11 -LIBS += $$QMAKE_LIBS_X11SM +LIBS_PRIVATE += $$QMAKE_LIBS_X11SM diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 68da1d6..2fb5c32 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2165,6 +2165,7 @@ SOURCES += \ SOURCES += \ platform/text/cf/StringCF.cpp \ platform/text/cf/StringImplCF.cpp + LIBS_PRIVATE += -framework Carbon -framework AppKit } win32-* { diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri index 2e247e5..724b18d 100644 --- a/src/corelib/codecs/codecs.pri +++ b/src/corelib/codecs/codecs.pri @@ -29,7 +29,7 @@ unix { SOURCES += codecs/qiconvcodec.cpp DEFINES += GNU_LIBICONV - !mac:LIBS *= -liconv + !mac:LIBS_PRIVATE *= -liconv } else { # no iconv, so we put all plugins in the library HEADERS += \ diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index db51d43..d028772 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -18,7 +18,7 @@ include(codecs/codecs.pri) include(statemachine/statemachine.pri) include(xml/xml.pri) -mac|darwin:LIBS += -framework ApplicationServices +mac|darwin:LIBS_PRIVATE += -framework ApplicationServices mac:lib_bundle:DEFINES += QT_NO_DEBUG_PLUGIN_CHECK win32:DEFINES-=QT_NO_CAST_TO_ASCII diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 3493784..5c2f384 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -103,7 +103,7 @@ unix { HEADERS += \ kernel/qeventdispatcher_glib_p.h QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB - LIBS +=$$QT_LIBS_GLIB + LIBS_PRIVATE +=$$QT_LIBS_GLIB } SOURCES += \ kernel/qeventdispatcher_unix.cpp diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri index aaecec9..c05ff48 100644 --- a/src/corelib/plugin/plugin.pri +++ b/src/corelib/plugin/plugin.pri @@ -22,3 +22,5 @@ win32 { unix { SOURCES += plugin/qlibrary_unix.cpp } + +LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 44fbb62..1a6c1c0 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -91,7 +91,7 @@ contains(QT_CONFIG, zlib) { ../3rdparty/zlib/uncompr.c \ ../3rdparty/zlib/zutil.c } else:!contains(QT_CONFIG, no-zlib) { - unix:LIBS += -lz + unix:LIBS_PRIVATE += -lz # win32:LIBS += libz.lib } @@ -109,4 +109,5 @@ SOURCES += ../3rdparty/harfbuzz/src/harfbuzz-buffer.c \ tools/qharfbuzz.cpp HEADERS += tools/qharfbuzz_p.h -!macx-icc:!vxworks:unix:LIBS += -lm +# Note: libm should be present by default becaue this is C++ +!macx-icc:!vxworks:unix:LIBS_PRIVATE += -lm diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index 39adfe1..dcd8418 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -6,8 +6,8 @@ DEFINES += QDBUS_MAKEDLL DBUS_API_SUBJECT_TO_CHANGE QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS contains(QT_CONFIG, dbus-linked) { - LIBS += $$QT_LIBS_DBUS - DEFINES += QT_LINKED_LIBDBUS + LIBS_PRIVATE += $$QT_LIBS_DBUS + DEFINES += QT_LINKED_LIBDBUS } #INCLUDEPATH += . @@ -18,9 +18,9 @@ unix { } win32 { - LIBS += -lws2_32 -ladvapi32 -lnetapi32 -luser32 - CONFIG(debug, debug|release):LIBS += -ldbus-1d - else:LIBS += -ldbus-1 + LIBS_PRIVATE += -lws2_32 -ladvapi32 -lnetapi32 -luser32 + CONFIG(debug, debug|release):LIBS_PRIVATE += -ldbus-1d + else:LIBS_PRIVATE += -ldbus-1 } include(../qbase.pri) diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri index 651507f..75a3d91 100644 --- a/src/gui/egl/egl.pri +++ b/src/gui/egl/egl.pri @@ -25,4 +25,4 @@ for(p, QMAKE_LIBDIR_EGL) { } !isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL -!isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL +!isEmpty(QMAKE_LIBS_EGL): LIBS_PRIVATE += $$QMAKE_LIBS_EGL diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri index e8eb959..255a504 100644 --- a/src/gui/embedded/embedded.pri +++ b/src/gui/embedded/embedded.pri @@ -189,7 +189,7 @@ embedded { } contains( mouse-drivers, tslib ) { - LIBS += -lts + LIBS_PRIVATE += -lts HEADERS +=embedded/qmousetslib_qws.h SOURCES +=embedded/qmousetslib_qws.cpp } diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index baf2125..5507d25 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -89,7 +89,7 @@ SOURCES += \ SOURCES += image/qpnghandler.cpp contains(QT_CONFIG, system-png) { - unix:LIBS += -lpng + unix:LIBS_PRIVATE += -lpng win32:LIBS += libpng.lib } else { !isEqual(QT_ARCH, i386):!isEqual(QT_ARCH, x86_64):DEFINES += PNG_NO_ASSEMBLER_CODE diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index d9deefe..a94c5a3 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -124,7 +124,7 @@ unix:x11 { HEADERS += \ kernel/qguieventdispatcher_glib_p.h QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB - LIBS +=$$QT_LIBS_GLIB + LIBS_PRIVATE +=$$QT_LIBS_GLIB } SOURCES += \ kernel/qeventdispatcher_x11.cpp @@ -205,7 +205,7 @@ embedded { QMAKE_BUNDLE_DATA += MENU_NIB RESOURCES += mac/macresources.qrc - LIBS += -framework AppKit + LIBS_PRIVATE += -framework AppKit } wince*: { diff --git a/src/gui/kernel/mac.pri b/src/gui/kernel/mac.pri index 415fe0a..1538510 100644 --- a/src/gui/kernel/mac.pri +++ b/src/gui/kernel/mac.pri @@ -1,4 +1,4 @@ !x11:!embedded:mac { - LIBS += -framework Carbon -lz + LIBS_PRIVATE += -framework Carbon -lz *-mwerks:INCLUDEPATH += compat } diff --git a/src/gui/kernel/x11.pri b/src/gui/kernel/x11.pri index ac40f69..82de1b6 100644 --- a/src/gui/kernel/x11.pri +++ b/src/gui/kernel/x11.pri @@ -1,4 +1,4 @@ x11 { - contains(QT_CONFIG, nas): LIBS += -laudio -lXt + contains(QT_CONFIG, nas): LIBS_PRIVATE += -laudio -lXt } diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index d226be2..adb73aa 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -352,4 +352,9 @@ embedded { SOURCES += painting/qwindowsurface_qws.cpp } - +contains(QT_CONFIG, zlib) { + INCLUDEPATH += ../3rdparty/zlib +} else:!contains(QT_CONFIG, no-zlib) { + unix:LIBS_PRIVATE += -lz +# win32:LIBS += libz.lib +} diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index d255f80..ce1f91f 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -37,7 +37,7 @@ x11|embedded|!macx-*:styles -= mac x11{ QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE - LIBS += $$QT_LIBS_QGTKSTYLE + LIBS_PRIVATE += $$QT_LIBS_QGTKSTYLE styles += gtk } diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index fc33d43..94ed756 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -164,7 +164,7 @@ contains(QT_CONFIG, freetype) { embedded:CONFIG += opentype # pull in the proper freetype2 include directory include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri) - LIBS += -lfreetype + LIBS_PRIVATE += -lfreetype } else { DEFINES *= QT_NO_FREETYPE } diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri index 3ddb23b..c7fbbb0 100644 --- a/src/multimedia/audio/audio.pri +++ b/src/multimedia/audio/audio.pri @@ -31,7 +31,7 @@ mac { $$PWD/qaudioinput_mac_p.cpp \ $$PWD/qaudio_mac.cpp - LIBS += -framework CoreAudio -framework AudioUnit -framework AudioToolbox + LIBS += -framework ApplicationServices -framework CoreAudio -framework AudioUnit -framework AudioToolbox } else:win32 { @@ -50,7 +50,7 @@ mac { SOURCES += $$PWD/qaudiodeviceinfo_alsa_p.cpp \ $$PWD/qaudiooutput_alsa_p.cpp \ $$PWD/qaudioinput_alsa_p.cpp - LIBS += -lasound + LIBS_PRIVATE += -lasound } } } diff --git a/src/network/access/access.pri b/src/network/access/access.pri index ab7b3a7..edc1b63 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -59,6 +59,6 @@ SOURCES += access/qftp.cpp \ contains(QT_CONFIG, zlib) { INCLUDEPATH += ../3rdparty/zlib } else:!contains(QT_CONFIG, no-zlib) { - unix:LIBS += -lz + unix:LIBS_PRIVATE += -lz # win32:LIBS += libz.lib } diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index 8aa6ff4..09d2acf 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -23,7 +23,7 @@ SOURCES += kernel/qauthenticator.cpp \ unix:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp -mac:LIBS+= -framework SystemConfiguration +mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation mac:SOURCES += kernel/qnetworkproxy_mac.cpp else:win32:SOURCES += kernel/qnetworkproxy_win.cpp else:SOURCES += kernel/qnetworkproxy_generic.cpp diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri index 196e19d..44f4812 100644 --- a/src/network/ssl/ssl.pri +++ b/src/network/ssl/ssl.pri @@ -29,5 +29,5 @@ contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { RESOURCES += network.qrc # Add optional SSL libs - LIBS += $$OPENSSL_LIBS + LIBS_PRIVATE += $$OPENSSL_LIBS } diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 868484e..4231721 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -73,16 +73,26 @@ x11 { } contains(QT_CONFIG, fontconfig) { + contains(QT_CONFIG, system-freetype) { + embedded:CONFIG += opentype + # pull in the proper freetype2 include directory include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri) + LIBS_PRIVATE += -lfreetype + } else { + ### Note: how does this compile with a non-system freetype? + # This probably doesn't compile + } } else { DEFINES *= QT_NO_FREETYPE } + + LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD } mac { OBJECTIVE_SOURCES += qgl_mac.mm \ qglpixelbuffer_mac.mm - LIBS += -framework AppKit + LIBS_PRIVATE += -framework AppKit -framework Carbon } win32:!wince*: { SOURCES += qgl_win.cpp \ @@ -131,5 +141,5 @@ wince*: { } } else { - QMAKE_LIBS += $$QMAKE_LIBS_OPENGL + LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL } diff --git a/src/openvg/openvg.pro b/src/openvg/openvg.pro index 240bf13..bf224b4 100644 --- a/src/openvg/openvg.pro +++ b/src/openvg/openvg.pro @@ -36,19 +36,19 @@ include(../qbase.pri) unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui !isEmpty(QMAKE_INCDIR_OPENVG): INCLUDEPATH += $$QMAKE_INCDIR_OPENVG -!isEmpty(QMAKE_LIBDIR_OPENVG): LIBS += -L$$QMAKE_LIBDIR_OPENVG -!isEmpty(QMAKE_LIBS_OPENVG): LIBS += $$QMAKE_LIBS_OPENVG +!isEmpty(QMAKE_LIBDIR_OPENVG): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_OPENVG +!isEmpty(QMAKE_LIBS_OPENVG): LIBS_PRIVATE += $$QMAKE_LIBS_OPENVG contains(QT_CONFIG, egl) { !isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL - !isEmpty(QMAKE_LIBDIR_EGL): LIBS += -L$$QMAKE_LIBDIR_EGL - !isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL + !isEmpty(QMAKE_LIBDIR_EGL): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_EGL + !isEmpty(QMAKE_LIBS_EGL): LIBS_PRIVATE += $$QMAKE_LIBS_EGL } contains(QT_CONFIG, openvg_on_opengl) { !isEmpty(QMAKE_INCDIR_OPENGL): INCLUDEPATH += $$QMAKE_INCDIR_OPENGL - !isEmpty(QMAKE_LIBDIR_OPENGL): LIBS += -L$$QMAKE_LIBDIR_OPENGL - !isEmpty(QMAKE_LIBS_OPENGL): LIBS += $$QMAKE_LIBS_OPENGL + !isEmpty(QMAKE_LIBDIR_OPENGL): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_OPENGL + !isEmpty(QMAKE_LIBS_OPENGL): LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL } INCLUDEPATH += ../3rdparty/harfbuzz/src diff --git a/src/plugins/phonon/qt7/qt7.pro b/src/plugins/phonon/qt7/qt7.pro index 665baee..53407db 100644 --- a/src/plugins/phonon/qt7/qt7.pro +++ b/src/plugins/phonon/qt7/qt7.pro @@ -12,7 +12,7 @@ contains(QMAKE_MAC_XARCH, no) { LIBS += -Xarch_i386 -framework QuickTime -Xarch_ppc -framework QuickTime } -LIBS += -framework AudioUnit \ +LIBS += -framework AppKit -framework AudioUnit \ -framework AudioToolbox -framework CoreAudio \ -framework QuartzCore -framework QTKit diff --git a/src/qt3support/network/network.pri b/src/qt3support/network/network.pri index 31ea682..086f56a 100644 --- a/src/qt3support/network/network.pri +++ b/src/qt3support/network/network.pri @@ -26,5 +26,5 @@ SOURCES += network/q3dns.cpp \ win32:SOURCES += network/q3socketdevice_win.cpp unix:SOURCES += network/q3socketdevice_unix.cpp -mac:LIBS += -lresolv +mac:LIBS_PRIVATE += -lresolv diff --git a/src/qt3support/qt3support.pro b/src/qt3support/qt3support.pro index 23a4696..a30117c 100644 --- a/src/qt3support/qt3support.pro +++ b/src/qt3support/qt3support.pro @@ -25,7 +25,7 @@ unix { QMAKE_PKGCONFIG_CFLAGS += -DQT3_SUPPORT QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork QtSql } -mac:LIBS += -framework Carbon +mac:LIBS_PRIVATE += -framework Carbon QMAKE_LIBS += $$QMAKE_LIBS_COMPAT $$QMAKE_LIBS_NETWORK DEFINES -= QT3_SUPPORT_WARNINGS diff --git a/src/svg/svg.pro b/src/svg/svg.pro index aef0786..9a01983 100644 --- a/src/svg/svg.pro +++ b/src/svg/svg.pro @@ -44,5 +44,5 @@ INCLUDEPATH += ../3rdparty/harfbuzz/src contains(QT_CONFIG, zlib) { INCLUDEPATH += ../3rdparty/zlib } else:!contains(QT_CONFIG, no-zlib) { - unix:LIBS += -lz + unix:LIBS_PRIVATE += -lz } diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 9740c21..5238dfe 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -57,10 +57,9 @@ wince*::LIBS += libcmt.lib \ commctrl.lib \ coredll.lib \ winsock.lib -mac:LIBS += -framework \ - IOKit \ - -framework \ - Security +mac:LIBS += -framework IOKit \ + -framework ApplicationServices \ + -framework Security include(../qbase.pri) QMAKE_TARGET_PRODUCT = QTestLib QMAKE_TARGET_DESCRIPTION = Qt \ diff --git a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro index 5d6d436..011dec2 100644 --- a/tools/assistant/lib/lib.pro +++ b/tools/assistant/lib/lib.pro @@ -18,14 +18,12 @@ if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { mac:qclucene = $${qclucene}_debug win32:qclucene = $${qclucene}d } -linux-lsb-g++:LIBS += --lsb-shared-libs=$$qclucene -unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \ - QtSql \ - QtXml -LIBS += -l$$qclucene +linux-lsb-g++:LIBS_PRIVATE += --lsb-shared-libs=$$qclucene unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \ QtSql \ QtXml +LIBS_PRIVATE += -l$$qclucene + RESOURCES += helpsystem.qrc SOURCES += qhelpenginecore.cpp \ qhelpengine.cpp \ -- cgit v0.12 From 213e2c937b667dba7e4996b0857ae5791c6d5fc8 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 12:01:21 +0200 Subject: Fixed coverity warnings --- src/corelib/io/qiodevice.cpp | 2 +- src/gui/itemviews/qlistview.cpp | 1 - src/gui/itemviews/qlistview_p.h | 7 ++++--- src/gui/itemviews/qtreewidget.cpp | 1 + src/gui/painting/qpdf.cpp | 2 +- src/gui/styles/qstyleoption.cpp | 6 +++--- src/gui/text/qcssparser_p.h | 2 +- src/xml/dom/qdom.cpp | 5 ++--- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 4108136..35b85c3 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -811,7 +811,7 @@ qint64 QIODevice::read(char *data, qint64 maxSize) #endif if (readFromDevice < bytesToBuffer) - d->buffer.truncate(readFromDevice < 0 ? 0 : int(readFromDevice)); + d->buffer.truncate(int(readFromDevice)); if (!d->buffer.isEmpty()) { lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar); readSoFar += lastReadChunkSize; diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 1870a3b..3ab3204 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1957,7 +1957,6 @@ bool QListView::event(QEvent *e) QListViewPrivate::QListViewPrivate() : QAbstractItemViewPrivate(), dynamicListView(0), - staticListView(0), wrap(false), space(0), flow(QListView::TopToBottom), diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h index 1131059..6c8d324 100644 --- a/src/gui/itemviews/qlistview_p.h +++ b/src/gui/itemviews/qlistview_p.h @@ -351,9 +351,10 @@ public: QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; - // ### FIXME: we only need one at a time - QDynamicListViewBase *dynamicListView; - QStaticListViewBase *staticListView; + union { + QDynamicListViewBase *dynamicListView; + QStaticListViewBase *staticListView; + }; // ### FIXME: see if we can move the members into the dynamic/static classes diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 025f83c..1ab69df 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -1768,6 +1768,7 @@ QVariant QTreeWidgetItem::data(int column, int role) const // special case for check state in tristate if (children.count() && (itemFlags & Qt::ItemIsTristate)) return childrenCheckState(column); + // fallthrough intended default: if (column >= 0 && column < values.size()) { const QVector &column_values = values.at(column); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 6a7889a..478a2a8 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -313,7 +313,7 @@ QByteArray QPdf::generatePath(const QPainterPath &path, const QTransform &matrix Qt::FillRule fillRule = path.fillRule(); - const char *op = 0; + const char *op = ""; switch (flags) { case ClipPath: op = (fillRule == Qt::WindingFill) ? "W n\n" : "W* n\n"; diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index 98996e2..eabbb8d 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -712,7 +712,7 @@ QStyleOptionFrameV2 &QStyleOptionFrameV2::operator=(const QStyleOptionFrame &oth Constructs a QStyleOptionFrameV3 object. */ QStyleOptionFrameV3::QStyleOptionFrameV3() - : QStyleOptionFrameV2(Version), frameShape(QFrame::NoFrame) + : QStyleOptionFrameV2(Version), frameShape(QFrame::NoFrame), unused(0) { } @@ -726,7 +726,7 @@ QStyleOptionFrameV3::QStyleOptionFrameV3() \internal */ QStyleOptionFrameV3::QStyleOptionFrameV3(int version) - : QStyleOptionFrameV2(version), frameShape(QFrame::NoFrame) + : QStyleOptionFrameV2(version), frameShape(QFrame::NoFrame), unused(0) { } @@ -4845,7 +4845,7 @@ QStyleOptionTabBarBaseV2 &QStyleOptionTabBarBaseV2::operator = (const QStyleOpti /*! \internal */ QStyleOptionTabBarBaseV2::QStyleOptionTabBarBaseV2(int version) - : QStyleOptionTabBarBase(version) + : QStyleOptionTabBarBase(version), documentMode(false) { } diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index c685b08..6f73445 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -504,7 +504,7 @@ const int NumPseudos = 46; struct Pseudo { - Pseudo() : negated(false) { } + Pseudo() : type(0), negated(false) { } quint64 type; QString name; QString function; diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index a7dfaa9..85a31c7 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -1845,8 +1845,7 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) oldChild->prev = 0; // We are no longer interested in the old node - if (oldChild) - oldChild->ref.deref(); + oldChild->ref.deref(); return oldChild; } @@ -4355,7 +4354,7 @@ bool QDomAttr::specified() const QDomElement QDomAttr::ownerElement() const { Q_ASSERT(impl->parent()); - if (!impl || !impl->parent()->isElement()) + if (!impl->parent()->isElement()) return QDomElement(); return QDomElement((QDomElementPrivate*)(impl->parent())); } -- cgit v0.12 From dc2771eb57702a0daf5164b0f9ad569c9fe0e5ba Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 12:51:37 +0200 Subject: Better handling of qreal with QVariant --- src/corelib/kernel/qabstractitemmodel.cpp | 39 ++++++++++++++++++++----------- src/corelib/kernel/qabstractitemmodel_p.h | 2 +- src/corelib/kernel/qvariant.cpp | 2 +- src/gui/itemviews/qlistwidget.cpp | 4 +--- src/gui/itemviews/qstyleditemdelegate.cpp | 2 +- src/gui/itemviews/qtablewidget.cpp | 4 +--- src/gui/itemviews/qtreewidget.cpp | 4 +--- src/gui/text/qcssparser.cpp | 2 +- 8 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index cfc961c..61b19a2 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -488,35 +488,48 @@ const QHash &QAbstractItemModelPrivate::defaultRoleNames() return *qDefaultRoleNames(); } -/*! - \internal - return true if \a value contains a numerical type - This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort. - We cannot rely on QVariant::canConvert because this would take strings as double - and then not sort strings correctly -*/ -bool QAbstractItemModelPrivate::canConvertToDouble(const QVariant &value) +static uint typeOfVariant(const QVariant &value) { + //return 0 for integer, 1 for floating point and 2 for other switch (value.userType()) { case QVariant::Bool: case QVariant::Int: case QVariant::UInt: case QVariant::LongLong: case QVariant::ULongLong: - case QVariant::Double: case QVariant::Char: - case QMetaType::Float: case QMetaType::Short: case QMetaType::UShort: case QMetaType::UChar: case QMetaType::ULong: case QMetaType::Long: - return true; + return 0; + case QVariant::Double: + case QMetaType::Float: + return 1; default: - return false; + return 2; + } +} + +/*! + \internal + return true if \a value contains a numerical type + + This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort. +*/ +bool QAbstractItemModelPrivate::variantLessThan(const QVariant &v1, const QVariant &v2) +{ + switch(qMax(typeOfVariant(v1), typeOfVariant(v2))) + { + case 0: //integer type + return v1.toLongLong() < v2.toLongLong(); + case 1: //floating point + return v1.toReal() < v2.toReal(); + default: + return v1.toString() < v2.toString(); } - return false; } void QAbstractItemModelPrivate::removePersistentIndexData(QPersistentModelIndexData *data) diff --git a/src/corelib/kernel/qabstractitemmodel_p.h b/src/corelib/kernel/qabstractitemmodel_p.h index 76c2d70..e81e627 100644 --- a/src/corelib/kernel/qabstractitemmodel_p.h +++ b/src/corelib/kernel/qabstractitemmodel_p.h @@ -89,7 +89,7 @@ public: void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last); void columnsRemoved(const QModelIndex &parent, int first, int last); static QAbstractItemModel *staticEmptyModel(); - static bool canConvertToDouble(const QVariant &value); + static bool variantLessThan(const QVariant &v1, const QVariant &v2); inline QModelIndex createIndex(int row, int column, void *data = 0) const { return q_func()->createIndex(row, column, data); diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 3c430eb..66c4176 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2776,7 +2776,7 @@ bool QVariant::cmp(const QVariant &v) const if (d.type != v2.d.type) { if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) { if (qIsFloatingPoint(d.type) || qIsFloatingPoint(v.d.type)) - return qFuzzyCompare(toDouble(), v.toDouble()); + return qFuzzyCompare(toReal(), v.toReal()); else return toLongLong() == v.toLongLong(); } diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 2792bbd..a1f8288 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -708,9 +708,7 @@ QVariant QListWidgetItem::data(int role) const bool QListWidgetItem::operator<(const QListWidgetItem &other) const { const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index f7c7d12..a8ea218 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -270,7 +270,7 @@ QString QStyledItemDelegate::displayText(const QVariant &value, const QLocale& l switch (value.userType()) { case QMetaType::Float: case QVariant::Double: - text = locale.toString(value.toDouble()); + text = locale.toString(value.toReal()); break; case QVariant::Int: case QVariant::LongLong: diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index fea81e5..de8ebde 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -1392,9 +1392,7 @@ QVariant QTableWidgetItem::data(int role) const bool QTableWidgetItem::operator<(const QTableWidgetItem &other) const { const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 1ab69df..f48e393 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -1790,9 +1790,7 @@ bool QTreeWidgetItem::operator<(const QTreeWidgetItem &other) const int column = view ? view->sortColumn() : 0; const QVariant v1 = data(column, Qt::DisplayRole); const QVariant v2 = other.data(column, Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 181ec7e..f11104f 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -793,7 +793,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal) if (attr.compare(QLatin1String("spread"), Qt::CaseInsensitive) == 0) { spread = spreads.indexOf(value.variant.toString()); } else { - vars[attr] = value.variant.toString().toDouble(); + vars[attr] = value.variant.toReal(); } } parser.skipSpace(); -- cgit v0.12 From efd84105355552bcb203b5e402be0352641e7480 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Mon, 17 Aug 2009 13:14:27 +0200 Subject: Fix compiler flags setting for .mm files on Mac. Commit 7f1cba82 causes {x86, x86_64, ppc, ppc64}.prf to be loaded before objective_c.prf. This will add content to QMAKE_OBJECTIVE_CFLAGS, causing the isEmpty test to skip populating QMAKE_OBJECTIVE_CFLAGS. Remove the isEmpty test to fix the issue. --- mkspecs/features/mac/objective_c.prf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkspecs/features/mac/objective_c.prf b/mkspecs/features/mac/objective_c.prf index 0a73af9..0df7013 100644 --- a/mkspecs/features/mac/objective_c.prf +++ b/mkspecs/features/mac/objective_c.prf @@ -1,6 +1,5 @@ isEmpty(QMAKE_OBJECTIVE_CC):QMAKE_OBJECTIVE_CC = $$QMAKE_CC -isEmpty(QMAKE_OBJECTIVE_CFLAGS) { #bootstrap QMAKE_OBJECTIVE_CFLAGS = $$QMAKE_CFLAGS QMAKE_OBJECTIVE_CFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON QMAKE_OBJECTIVE_CFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF @@ -9,7 +8,7 @@ isEmpty(QMAKE_OBJECTIVE_CFLAGS) { #bootstrap QMAKE_OBJECTIVE_CFLAGS_X86 = $$QMAKE_CFLAGS_X86 QMAKE_OBJECTIVE_CFLAGS_PPC = $$QMAKE_CFLAGS_PPC QMAKE_OBJECTIVE_CFLAGS_HIDESYMS = $$QMAKE_CXXFLAGS_HIDESYMS -} + OBJECTIVE_C_OBJECTS_DIR = $$OBJECTS_DIR isEmpty(OBJECTIVE_C_OBJECTS_DIR):OBJECTIVE_C_OBJECTS_DIR = . isEmpty(QMAKE_EXT_OBJECTIVE_C):QMAKE_EXT_OBJECTIVE_C = .mm .m -- cgit v0.12 From abdf1befb8de4b88da43561dae2e1beb09c2a532 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 17 Aug 2009 13:29:09 +0200 Subject: Transforms do not obey AnchorUnderMouse with viewport margins set setTransformationAnchor(QGraphicsView::AnchorUnderMouse) would not work properly if viewport margins were set. When centering the view in QGraphicsViewPrivate::centerView, the viewport margins were not being taken into account. Mapping from global cursor coordinates in the viewport instead of the view fixes the issue. Task-number: 255529 Reviewed-by: Olivier --- src/gui/graphicsview/qgraphicsview.cpp | 4 +-- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 37 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 7213542..91e654c 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -493,8 +493,8 @@ void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor) // Last scene pos: lastMouseMoveScenePoint // Current mouse pos: QPointF transformationDiff = q->mapToScene(viewport->rect().center()) - - q->mapToScene(q->mapFromGlobal(QCursor::pos())); - q->centerOn(lastMouseMoveScenePoint + transformationDiff);; + - q->mapToScene(viewport->mapFromGlobal(QCursor::pos())); + q->centerOn(lastMouseMoveScenePoint + transformationDiff); } else { q->centerOn(lastCenterPoint); } diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 0c65b87..c12fb11 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -216,6 +216,7 @@ private slots: void task239047_fitInViewSmallViewport(); void task245469_itemsAtPointWithClip(); void task253415_reconnectUpdateSceneOnSceneChanged(); + void task255529_transformationAnchorMouseAndViewportMargins(); }; void tst_QGraphicsView::initTestCase() @@ -3617,5 +3618,41 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() QVERIFY(wasConnected2); } +void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() +{ + QGraphicsScene scene(-100, -100, 200, 200); + scene.addRect(QRectF(-50, -50, 100, 100), QPen(Qt::black), QBrush(Qt::blue)); + + class VpGraphicsView: public QGraphicsView + { + public: + VpGraphicsView(QGraphicsScene *scene) + : QGraphicsView(scene) + { + setViewportMargins(8, 16, 12, 20); + setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + setMouseTracking(true); + } + }; + + VpGraphicsView view(&scene); + view.show(); + QPoint mouseViewPos(20, 20); + sendMouseMove(view.viewport(), mouseViewPos); + QTest::qWait(125); + + QPointF mouseScenePos = view.mapToScene(mouseViewPos); + view.setTransform(QTransform().scale(5, 5)); + QTest::qWait(125); + view.setTransform(QTransform().rotate(5, Qt::ZAxis), true); + QTest::qWait(125); + + QPointF newMouseScenePos = view.mapToScene(mouseViewPos); + qreal slack = 3; + QVERIFY(qAbs(newMouseScenePos.x() - mouseScenePos.x()) < slack); + QVERIFY(qAbs(newMouseScenePos.y() - mouseScenePos.y()) < slack); +} + + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" -- cgit v0.12 From 025a7395153c3708e2964cfd93957532b19ae04f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 17 Aug 2009 13:15:08 +0200 Subject: QPaintDevice implemented in qpaintdevice.cpp. Saves duplicated code Reviewed-by: Eskil --- src/gui/painting/painting.pri | 5 +-- src/gui/painting/qpaintdevice.cpp | 66 +++++++++++++++++++++++++++++++++++ src/gui/painting/qpaintdevice_mac.cpp | 28 --------------- src/gui/painting/qpaintdevice_win.cpp | 21 ----------- src/gui/painting/qpaintdevice_x11.cpp | 21 ----------- 5 files changed, 69 insertions(+), 72 deletions(-) create mode 100644 src/gui/painting/qpaintdevice.cpp diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index adb73aa..b9d293c 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -46,7 +46,7 @@ HEADERS += \ SOURCES += \ painting/qbezier.cpp \ - painting/qblendfunctions.cpp \ + painting/qblendfunctions.cpp \ painting/qbrush.cpp \ painting/qcolor.cpp \ painting/qcolor_p.cpp \ @@ -57,6 +57,7 @@ SOURCES += \ painting/qmatrix.cpp \ painting/qmemrotate.cpp \ painting/qoutlinemapper.cpp \ + painting/qpaintdevice.cpp \ painting/qpaintengine.cpp \ painting/qpaintengine_alpha.cpp \ painting/qpaintengine_preview.cpp \ @@ -75,9 +76,9 @@ SOURCES += \ painting/qstroker.cpp \ painting/qstylepainter.cpp \ painting/qtessellator.cpp \ - painting/qwindowsurface.cpp \ painting/qtextureglyphcache.cpp \ painting/qtransform.cpp \ + painting/qwindowsurface.cpp \ DEFINES += QT_RASTER_IMAGEENGINE win32:DEFINES += QT_RASTER_PAINTENGINE diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp new file mode 100644 index 0000000..6477952 --- /dev/null +++ b/src/gui/painting/qpaintdevice.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qpaintdevice.h" + +QT_BEGIN_NAMESPACE + +extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp + +QPaintDevice::QPaintDevice() +{ + painters = 0; +} + +QPaintDevice::~QPaintDevice() +{ + if (paintingActive()) + qWarning("QPaintDevice: Cannot destroy paint device that is being " + "painted"); + qt_painter_removePaintDevice(this); +} + + +int QPaintDevice::metric(PaintDeviceMetric) const +{ + qWarning("QPaintDevice::metrics: Device has no metric information"); + return 0; +} diff --git a/src/gui/painting/qpaintdevice_mac.cpp b/src/gui/painting/qpaintdevice_mac.cpp index bf5e261..aa7c2ac 100644 --- a/src/gui/painting/qpaintdevice_mac.cpp +++ b/src/gui/painting/qpaintdevice_mac.cpp @@ -57,34 +57,6 @@ QT_BEGIN_NAMESPACE Internal variables and functions *****************************************************************************/ - -/***************************************************************************** - External functions - *****************************************************************************/ - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -/***************************************************************************** - QPaintDevice member functions - *****************************************************************************/ -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -QPaintDevice::~QPaintDevice() -{ - if(paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted, be sure to QPainter::end() painters"); - qt_painter_removePaintDevice(this); -} - -int QPaintDevice::metric(PaintDeviceMetric) const -{ - return 0; -} - /*! \internal */ float qt_mac_defaultDpi_x() { diff --git a/src/gui/painting/qpaintdevice_win.cpp b/src/gui/painting/qpaintdevice_win.cpp index 86de028..f964feb 100644 --- a/src/gui/painting/qpaintdevice_win.cpp +++ b/src/gui/painting/qpaintdevice_win.cpp @@ -50,27 +50,6 @@ QT_BEGIN_NAMESPACE -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -QPaintDevice::~QPaintDevice() -{ - if (paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted. Be sure to QPainter::end() painters!"); - qt_painter_removePaintDevice(this); -} - -int QPaintDevice::metric(PaintDeviceMetric) const -{ - qWarning("QPaintDevice::metrics: Device has no metric information"); - return 0; -} - HDC QPaintDevice::getDC() const { return 0; diff --git a/src/gui/painting/qpaintdevice_x11.cpp b/src/gui/painting/qpaintdevice_x11.cpp index b0ed732..474f3f1 100644 --- a/src/gui/painting/qpaintdevice_x11.cpp +++ b/src/gui/painting/qpaintdevice_x11.cpp @@ -49,21 +49,6 @@ QT_BEGIN_NAMESPACE -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -QPaintDevice::~QPaintDevice() -{ - if (paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted"); - qt_painter_removePaintDevice(this); -} - /*! \internal Returns the X11 Drawable of the paint device. 0 is returned if it @@ -96,12 +81,6 @@ const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd) return 0; } -int QPaintDevice::metric(PaintDeviceMetric) const -{ - qWarning("QPaintDevice::metrics: Device has no metric information"); - return 0; -} - #ifdef QT3_SUPPORT -- cgit v0.12 From 3d50220423b96a84f1ca4c0f5ef9246345aad359 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 13:48:51 +0200 Subject: Fix coverity warnings --- src/gui/image/qmovie.cpp | 2 +- src/gui/image/qppmhandler.cpp | 2 +- src/gui/itemviews/qheaderview.cpp | 2 +- src/gui/painting/qpaintengine_raster.cpp | 3 --- src/gui/text/qcssparser.cpp | 6 +++--- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 2265e7b..c341e5e 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -356,7 +356,7 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber) reader = new QImageReader(device, format); else reader = new QImageReader(absoluteFilePath, format); - reader->canRead(); // Provoke a device->open() call + (void)reader->canRead(); // Provoke a device->open() call reader->device()->seek(initialDevicePos); reader->setBackgroundColor(bgColor); reader->setScaledSize(scaledSize); diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index 77ccb48..ed8f4c1 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -80,7 +80,7 @@ static int read_pbm_int(QIODevice *d) else if (isspace((uchar) c)) continue; else if (c == '#') - d->readLine(buf, buflen); + (void)d->readLine(buf, buflen); else break; } diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 633dd53..96df758 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -2615,7 +2615,7 @@ void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bot int first = orientation() == Qt::Horizontal ? topLeft.column() : topLeft.row(); int last = orientation() == Qt::Horizontal ? bottomRight.column() : bottomRight.row(); for (int i = first; i <= last && !resizeRequired; ++i) - resizeRequired = (resizeRequired && resizeMode(i)); + resizeRequired = (resizeMode(i) == ResizeToContents); if (resizeRequired) d->doDelayedResizeSections(); } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 654870f..d00329b 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1022,9 +1022,6 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt, if (alpha == 0 || !clip.isValid()) return; - if (alpha ==0) - return; - Q_ASSERT(img.depth() >= 8); int srcBPL = img.bytesPerLine(); diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index f11104f..d3dcf50 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -789,7 +789,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal) } else { parser.next(); Value value; - parser.parseTerm(&value); + (void)parser.parseTerm(&value); if (attr.compare(QLatin1String("spread"), Qt::CaseInsensitive) == 0) { spread = spreads.indexOf(value.variant.toString()); } else { @@ -797,7 +797,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal) } } parser.skipSpace(); - parser.test(COMMA); + (void)parser.test(COMMA); } if (gradType == 0) { @@ -2458,7 +2458,7 @@ bool Parser::parseAttrib(AttributeSelector *attr) bool Parser::parsePseudo(Pseudo *pseudo) { - test(COLON); + (void)test(COLON); pseudo->negated = test(EXCLAMATION_SYM); if (test(IDENT)) { pseudo->name = lexem(); -- cgit v0.12 From b80312254e61986e6848d1608dcac54e0b3f191a Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 12 Aug 2009 10:34:40 +0200 Subject: remove QT_RASTER_PAINTENGINE and QT_RASTER_IMAGEENGINE defines as they are legacy and completely pointless... Reviewed-By: Eskil --- src/gui/image/qimage.cpp | 7 +---- src/gui/image/qpixmap_mac.cpp | 11 ------- src/gui/kernel/qcocoaview_mac.mm | 67 +++++++++++++++++++--------------------- src/gui/kernel/qwidget_mac.mm | 27 +--------------- src/gui/painting/painting.pri | 3 -- 5 files changed, 33 insertions(+), 82 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 0001e2b..09bc8c8 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -61,11 +61,7 @@ #include -#ifdef QT_RASTER_IMAGEENGINE #include -#else -#include -#endif #include @@ -5255,11 +5251,10 @@ QPaintEngine *QImage::paintEngine() const if (!d) return 0; -#ifdef QT_RASTER_IMAGEENGINE if (!d->paintEngine) { d->paintEngine = new QRasterPaintEngine(const_cast(this)); } -#endif + return d->paintEngine; } diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 8c911bb..5959da1 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -38,7 +38,6 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//#define QT_RASTER_PAINTENGINE #include "qpixmap.h" #include "qimage.h" @@ -52,9 +51,6 @@ #include #include #include -#ifdef QT_RASTER_PAINTENGINE -# include -#endif #include #include #include @@ -1098,14 +1094,7 @@ QPaintEngine* QMacPixmapData::paintEngine() const { if (!pengine) { QMacPixmapData *that = const_cast(this); -#ifdef QT_RASTER_PAINTENGINE - if (qgetenv("QT_MAC_USE_COREGRAPHICS").isNull()) - that->pengine = new QRasterPaintEngine(); - else - that->pengine = new QCoreGraphicsPaintEngine(); -#else that->pengine = new QCoreGraphicsPaintEngine(); -#endif } return pengine; } diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index c20445a..45b0ada 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -102,7 +102,7 @@ static dndenum_mapper dnd_enums[] = { { NSDragOperationCopy, Qt::CopyAction, true }, { NSDragOperationGeneric, Qt::CopyAction, false }, { NSDragOperationEvery, Qt::ActionMask, false }, - { NSDragOperationNone, Qt::IgnoreAction, false } + { NSDragOperationNone, Qt::IgnoreAction, false } }; static NSDragOperation qt_mac_mapDropAction(Qt::DropAction action) @@ -228,14 +228,14 @@ extern "C" { currentCustomTypes = new QStringList(); *currentCustomTypes = customTypes; const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName"; - NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, - NSFilenamesPboardType, NSStringPboardType, - NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType, - NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType, - NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType, - NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType, + NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, + NSFilenamesPboardType, NSStringPboardType, + NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType, + NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType, + NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType, + NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType, NSURLPboardType, NSPDFPboardType, NSVCardPboardType, - NSFilesPromisePboardType, NSInkTextPboardType, + NSFilesPromisePboardType, NSInkTextPboardType, NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil]; // Add custom types supported by the application. for (int i = 0; i < customTypes.size(); i++) { @@ -280,16 +280,16 @@ extern "C" { dropData = 0; } } - -- (void)addDropData:(id )sender + +- (void)addDropData:(id )sender { [self removeDropData]; - CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name]; + CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name]; dropData = new QCocoaDropData(dropPasteboard); -} +} -- (NSDragOperation)draggingEntered:(id )sender -{ +- (NSDragOperation)draggingEntered:(id )sender +{ if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false) return NSDragOperationNone; NSPoint windowPoint = [sender draggingLocation]; @@ -307,7 +307,7 @@ extern "C" { NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint]; NSPoint localPoint = [self convertPoint:windowPoint fromView:nil]; QPoint posDrag(localPoint.x, localPoint.y); - NSDragOperation nsActions = [sender draggingSourceOperationMask]; + NSDragOperation nsActions = [sender draggingSourceOperationMask]; Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions); QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions; Qt::KeyboardModifiers modifiers = Qt::NoModifier; @@ -336,8 +336,8 @@ extern "C" { qDMEvent.accept(); // accept by default, since enter event was accepted. QApplication::sendEvent(qwidget, &qDMEvent); if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) { - // since we accepted the drag enter event, the widget expects - // future drage move events. + // since we accepted the drag enter event, the widget expects + // future drage move events. // ### check if we need to treat this like the drag enter event. nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDEEvent.dropAction()); } else { @@ -345,7 +345,7 @@ extern "C" { } QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent); return nsActions; - } + } } - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender @@ -373,7 +373,7 @@ extern "C" { if (qt_mac_mouse_inside_answer_rect(posDrag) && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) return QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction)); - // send drag move event to the widget + // send drag move event to the widget QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions; Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions); Qt::KeyboardModifiers modifiers = Qt::NoModifier; @@ -436,7 +436,7 @@ extern "C" { NSPoint localPoint = [self convertPoint:windowPoint fromView:nil]; QPoint posDrop(localPoint.x, localPoint.y); - NSDragOperation nsActions = [sender draggingSourceOperationMask]; + NSDragOperation nsActions = [sender draggingSourceOperationMask]; Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions); QMimeData *mimeData = dropData; if (QDragManager::self()->source()) @@ -563,11 +563,6 @@ extern "C" { qt_sendSpontaneousEvent(qwidget, &e); if (!redirectionOffset.isNull()) QPainter::restoreRedirected(qwidget); -#ifdef QT_RASTER_PAINTENGINE - if(engine && engine->type() == QPaintEngine::Raster) - static_cast(engine)->flush(qwidget, - qrgn.boundingRect().topLeft()); -#endif if (engine) engine->setSystemClip(QRegion()); qwidget->setAttribute(Qt::WA_WState_InPaintEvent, false); @@ -638,7 +633,7 @@ extern "C" { QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1)); QApplicationPrivate::instance()->notify_helper(qwidget, &he); } - } + } } - (void)mouseExited:(NSEvent *)event @@ -647,7 +642,7 @@ extern "C" { NSPoint globalPoint = [[event window] convertBaseToScreen:[event locationInWindow]]; if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) { QApplication::sendEvent(qwidget, &leaveEvent); - + // ### Think about if it is necessary to update the cursor, should only be for a few cases. qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint()); if (qwidget->testAttribute(Qt::WA_Hover) @@ -679,7 +674,7 @@ extern "C" { { qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::LeftButton); // Don't call super here. This prevents us from getting the mouseUp event, - // which we need to send even if the mouseDown event was not accepted. + // which we need to send even if the mouseDown event was not accepted. // (this is standard Qt behavior.) } @@ -843,7 +838,7 @@ extern "C" { } #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 -- (void)touchesBeganWithEvent:(NSEvent *)event; +- (void)touchesBeganWithEvent:(NSEvent *)event; { bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents); qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all)); @@ -1128,7 +1123,7 @@ extern "C" { while (index < composingLength) { NSRange effectiveRange; NSRange range = NSMakeRange(index, composingLength-index); - NSDictionary *attributes = [aString attributesAtIndex:index + NSDictionary *attributes = [aString attributesAtIndex:index longestEffectiveRange:&effectiveRange inRange:range]; NSNumber *underlineStyle = [attributes objectForKey:NSUnderlineStyleAttributeName]; @@ -1137,7 +1132,7 @@ extern "C" { NSColor *color = [attributes objectForKey:NSUnderlineColorAttributeName]; if (color) { clr = colorFrom(color); - } + } QTextCharFormat format; format.setFontUnderline(true); format.setUnderlineColor(clr); @@ -1213,7 +1208,7 @@ extern "C" { - (NSRange) markedRange { - NSRange range; + NSRange range; if (composing) { range.location = 0; range.length = composingLength; @@ -1238,13 +1233,13 @@ extern "C" { selRange.length = 0; } return selRange; - + } - (NSRect) firstRectForCharacterRange:(NSRange)theRange { Q_UNUSED(theRange); - // The returned rect is always based on the internal cursor. + // The returned rect is always based on the internal cursor. QRect mr(qwidget->inputMethodQuery(Qt::ImMicroFocus).toRect()); QPoint mp(qwidget->mapToGlobal(QPoint(mr.bottomLeft()))); NSRect rect ; @@ -1392,7 +1387,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) NSImage *image = (NSImage *)qt_mac_create_nsimage(pix); [image retain]; DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; - // save supported actions + // save supported actions [dndParams->view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)]; NSPoint imageLoc = {dndParams->localPoint.x - hotspot.x(), dndParams->localPoint.y + pix.height() - hotspot.y()}; @@ -1416,7 +1411,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams->performedAction)); // do post drag processing, if required. if(performedAction != Qt::IgnoreAction) { - // check if the receiver points us to a file location. + // check if the receiver points us to a file location. // if so, we need to do the file copy/move ourselves. QCFType pasteLocation = 0; PasteboardCopyPasteLocation(dragBoard.pasteBoard(), &pasteLocation); diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5948cd4..5bf140c 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -72,7 +72,6 @@ ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ****************************************************************************/ -//#define QT_RASTER_PAINTENGINE #include #include @@ -88,9 +87,6 @@ #include "qlayout.h" #include "qmenubar.h" #include -#ifdef QT_RASTER_PAINTENGINE -# include -#endif #include #include #include "qpainter.h" @@ -1220,11 +1216,6 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event, QApplication::sendSpontaneousEvent(widget, &e); if (!redirectionOffset.isNull()) widget->d_func()->restoreRedirected(); -#ifdef QT_RASTER_PAINTENGINE - if(engine && engine->type() == QPaintEngine::Raster) - static_cast(engine)->flush(widget, - qrgn.boundingRect().topLeft()); -#endif //cleanup if (engine) @@ -3101,7 +3092,7 @@ void QWidgetPrivate::update_sys(const QRegion &rgn) dirtyOnWidget += rgn; #ifndef QT_MAC_USE_COCOA RgnHandle rgnHandle = rgn.toQDRgnForUpdate_sys(); - if (rgnHandle) + if (rgnHandle) HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true); else { HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow. @@ -4555,21 +4546,6 @@ Q_GLOBAL_STATIC(QPaintEngineCleanupHandler, engineHandler) QPaintEngine *QWidget::paintEngine() const { QPaintEngine *&pe = engineHandler()->engine; -#ifdef QT_RASTER_PAINTENGINE - if (!pe) { - if(qgetenv("QT_MAC_USE_COREGRAPHICS").isNull()) - pe = new QRasterPaintEngine(); - else - pe = new QCoreGraphicsPaintEngine(); - } - if (pe->isActive()) { - QPaintEngine *engine = - qgetenv("QT_MAC_USE_COREGRAPHICS").isNull() - ? (QPaintEngine*)new QRasterPaintEngine() : (QPaintEngine*)new QCoreGraphicsPaintEngine(); - engine->setAutoDestruct(true); - return engine; - } -#else if (!pe) pe = new QCoreGraphicsPaintEngine(); if (pe->isActive()) { @@ -4577,7 +4553,6 @@ QPaintEngine *QWidget::paintEngine() const engine->setAutoDestruct(true); return engine; } -#endif return pe; } diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index b9d293c..d11e818 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -80,9 +80,6 @@ SOURCES += \ painting/qtransform.cpp \ painting/qwindowsurface.cpp \ - DEFINES += QT_RASTER_IMAGEENGINE - win32:DEFINES += QT_RASTER_PAINTENGINE - embedded:DEFINES += QT_RASTER_PAINTENGINE SOURCES += \ painting/qpaintengine_raster.cpp \ painting/qdrawhelper.cpp \ -- cgit v0.12 From 38f41726cf3a76a57ca15f7cc82e56a5aa2c5a1c Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 13:59:43 +0200 Subject: QTextControl::print: fix coverity warning the test was wrong on the QPrinter pointer In addition, priv is never null --- src/gui/text/qtextcontrol.cpp | 2 +- src/gui/text/qtextcursor.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 58f8a06..1c14d20 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -2262,7 +2262,7 @@ void QTextControl::print(QPrinter *printer) const { #ifndef QT_NO_PRINTER Q_D(const QTextControl); - if (printer && !printer->isValid()) + if (!printer || !printer->isValid()) return; QTextDocument *tempDoc = 0; const QTextDocument *doc = d->doc; diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 6ab89dc..f97146d 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -84,8 +84,7 @@ QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs) QTextCursorPrivate::~QTextCursorPrivate() { - if (priv) - priv->removeCursor(this); + priv->removeCursor(this); } QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op) @@ -125,7 +124,7 @@ QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int position void QTextCursorPrivate::setX() { - if (priv && priv->isInEditBlock()) { + if (priv->isInEditBlock()) { x = -1; // mark dirty return; } -- cgit v0.12 From 1ca6a2f3174fdfbbe080af920ab75558a1a9247e Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 17 Aug 2009 14:28:45 +0200 Subject: qdoc: Fixed the bug that made reporting NOTIFY signals not work. The signal was being associated with a particular property, but in many classes, the NOTIFY signal applies to multiple properties. Added a new function to the PropertyNode class that adds the signal function without associating it with any property. Task-number: 259071 --- src/gui/graphicsview/qgraphicsitem.cpp | 5 +++-- tools/qdoc3/cppcodeparser.cpp | 4 ++-- tools/qdoc3/node.h | 6 ++++++ tools/qdoc3/tree.cpp | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f454d7c..6d75db3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -6831,11 +6831,12 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent By default, this property is true. - \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled(), enabledChanged() + \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled() + \sa QGraphicsObject::enabledChanged() */ /*! - \fn QGraphicsObject::enabledChanged() + \fn void QGraphicsObject::enabledChanged() This signal gets emitted whenever the item get's enabled or disabled. diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index ebe5ec9..7519ff1 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -1734,11 +1734,11 @@ bool CppCodeParser::matchProperty(InnerNode *parent) property->setDesignable(value.toLower() == "true"); else if (key == "RESET") tre->addPropertyFunction(property, value, PropertyNode::Resetter); -#if 0 + else if (key == "NOTIFY") { tre->addPropertyFunction(property, value, PropertyNode::Notifier); } -#endif + } match(Tok_RightParen); return true; diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index 2a1ca05..0cddf51 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -598,6 +598,7 @@ class PropertyNode : public LeafNode void setDataType(const QString& dataType) { dt = dataType; } void addFunction(FunctionNode *function, FunctionRole role); + void addSignal(FunctionNode *function, FunctionRole role); void setStored(bool stored) { sto = toTrool(stored); } void setDesignable(bool designable) { des = toTrool(designable); } void setOverriddenFrom(const PropertyNode *baseProperty); @@ -641,6 +642,11 @@ inline void PropertyNode::addFunction(FunctionNode *function, FunctionRole role) function->setAssociatedProperty(this); } +inline void PropertyNode::addSignal(FunctionNode *function, FunctionRole role) +{ + funcs[(int)role].append(function); +} + inline NodeList PropertyNode::functions() const { NodeList list; diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index b42701f..7d488df 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -501,7 +501,7 @@ void Tree::resolveProperties() } else if (function->name() == resetterName) { property->addFunction(function, PropertyNode::Resetter); } else if (function->name() == notifierName) { - property->addFunction(function, PropertyNode::Notifier); + property->addSignal(function, PropertyNode::Notifier); } } } -- cgit v0.12 From 6687a82476a96922f23d4fd3535d4e7354d9cdab Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 14:42:48 +0200 Subject: More coverity warnings removed --- src/corelib/io/qfileinfo_p.h | 4 ++-- src/gui/text/qtextobject.cpp | 10 ---------- src/gui/text/qtextobject_p.h | 2 +- src/gui/text/qtexttable_p.h | 2 +- src/svg/qsvgstyle.cpp | 4 +++- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index d64a5c4..d92090c 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -81,11 +81,11 @@ public: CachedSize =0x08 }; struct Data { inline Data() - : ref(1), fileEngine(0), cache_enabled(1) + : ref(1), fileEngine(0), cache_enabled(1), fileSize(0) { clear(); } inline Data(const Data ©) : ref(1), fileEngine(QAbstractFileEngine::create(copy.fileName)), - fileName(copy.fileName), cache_enabled(copy.cache_enabled) + fileName(copy.fileName), cache_enabled(copy.cache_enabled), fileSize(copy.fileSize) { clear(); } inline ~Data() { delete fileEngine; } inline void clearFlags() { diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 98c92eb..5dc0c48 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -412,11 +412,6 @@ QTextFrameLayoutData::~QTextFrameLayoutData() QTextFrame::QTextFrame(QTextDocument *doc) : QTextObject(*new QTextFramePrivate(doc), doc) { - Q_D(QTextFrame); - d->fragment_start = 0; - d->fragment_end = 0; - d->parentFrame = 0; - d->layoutData = 0; } // ### DOC: What does this do to child frames? @@ -435,11 +430,6 @@ QTextFrame::~QTextFrame() QTextFrame::QTextFrame(QTextFramePrivate &p, QTextDocument *doc) : QTextObject(p, doc) { - Q_D(QTextFrame); - d->fragment_start = 0; - d->fragment_end = 0; - d->parentFrame = 0; - d->layoutData = 0; } /*! diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h index e862b30..22034c8 100644 --- a/src/gui/text/qtextobject_p.h +++ b/src/gui/text/qtextobject_p.h @@ -94,7 +94,7 @@ class QTextFramePrivate : public QTextObjectPrivate Q_DECLARE_PUBLIC(QTextFrame) public: QTextFramePrivate(QTextDocument *doc) - : QTextObjectPrivate(doc) + : QTextObjectPrivate(doc), fragment_start(0), fragment_end(0), parentFrame(0), layoutData(0) { } virtual void fragmentAdded(const QChar &type, uint fragment); diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h index 4dd52c7..7783b5d 100644 --- a/src/gui/text/qtexttable_p.h +++ b/src/gui/text/qtexttable_p.h @@ -62,7 +62,7 @@ class QTextTablePrivate : public QTextFramePrivate { Q_DECLARE_PUBLIC(QTextTable) public: - QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(0), nRows(0), dirty(true), blockFragmentUpdates(false) {} + QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(0), nRows(0), nCols(0), dirty(true), blockFragmentUpdates(false) {} ~QTextTablePrivate(); static QTextTable *createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat); diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index 820f716..1ecf870 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -90,6 +90,7 @@ QSvgFillStyle::QSvgFillStyle(const QBrush &brush) , m_fillRule(Qt::WindingFill) , m_fillOpacitySet(false) , m_fillOpacity(1.0) + , m_oldOpacity(0) , m_gradientResolved(true) , m_fillSet(true) { @@ -101,6 +102,7 @@ QSvgFillStyle::QSvgFillStyle(QSvgStyleProperty *style) , m_fillRule(Qt::WindingFill) , m_fillOpacitySet(false) , m_fillOpacity(1.0) + , m_oldOpacity(0) , m_gradientResolved(true) , m_fillSet(style != 0) { @@ -858,7 +860,7 @@ QSvgStyleProperty::Type QSvgAnimateColor::type() const } QSvgOpacityStyle::QSvgOpacityStyle(qreal opacity) - : m_opacity(opacity) + : m_opacity(opacity), m_oldOpacity(0) { } -- cgit v0.12 From 9e144490bfa059050f8b90645db80b1fd45fd2b1 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 15:08:14 +0200 Subject: Fix a crash in the destruction of QListView --- src/gui/itemviews/qlistview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 3ab3204..b055d32 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1974,8 +1974,10 @@ QListViewPrivate::QListViewPrivate() QListViewPrivate::~QListViewPrivate() { - delete staticListView; - delete dynamicListView; + if (viewMode == QListView::ListMode) + delete staticListView; + else + delete dynamicListView; } void QListViewPrivate::clear() -- cgit v0.12 From 4929da8ad0a43220c3cbd2d9f11db4c535028243 Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 17 Aug 2009 15:11:32 +0200 Subject: Add some more exception around to clucene index writer. Reviewed-by: ck --- .../lib/qhelpsearchindexwriter_clucene.cpp | 78 ++++++++++++++++------ .../lib/qhelpsearchindexwriter_clucene_p.h | 2 + 2 files changed, 60 insertions(+), 20 deletions(-) diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp index 6f7c035..4651d2e 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp @@ -590,15 +590,24 @@ void QHelpSearchIndexWriter::updateIndex(const QString &collectionFile, void QHelpSearchIndexWriter::optimizeIndex() { - if (QCLuceneIndexReader::indexExists(m_indexFilesFolder)) { - if (QCLuceneIndexReader::isLocked(m_indexFilesFolder)) - return; - - QCLuceneStandardAnalyzer analyzer; - QCLuceneIndexWriter writer(m_indexFilesFolder, analyzer, false); - writer.optimize(); - writer.close(); +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + if (QCLuceneIndexReader::indexExists(m_indexFilesFolder)) { + if (QCLuceneIndexReader::isLocked(m_indexFilesFolder)) + return; + + QCLuceneStandardAnalyzer analyzer; + QCLuceneIndexWriter writer(m_indexFilesFolder, analyzer, false); + writer.optimize(); + writer.close(); + } +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("Full Text Search, could not optimize index."); + return; } +#endif } void QHelpSearchIndexWriter::run() @@ -720,21 +729,30 @@ void QHelpSearchIndexWriter::run() } #if !defined(QT_NO_EXCEPTIONS) } catch (...) { - qWarning("Full Text Search, could not create index writer in '%s'.", qPrintable(indexPath)); + qWarning("Full Text Search, could not create index writer in '%s'.", + qPrintable(indexPath)); return; } #endif - writer->setMergeFactor(100); - writer->setMinMergeDocs(1000); - writer->setMaxFieldLength(QCLuceneIndexWriter::DEFAULT_MAX_FIELD_LENGTH); +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + writer->setMergeFactor(100); + writer->setMinMergeDocs(1000); + writer->setMaxFieldLength(QCLuceneIndexWriter::DEFAULT_MAX_FIELD_LENGTH); +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("Full Text Search, could not set writer properties."); + return; + } +#endif QStringList namespaces; foreach(const QString &namespaceName, registeredDocs) { mutexLocker.relock(); if (m_cancel) { - writer->close(); - delete writer; + closeIndexWriter(writer); emit indexingFinished(); return; } @@ -777,8 +795,7 @@ void QHelpSearchIndexWriter::run() mutexLocker.unlock(); } - writer->close(); - delete writer; + closeIndexWriter(writer); mutexLocker.relock(); if (!m_cancel) { @@ -813,15 +830,23 @@ bool QHelpSearchIndexWriter::addDocuments(const QList docFiles, foreach(const QUrl &url, docFiles) { QCLuceneDocument document; DocumentHelper helper(url.toString(), engine.fileData(url)); - if (helper.addFieldsToDocument(&document, namespaceName, attrList)) - writer->addDocument(document, analyzer); - + if (helper.addFieldsToDocument(&document, namespaceName, attrList)) { +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + writer->addDocument(document, analyzer); +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("Full Text Search, could not properly add documents."); + return false; + } +#endif + } locker.relock(); if (m_cancel) return false; locker.unlock(); } - return true; } @@ -861,6 +886,19 @@ QList QHelpSearchIndexWriter::indexableFiles(QHelpEngineCore *helpEngine, return docFiles; } +void QHelpSearchIndexWriter::closeIndexWriter(QCLuceneIndexWriter *writer) +{ +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + writer->close(); + delete writer; +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("Full Text Search, could not properly close index writer."); + } +#endif +} } // namespace clucene } // namespace fulltextsearch diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h b/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h index e9a917b..d4bb755 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h @@ -104,6 +104,8 @@ private: QList indexableFiles(QHelpEngineCore *helpEngine, const QString &namespaceName, const QStringList &attributes) const; + void closeIndexWriter(QCLuceneIndexWriter *writer); + private: QMutex mutex; QWaitCondition waitCondition; -- cgit v0.12