summaryrefslogtreecommitdiffstats
path: root/examples/richtext/syntaxhighlighter
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:18:55 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:18:55 (GMT)
commite5fcad302d86d316390c6b0f62759a067313e8a9 (patch)
treec2afbf6f1066b6ce261f14341cf6d310e5595bc1 /examples/richtext/syntaxhighlighter
downloadQt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2
Long live Qt 4.5!
Diffstat (limited to 'examples/richtext/syntaxhighlighter')
-rw-r--r--examples/richtext/syntaxhighlighter/highlighter.cpp148
-rw-r--r--examples/richtext/syntaxhighlighter/highlighter.h85
-rw-r--r--examples/richtext/syntaxhighlighter/main.cpp53
-rw-r--r--examples/richtext/syntaxhighlighter/mainwindow.cpp130
-rw-r--r--examples/richtext/syntaxhighlighter/mainwindow.h76
-rw-r--r--examples/richtext/syntaxhighlighter/syntaxhighlighter.pro17
6 files changed, 509 insertions, 0 deletions
diff --git a/examples/richtext/syntaxhighlighter/highlighter.cpp b/examples/richtext/syntaxhighlighter/highlighter.cpp
new file mode 100644
index 0000000..5d9939d
--- /dev/null
+++ b/examples/richtext/syntaxhighlighter/highlighter.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "highlighter.h"
+
+//! [0]
+Highlighter::Highlighter(QTextDocument *parent)
+ : QSyntaxHighlighter(parent)
+{
+ HighlightingRule rule;
+
+ keywordFormat.setForeground(Qt::darkBlue);
+ keywordFormat.setFontWeight(QFont::Bold);
+ QStringList keywordPatterns;
+ keywordPatterns << "\\bchar\\b" << "\\bclass\\b" << "\\bconst\\b"
+ << "\\bdouble\\b" << "\\benum\\b" << "\\bexplicit\\b"
+ << "\\bfriend\\b" << "\\binline\\b" << "\\bint\\b"
+ << "\\blong\\b" << "\\bnamespace\\b" << "\\boperator\\b"
+ << "\\bprivate\\b" << "\\bprotected\\b" << "\\bpublic\\b"
+ << "\\bshort\\b" << "\\bsignals\\b" << "\\bsigned\\b"
+ << "\\bslots\\b" << "\\bstatic\\b" << "\\bstruct\\b"
+ << "\\btemplate\\b" << "\\btypedef\\b" << "\\btypename\\b"
+ << "\\bunion\\b" << "\\bunsigned\\b" << "\\bvirtual\\b"
+ << "\\bvoid\\b" << "\\bvolatile\\b";
+ foreach (const QString &pattern, keywordPatterns) {
+ rule.pattern = QRegExp(pattern);
+ rule.format = keywordFormat;
+ highlightingRules.append(rule);
+//! [0] //! [1]
+ }
+//! [1]
+
+//! [2]
+ classFormat.setFontWeight(QFont::Bold);
+ classFormat.setForeground(Qt::darkMagenta);
+ rule.pattern = QRegExp("\\bQ[A-Za-z]+\\b");
+ rule.format = classFormat;
+ highlightingRules.append(rule);
+//! [2]
+
+//! [3]
+ singleLineCommentFormat.setForeground(Qt::red);
+ rule.pattern = QRegExp("//[^\n]*");
+ rule.format = singleLineCommentFormat;
+ highlightingRules.append(rule);
+
+ multiLineCommentFormat.setForeground(Qt::red);
+//! [3]
+
+//! [4]
+ quotationFormat.setForeground(Qt::darkGreen);
+ rule.pattern = QRegExp("\".*\"");
+ rule.format = quotationFormat;
+ highlightingRules.append(rule);
+//! [4]
+
+//! [5]
+ functionFormat.setFontItalic(true);
+ functionFormat.setForeground(Qt::blue);
+ rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()");
+ rule.format = functionFormat;
+ highlightingRules.append(rule);
+//! [5]
+
+//! [6]
+ commentStartExpression = QRegExp("/\\*");
+ commentEndExpression = QRegExp("\\*/");
+}
+//! [6]
+
+//! [7]
+void Highlighter::highlightBlock(const QString &text)
+{
+ foreach (const HighlightingRule &rule, highlightingRules) {
+ QRegExp expression(rule.pattern);
+ int index = expression.indexIn(text);
+ while (index >= 0) {
+ int length = expression.matchedLength();
+ setFormat(index, length, rule.format);
+ index = expression.indexIn(text, index + length);
+ }
+ }
+//! [7] //! [8]
+ setCurrentBlockState(0);
+//! [8]
+
+//! [9]
+ int startIndex = 0;
+ if (previousBlockState() != 1)
+ startIndex = commentStartExpression.indexIn(text);
+
+//! [9] //! [10]
+ while (startIndex >= 0) {
+//! [10] //! [11]
+ int endIndex = commentEndExpression.indexIn(text, startIndex);
+ int commentLength;
+ if (endIndex == -1) {
+ setCurrentBlockState(1);
+ commentLength = text.length() - startIndex;
+ } else {
+ commentLength = endIndex - startIndex
+ + commentEndExpression.matchedLength();
+ }
+ setFormat(startIndex, commentLength, multiLineCommentFormat);
+ startIndex = commentStartExpression.indexIn(text, startIndex + commentLength);
+ }
+}
+//! [11]
diff --git a/examples/richtext/syntaxhighlighter/highlighter.h b/examples/richtext/syntaxhighlighter/highlighter.h
new file mode 100644
index 0000000..2774212
--- /dev/null
+++ b/examples/richtext/syntaxhighlighter/highlighter.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HIGHLIGHTER_H
+#define HIGHLIGHTER_H
+
+#include <QSyntaxHighlighter>
+
+#include <QHash>
+#include <QTextCharFormat>
+
+QT_BEGIN_NAMESPACE
+class QTextDocument;
+QT_END_NAMESPACE
+
+//! [0]
+class Highlighter : public QSyntaxHighlighter
+{
+ Q_OBJECT
+
+public:
+ Highlighter(QTextDocument *parent = 0);
+
+protected:
+ void highlightBlock(const QString &text);
+
+private:
+ struct HighlightingRule
+ {
+ QRegExp pattern;
+ QTextCharFormat format;
+ };
+ QVector<HighlightingRule> highlightingRules;
+
+ QRegExp commentStartExpression;
+ QRegExp commentEndExpression;
+
+ QTextCharFormat keywordFormat;
+ QTextCharFormat classFormat;
+ QTextCharFormat singleLineCommentFormat;
+ QTextCharFormat multiLineCommentFormat;
+ QTextCharFormat quotationFormat;
+ QTextCharFormat functionFormat;
+};
+//! [0]
+
+#endif
diff --git a/examples/richtext/syntaxhighlighter/main.cpp b/examples/richtext/syntaxhighlighter/main.cpp
new file mode 100644
index 0000000..fbb822d
--- /dev/null
+++ b/examples/richtext/syntaxhighlighter/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow window;
+ window.resize(640, 512);
+ window.show();
+ return app.exec();
+}
diff --git a/examples/richtext/syntaxhighlighter/mainwindow.cpp b/examples/richtext/syntaxhighlighter/mainwindow.cpp
new file mode 100644
index 0000000..a6312f9
--- /dev/null
+++ b/examples/richtext/syntaxhighlighter/mainwindow.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+//! [0]
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setupFileMenu();
+ setupHelpMenu();
+ setupEditor();
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Syntax Highlighter"));
+}
+//! [0]
+
+void MainWindow::about()
+{
+ QMessageBox::about(this, tr("About Syntax Highlighter"),
+ tr("<p>The <b>Syntax Highlighter</b> example shows how " \
+ "to perform simple syntax highlighting by subclassing " \
+ "the QSyntaxHighlighter class and describing " \
+ "highlighting rules using regular expressions.</p>"));
+}
+
+void MainWindow::newFile()
+{
+ editor->clear();
+}
+
+void MainWindow::openFile(const QString &path)
+{
+ QString fileName = path;
+
+ if (fileName.isNull())
+ fileName = QFileDialog::getOpenFileName(this,
+ tr("Open File"), "", "C++ Files (*.cpp *.h)");
+
+ if (!fileName.isEmpty()) {
+ QFile file(fileName);
+ if (file.open(QFile::ReadOnly | QFile::Text))
+ editor->setPlainText(file.readAll());
+ }
+}
+
+//! [1]
+void MainWindow::setupEditor()
+{
+ QFont font;
+ font.setFamily("Courier");
+ font.setFixedPitch(true);
+ font.setPointSize(10);
+
+ editor = new QTextEdit;
+ editor->setFont(font);
+
+ highlighter = new Highlighter(editor->document());
+
+ QFile file("mainwindow.h");
+ if (file.open(QFile::ReadOnly | QFile::Text))
+ editor->setPlainText(file.readAll());
+}
+//! [1]
+
+void MainWindow::setupFileMenu()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"), this);
+ menuBar()->addMenu(fileMenu);
+
+ fileMenu->addAction(tr("&New"), this, SLOT(newFile()),
+ QKeySequence(tr("Ctrl+N",
+ "File|New")));
+ fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
+ QKeySequence(tr("Ctrl+O",
+ "File|Open")));
+ fileMenu->addAction(tr("E&xit"), qApp, SLOT(quit()),
+ QKeySequence(tr("Ctrl+Q",
+ "File|Exit")));
+}
+
+void MainWindow::setupHelpMenu()
+{
+ QMenu *helpMenu = new QMenu(tr("&Help"), this);
+ menuBar()->addMenu(helpMenu);
+
+ helpMenu->addAction(tr("&About"), this, SLOT(about()));
+ helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
+}
diff --git a/examples/richtext/syntaxhighlighter/mainwindow.h b/examples/richtext/syntaxhighlighter/mainwindow.h
new file mode 100644
index 0000000..12334ab
--- /dev/null
+++ b/examples/richtext/syntaxhighlighter/mainwindow.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "highlighter.h"
+
+QT_BEGIN_NAMESPACE
+class QTextEdit;
+QT_END_NAMESPACE
+
+//! [0]
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+public slots:
+ void about();
+ void newFile();
+ void openFile(const QString &path = QString());
+
+private:
+ void setupEditor();
+ void setupFileMenu();
+ void setupHelpMenu();
+
+ QTextEdit *editor;
+ Highlighter *highlighter;
+};
+//! [0]
+
+#endif
diff --git a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro
new file mode 100644
index 0000000..b861970
--- /dev/null
+++ b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro
@@ -0,0 +1,17 @@
+HEADERS = highlighter.h \
+ mainwindow.h
+SOURCES = highlighter.cpp \
+ mainwindow.cpp \
+ main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/richtext/syntaxhighlighter
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS syntaxhighlighter.pro examples
+sources.path = $$[QT_INSTALL_EXAMPLES]/richtext/syntaxhighlighter
+INSTALLS += target sources
+
+wince*: {
+ addFiles.sources = main.cpp mainwindow.cpp
+ addFiles.path = .
+ DEPLOYMENT += addFiles
+}
PHONON_MMF_DIR/effectfactory.h \ + $$PHONON_MMF_DIR/effectparameter.h \ + $$PHONON_MMF_DIR/environmentalreverb.h \ + $$PHONON_MMF_DIR/loudness.h \ + $$PHONON_MMF_DIR/mediaobject.h \ + $$PHONON_MMF_DIR/mmf_medianode.h \ + $$PHONON_MMF_DIR/stereowidening.h \ + $$PHONON_MMF_DIR/objectdump.h \ + $$PHONON_MMF_DIR/objectdump_symbian.h \ + $$PHONON_MMF_DIR/objecttree.h \ + $$PHONON_MMF_DIR/utils.h \ + $$PHONON_MMF_DIR/videowidget.h + + SOURCES += \ + $$PHONON_MMF_DIR/abstractaudioeffect.cpp \ + $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ + $$PHONON_MMF_DIR/abstractplayer.cpp \ + $$PHONON_MMF_DIR/audioequalizer.cpp \ + $$PHONON_MMF_DIR/audiooutput.cpp \ + $$PHONON_MMF_DIR/audioplayer.cpp \ + $$PHONON_MMF_DIR/abstractvideooutput.cpp \ + $$PHONON_MMF_DIR/abstractvideoplayer.cpp \ + $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/bassboost.cpp \ + $$PHONON_MMF_DIR/dummyplayer.cpp \ + $$PHONON_MMF_DIR/effectfactory.cpp \ + $$PHONON_MMF_DIR/effectparameter.cpp \ + $$PHONON_MMF_DIR/environmentalreverb.cpp \ + $$PHONON_MMF_DIR/loudness.cpp \ + $$PHONON_MMF_DIR/mediaobject.cpp \ + $$PHONON_MMF_DIR/mmf_medianode.cpp \ + $$PHONON_MMF_DIR/stereowidening.cpp \ + $$PHONON_MMF_DIR/objectdump.cpp \ + $$PHONON_MMF_DIR/objectdump_symbian.cpp \ + $$PHONON_MMF_DIR/objecttree.cpp \ + $$PHONON_MMF_DIR/utils.cpp \ + $$PHONON_MMF_DIR/videowidget.cpp + + # Test for whether the build environment supports video rendering to graphics + # surfaces. + symbian:exists($${EPOCROOT}epoc32/include/platform/videoplayer2.h) { + HEADERS += \ + $$PHONON_MMF_DIR/videooutput_surface.h \ + $$PHONON_MMF_DIR/videoplayer_surface.h + SOURCES += \ + $$PHONON_MMF_DIR/videooutput_surface.cpp \ + $$PHONON_MMF_DIR/videoplayer_surface.cpp + DEFINES += PHONON_MMF_VIDEO_SURFACES + } else { + HEADERS += \ + $$PHONON_MMF_DIR/ancestormovemonitor.h \ + $$PHONON_MMF_DIR/videooutput_dsa.h \ + $$PHONON_MMF_DIR/videoplayer_dsa.h + SOURCES += \ + $$PHONON_MMF_DIR/ancestormovemonitor.cpp \ + $$PHONON_MMF_DIR/videooutput_dsa.cpp \ + $$PHONON_MMF_DIR/videoplayer_dsa.cpp \ + } + + LIBS += -lcone + LIBS += -lws32 + + # This is only needed for debug builds, but is always linked against. + LIBS += -lhal + + TARGET.CAPABILITY = all -tcb + + LIBS += -lmediaclientvideo # For CVideoPlayerUtility + LIBS += -lcone # For CCoeEnv + LIBS += -lws32 # For RWindow + LIBS += -lefsrv # For file server + LIBS += -lapgrfx -lapmime # For recognizer + LIBS += -lmmfcontrollerframework # For CMMFMetaDataEntry + LIBS += -lmediaclientaudiostream # For CMdaAudioOutputStream + + # These are for effects. + LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect + + # This is needed for having the .qtplugin file properly created on Symbian. + QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend + + target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend + INSTALLS += target + + include(../../qpluginbase.pri) + + TARGET.UID3=0x2001E629 } - -LIBS += -lcone -LIBS += -lws32 - -# This is only needed for debug builds, but is always linked against. -LIBS += -lhal - -TARGET.CAPABILITY = all -tcb - -LIBS += -lmediaclientvideo # For CVideoPlayerUtility -LIBS += -lcone # For CCoeEnv -LIBS += -lws32 # For RWindow -LIBS += -lefsrv # For file server -LIBS += -lapgrfx -lapmime # For recognizer -LIBS += -lmmfcontrollerframework # For CMMFMetaDataEntry -LIBS += -lmediaclientaudiostream # For CMdaAudioOutputStream - -# These are for effects. -LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect - -# This is needed for having the .qtplugin file properly created on Symbian. -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend - -target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend -INSTALLS += target - -include(../../qpluginbase.pri) - -TARGET.UID3=0x2001E629 - -- cgit v0.12 From 569860f721a30d5caad8ea1b55a3220f7e7f3d56 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 21 Jun 2010 18:52:45 +0200 Subject: Fix null HB_Device** dereference on exit in Harfbuzz GPOS code Fix incorrect usage of _HB_OPEN_Free_Device() in CaretValue cleanup --- src/3rdparty/harfbuzz/src/harfbuzz-gdef.c | 2 +- src/3rdparty/harfbuzz/src/harfbuzz-gpos.c | 26 +++++++++++++---------- src/3rdparty/harfbuzz/src/harfbuzz-open-private.h | 2 +- src/3rdparty/harfbuzz/src/harfbuzz-open.c | 8 +++---- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-gdef.c b/src/3rdparty/harfbuzz/src/harfbuzz-gdef.c index c0c6f2c..966b167 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-gdef.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-gdef.c @@ -462,7 +462,7 @@ static HB_Error Load_CaretValue( HB_CaretValue* cv, static void Free_CaretValue( HB_CaretValue* cv) { if ( cv->CaretValueFormat == 3 ) - _HB_OPEN_Free_Device( &cv->cvf.cvf3.Device ); + _HB_OPEN_Free_Device( cv->cvf.cvf3.Device ); } diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c index 31b9ae1..0236271 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c @@ -433,13 +433,16 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, return HB_Err_Ok; Fail1: - _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE] ); + if ( vr->DeviceTables ) + _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_ADVANCE_DEVICE] ); Fail2: - _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE] ); + if ( vr->DeviceTables ) + _HB_OPEN_Free_Device( vr->DeviceTables[VR_X_ADVANCE_DEVICE] ); Fail3: - _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); + if ( vr->DeviceTables ) + _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); FREE( vr->DeviceTables ); return error; @@ -450,13 +453,13 @@ static void Free_ValueRecord( HB_ValueRecord* vr, HB_UShort format ) { if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE ) - _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE] ); + _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_ADVANCE_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE ) - _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE] ); + _HB_OPEN_Free_Device( vr->DeviceTables[VR_X_ADVANCE_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE ) - _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); + _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) - _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE] ); + _HB_OPEN_Free_Device( vr->DeviceTables[VR_X_PLACEMENT_DEVICE] ); FREE( vr->DeviceTables ); } @@ -688,7 +691,8 @@ static HB_Error Load_Anchor( HB_Anchor* an, return HB_Err_Ok; Fail: - _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] ); + if ( an->af.af3.DeviceTables ) + _HB_OPEN_Free_Device( an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] ); FREE( an->af.af3.DeviceTables ); return error; @@ -697,10 +701,10 @@ Fail: static void Free_Anchor( HB_Anchor* an) { - if ( an->PosFormat == 3 ) + if ( an->PosFormat == 3 && an->af.af3.DeviceTables ) { - _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] ); - _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE] ); + _HB_OPEN_Free_Device( an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] ); + _HB_OPEN_Free_Device( an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE] ); FREE( an->af.af3.DeviceTables ); } } diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-open-private.h b/src/3rdparty/harfbuzz/src/harfbuzz-open-private.h index 65ca453..f1ca278 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-open-private.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-open-private.h @@ -79,7 +79,7 @@ HB_INTERNAL void _HB_OPEN_Free_LookupList( HB_LookupList* ll, HB_INTERNAL void _HB_OPEN_Free_Coverage( HB_Coverage* c ); HB_INTERNAL void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd ); -HB_INTERNAL void _HB_OPEN_Free_Device( HB_Device** d ); +HB_INTERNAL void _HB_OPEN_Free_Device( HB_Device* d ); diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-open.c b/src/3rdparty/harfbuzz/src/harfbuzz-open.c index adc6cec..15cd2c1 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-open.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-open.c @@ -1353,12 +1353,12 @@ _HB_OPEN_Load_Device( HB_Device** device, HB_INTERNAL void -_HB_OPEN_Free_Device( HB_Device** d ) +_HB_OPEN_Free_Device( HB_Device* d ) { - if ( *d ) + if ( d ) { - FREE( (*d)->DeltaValue ); - FREE( *d ); + FREE( d->DeltaValue ); + FREE( d ); } } -- cgit v0.12 From b82ed43086aebb4698a8a52965eeb17349ef1d04 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Mon, 21 Jun 2010 15:11:59 +1000 Subject: Audio(osx); Fix audio format converters. Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudio_mac.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp index 14fee8b..4e17b52 100644 --- a/src/multimedia/audio/qaudio_mac.cpp +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -68,11 +68,11 @@ QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) audioFormat.setChannels(sf.mChannelsPerFrame); audioFormat.setSampleSize(sf.mBitsPerChannel); audioFormat.setCodec(QString::fromLatin1("audio/pcm")); - audioFormat.setByteOrder(sf.mFormatFlags & kLinearPCMFormatFlagIsBigEndian != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); + audioFormat.setByteOrder((sf.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); QAudioFormat::SampleType type = QAudioFormat::UnSignedInt; - if ((sf.mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) != 0) + if ((sf.mFormatFlags & kAudioFormatFlagIsSignedInteger) != 0) type = QAudioFormat::SignedInt; - else if ((sf.mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0) + else if ((sf.mFormatFlags & kAudioFormatFlagIsFloat) != 0) type = QAudioFormat::Float; audioFormat.setSampleType(type); @@ -99,6 +99,9 @@ AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& au case QAudioFormat::Unknown: default: break; } + if (audioFormat.byteOrder() == QAudioFormat::BigEndian) + sf.mFormatFlags |= kAudioFormatFlagIsBigEndian; + return sf; } -- cgit v0.12 From 66d02e4bde0a628978436217032abe555ed77fad Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Mon, 21 Jun 2010 15:18:32 +1000 Subject: Audio(osx); refactor input period conversion Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudioinput_mac_p.cpp | 49 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index b99fe11..5897e75 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -210,6 +210,11 @@ public: return true; } + bool empty() const + { + return position == totalPackets; + } + private: UInt32 totalPackets; UInt32 position; @@ -275,36 +280,32 @@ public: if (m_audioConverter != 0) { QAudioPacketFeeder feeder(m_inputBufferList); - bool wecan = true; int copied = 0; - const int available = m_buffer->free(); - while (err == noErr && wecan) { + while (err == noErr && !feeder.empty()) { QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available); - if (region.second > 0) { - AudioBufferList output; - output.mNumberBuffers = 1; - output.mBuffers[0].mNumberChannels = 1; - output.mBuffers[0].mDataByteSize = region.second; - output.mBuffers[0].mData = region.first; - - UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket; - err = AudioConverterFillComplexBuffer(m_audioConverter, - converterCallback, - &feeder, - &packetSize, - &output, - 0); - - region.second = output.mBuffers[0].mDataByteSize; - copied += region.second; + if (region.second == 0) + break; + + AudioBufferList output; + output.mNumberBuffers = 1; + output.mBuffers[0].mNumberChannels = 1; + output.mBuffers[0].mDataByteSize = region.second; + output.mBuffers[0].mData = region.first; + + UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket; + err = AudioConverterFillComplexBuffer(m_audioConverter, + converterCallback, + &feeder, + &packetSize, + &output, + 0); + region.second = output.mBuffers[0].mDataByteSize; + copied += region.second; - m_buffer->releaseWriteRegion(region); - } - else - wecan = false; + m_buffer->releaseWriteRegion(region); } framesRendered += copied / m_outputFormat.mBytesPerFrame; -- cgit v0.12 From 76c256bdabcc207a6ed70d5b5b62698495548a25 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Tue, 22 Jun 2010 12:01:51 +1000 Subject: Audio(osx); Fix period size calculation. Task-number: QTBUG-8878 Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudiooutput_mac_p.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index 9689101..cc52d90 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -358,17 +358,7 @@ bool QAudioOutputPrivate::open() // Set stream format streamFormat = toAudioStreamBasicDescription(audioFormat); - UInt32 size = sizeof(deviceFormat); - if (AudioUnitGetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &deviceFormat, - &size) != noErr) { - qWarning() << "QAudioOutput: Unable to retrieve device format"; - return false; - } - + UInt32 size = sizeof(streamFormat); if (AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, @@ -392,8 +382,7 @@ bool QAudioOutputPrivate::open() return false; } - periodSizeBytes = (numberOfFrames * streamFormat.mSampleRate / deviceFormat.mSampleRate) * - streamFormat.mBytesPerFrame; + periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; if (internalBufferSize < periodSizeBytes * 2) internalBufferSize = periodSizeBytes * 2; else -- cgit v0.12 From f02bb3b14ab0257a11cb9cde692f87a046c0308b Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Tue, 22 Jun 2010 16:59:08 +1000 Subject: Phonon(qt7); Don't try and display video frames when audio only. Task-number: QTBUG-9068 --- src/3rdparty/phonon/qt7/mediaobject.mm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/phonon/qt7/mediaobject.mm b/src/3rdparty/phonon/qt7/mediaobject.mm index 677640c..ca206bc 100644 --- a/src/3rdparty/phonon/qt7/mediaobject.mm +++ b/src/3rdparty/phonon/qt7/mediaobject.mm @@ -405,20 +405,22 @@ void MediaObject::restartAudioVideoTimers() if (m_audioTimer) killTimer(m_audioTimer); + if (hasVideo()) { #if QT_ALLOW_QUICKTIME // We prefer to use a display link as timer if available, since // it is more steady, and results in better and smoother frame drawing: - startDisplayLink(); - if (!m_displayLink){ + startDisplayLink(); + if (!m_displayLink){ + float fps = m_videoPlayer->staticFps(); + long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001; + m_videoTimer = startTimer(videoUpdateFrequency); + } +#else float fps = m_videoPlayer->staticFps(); long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001; m_videoTimer = startTimer(videoUpdateFrequency); - } -#else - float fps = m_videoPlayer->staticFps(); - long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001; - m_videoTimer = startTimer(videoUpdateFrequency); #endif + } long audioUpdateFrequency = m_audioPlayer->regularTaskFrequency(); m_audioTimer = startTimer(audioUpdateFrequency); -- cgit v0.12 From da024f96bf0969cd0de85389e621a14c3381add8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 22 Jun 2010 09:09:32 +0200 Subject: Make sure ValueRecord's DeviceTables are cleaned up on failure Cleanup was a missing for the case where loading an X placement device table failed. --- src/3rdparty/harfbuzz/src/harfbuzz-gpos.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c index 0236271..d6f9207 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c @@ -273,7 +273,7 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) { if ( ACCESS_Frame( 2L ) ) - return error; + goto Fail4; new_offset = GET_UShort(); @@ -287,7 +287,7 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, if ( FILE_Seek( new_offset ) || ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE], stream ) ) != HB_Err_Ok ) - return error; + goto Fail4; (void)FILE_Seek( cur_offset ); } } @@ -444,6 +444,7 @@ Fail3: if ( vr->DeviceTables ) _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); +Fail4: FREE( vr->DeviceTables ); return error; } -- cgit v0.12 From bae2219587a8c1a4c922d1cde51616e3ea1df370 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 22 Jun 2010 09:37:34 +0200 Subject: Clean up HB_Anchor's DeviceTables on failure when loading format 3 --- src/3rdparty/harfbuzz/src/harfbuzz-gpos.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c index d6f9207..a216005 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c @@ -637,7 +637,7 @@ static HB_Error Load_Anchor( HB_Anchor* an, if ( FILE_Seek( new_offset ) || ( error = _HB_OPEN_Load_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE], stream ) ) != HB_Err_Ok ) - return error; + goto Fail2; (void)FILE_Seek( cur_offset ); } @@ -695,6 +695,7 @@ Fail: if ( an->af.af3.DeviceTables ) _HB_OPEN_Free_Device( an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] ); +Fail2: FREE( an->af.af3.DeviceTables ); return error; } -- cgit v0.12 From b4dd04f50b2e275ef9f8e643f33143d20a436203 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Jun 2010 12:18:13 +0200 Subject: Updated Harfbuzz from git+ssh://git.freedesktop.org/git/harfbuzz to f0dcb906fe56b5dc06aa305b6cfc821d5dd25a28 * Import f0dcb906fe56b5dc06aa305b6cfc821d5dd25a28 which fixes a crash with certain fonts. --- src/3rdparty/harfbuzz/src/harfbuzz-open.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-open.c b/src/3rdparty/harfbuzz/src/harfbuzz-open.c index 15cd2c1..f12f5b7 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-open.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-open.c @@ -1403,12 +1403,11 @@ _HB_OPEN_Get_Device( HB_Device* d, HB_UShort size, HB_Short* value ) { - HB_UShort byte, bits, mask, f, s; + HB_UShort byte, bits, mask, s; - f = d->DeltaFormat; - - if ( d->DeltaValue && size >= d->StartSize && size <= d->EndSize ) + if ( d && d->DeltaValue && size >= d->StartSize && size <= d->EndSize ) { + HB_UShort f = d->DeltaFormat; s = size - d->StartSize; byte = d->DeltaValue[s >> ( 4 - f )]; bits = byte >> ( 16 - ( ( s % ( 1 << ( 4 - f ) ) + 1 ) << f ) ); -- cgit v0.12 From 1aee8f71da584525eea569690110ca2ed471c5ae Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 23 Jun 2010 07:44:10 +0200 Subject: Ensure that compiling with the no debug/warning output defines works The defines that can be used are QT_NO_DEBUG_OUTPUT and QT_NO_WARNING_OUTPUT in order to turn off qDebug and qWarning output. Reviewed-by: cduclos Reviewed-by: Markus Goetz --- src/gui/accessible/qaccessible_mac_cocoa.mm | 4 ++++ src/network/access/qftp.cpp | 2 +- src/opengl/qgl_p.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/accessible/qaccessible_mac_cocoa.mm b/src/gui/accessible/qaccessible_mac_cocoa.mm index 1688404..ada927e 100644 --- a/src/gui/accessible/qaccessible_mac_cocoa.mm +++ b/src/gui/accessible/qaccessible_mac_cocoa.mm @@ -58,11 +58,15 @@ QT_BEGIN_NAMESPACE //#define MAC_ACCESSIBILTY_DEVELOPER_MODE +#ifndef QT_NO_DEBUG_STREAM #ifdef MAC_ACCESSIBILTY_DEVELOPER_MODE #define MAC_ACCESSIBILTY_DEBUG QT_PREPEND_NAMESPACE(qDebug) #else #define MAC_ACCESSIBILTY_DEBUG if (0) QT_PREPEND_NAMESPACE(qDebug) #endif +#else +#define MAC_ACCESSIBILTY_DEBUG if (0) QT_PREPEND_NAMESPACE(QNoDebug) +#endif typedef QMap QMacAccessibiltyRoleMap; Q_GLOBAL_STATIC(QMacAccessibiltyRoleMap, qMacAccessibiltyRoleMap); diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 7f6df0a..97219f4 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -2311,7 +2311,7 @@ void QFtpPrivate::_q_piError(int errorCode, const QString &text) Q_Q(QFtp); if (pending.isEmpty()) { - qWarning() << "QFtpPrivate::_q_piError was called without pending command!"; + qWarning("QFtpPrivate::_q_piError was called without pending command!"); return; } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 191131e..4facb65 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -114,7 +114,7 @@ QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE # ifdef old_qDebug # undef qDebug -# define qDebug QT_QDEBUG_MACRO +# define qDebug QT_NO_QDEBUG_MACRO # undef old_qDebug # endif class QMacWindowChangeEvent; -- cgit v0.12 From 19ee05c994af7d0c55ec9e4a44e7e485eafc8c66 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 23 Jun 2010 09:20:54 +0100 Subject: Updated UIDs for spectrum demo Resolving UID clash with other example apps Reviewed-by: Miikka Heikkinen --- demos/spectrum/3rdparty/fftreal/fftreal.pro | 2 +- demos/spectrum/app/app.pro | 2 +- demos/spectrum/spectrum.pro | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/demos/spectrum/3rdparty/fftreal/fftreal.pro b/demos/spectrum/3rdparty/fftreal/fftreal.pro index 8d9f46e..6801b42 100644 --- a/demos/spectrum/3rdparty/fftreal/fftreal.pro +++ b/demos/spectrum/3rdparty/fftreal/fftreal.pro @@ -29,7 +29,7 @@ DEFINES += FFTREAL_LIBRARY symbian { # Provide unique ID for the generated binary, required by Symbian OS - TARGET.UID3 = 0xA000E3FB + TARGET.UID3 = 0xA000E403 TARGET.CAPABILITY = UserEnvironment } else { macx { diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro index db9a144..22ee3b1 100644 --- a/demos/spectrum/app/app.pro +++ b/demos/spectrum/app/app.pro @@ -48,7 +48,7 @@ symbian { TARGET.CAPABILITY = UserEnvironment # Provide unique ID for the generated binary, required by Symbian OS - TARGET.UID3 = 0xA000E3FA + TARGET.UID3 = 0xA000E402 } diff --git a/demos/spectrum/spectrum.pro b/demos/spectrum/spectrum.pro index a8f09de..12bdec1 100644 --- a/demos/spectrum/spectrum.pro +++ b/demos/spectrum/spectrum.pro @@ -21,7 +21,7 @@ symbian { include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) # UID for the SIS file - TARGET.UID3 = 0xA000E3FA + TARGET.UID3 = 0xA000E402 } sources.files = README.txt spectrum.pri spectrum.pro TODO.txt -- cgit v0.12 From 50846a87e82fa94753bd369d03c9ba00108a12de Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 23 Jun 2010 12:20:29 +0100 Subject: Allow TLW translucency on Symbian without Qt::FramelessWindowHint This flag is Windows-specific, and should not be required on other platforms. Reviewed-by: Jason Barron --- src/gui/kernel/qwidget_s60.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 86b858d..46f3254 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -738,9 +738,6 @@ void QWidgetPrivate::s60UpdateIsOpaque() if (!q->testAttribute(Qt::WA_WState_Created) || !q->testAttribute(Qt::WA_TranslucentBackground)) return; - if ((data.window_flags & Qt::FramelessWindowHint) == 0) - return; - RWindow *const window = static_cast(q->effectiveWinId()->DrawableWindow()); #ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE -- cgit v0.12 From 318e1b3a78bc7114bacdce8bec019228d8ecab19 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 23 Jun 2010 14:58:01 +0200 Subject: Doc: Fixed whitespace issues and added missing files to lists. Reviewed-by: Trust Me --- tools/qdoc3/test/qt-build-docs.qdocconf | 76 +++++++++++++-------------- tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf | 67 +++++++++++++---------- tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf | 14 ++++- 3 files changed, 90 insertions(+), 67 deletions(-) diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index 09cbc45..140b81f 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -22,43 +22,43 @@ qhp.Qt.indexTitle = Qt Reference Documentation # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - images/bg_l.png \ - images/bg_l_blank.png \ - images/bg_r.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_gt.png \ - images/bullet_dn.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/feedbackground.png \ - images/horBar.png \ - images/page.png \ - images/page_bg.png \ - images/sprites-combined.png \ - images/arrow-down.png \ - images/spinner.gif \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - images/coloreditorfactoryimage.png \ - images/dynamiclayouts-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - scripts/shBrushCpp.js \ - scripts/shCore.js \ - scripts/shLegacy.js \ - scripts/narrow.js \ - scripts/superfish.js \ - style/shCore.css \ - style/shThemeDefault.css \ - style/narrow.css \ - style/superfish.css \ - style/superfish_skin.css \ - style/OfflineStyle.css \ - style/style_ie6.css \ - style/style_ie7.css \ - style/style_ie8.css \ - style/style.css + images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/arrow-down.png \ + images/spinner.gif \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + scripts/shBrushCpp.js \ + scripts/shCore.js \ + scripts/shLegacy.js \ + scripts/narrow.js \ + scripts/superfish.js \ + style/shCore.css \ + style/shThemeDefault.css \ + style/narrow.css \ + style/superfish.css \ + style/superfish_skin.css \ + style/OfflineStyle.css \ + style/style_ie6.css \ + style/style_ie7.css \ + style/style_ie8.css \ + style/style.css @@ -141,7 +141,7 @@ exampledirs = $QT_SOURCE_TREE/doc/src \ imagedirs = $QT_SOURCE_TREE/doc/src/images \ $QT_SOURCE_TREE/examples \ $QT_SOURCE_TREE/doc/src/declarative/pics \ - $QT_SOURCE_TREE/doc/src/template/images + $QT_SOURCE_TREE/doc/src/template/images outputdir = $QT_BUILD_TREE/doc/html tagfile = $QT_BUILD_TREE/doc/html/qt.tags base = file:$QT_BUILD_TREE/doc/html diff --git a/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf b/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf index e517b33..7701cae 100644 --- a/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf @@ -30,33 +30,43 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - images/bg_l.png \ - images/bg_l_blank.png \ - images/bg_r.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_gt.png \ - images/bullet_dn.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/feedbackground.png \ - images/horBar.png \ - images/page.png \ - images/page_bg.png \ - images/sprites-combined.png \ - images/arrow-down.png \ - images/spinner.gif \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - images/coloreditorfactoryimage.png \ - images/dynamiclayouts-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/OfflineStyle.css \ - style/style_ie6.css \ - style/style_ie7.css \ - style/style_ie8.css \ - style/style.css + images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/arrow-down.png \ + images/spinner.gif \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + scripts/shBrushCpp.js \ + scripts/shCore.js \ + scripts/shLegacy.js \ + scripts/narrow.js \ + scripts/superfish.js \ + style/shCore.css \ + style/shThemeDefault.css \ + style/narrow.css \ + style/superfish.css \ + style/superfish_skin.css \ + style/OfflineStyle.css \ + style/style_ie6.css \ + style/style_ie7.css \ + style/style_ie8.css \ + style/style.css language = Cpp @@ -102,7 +112,8 @@ exampledirs = $QT_SOURCE_TREE/doc/src \ imagedirs = $QT_SOURCE_TREE/doc/src/ja_JP/images \ $QT_SOURCE_TREE/doc/src/images \ $QT_SOURCE_TREE/examples \ - $QT_SOURCE_TREE/doc/src/template/images + $QT_SOURCE_TREE/doc/src/declarative/pics \ + $QT_SOURCE_TREE/doc/src/template/images outputdir = $QT_BUILD_TREE/doc/html_ja_JP tagfile = $QT_BUILD_TREE/doc/html_ja_JP/qt.tags base = file:$QT_BUILD_TREE/doc/html_ja_JP diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf index 909a2d4..be459d8 100644 --- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf @@ -52,6 +52,17 @@ qhp.Qt.extraFiles = index.html \ images/dynamiclayouts-example.png \ scripts/functions.js \ scripts/jquery.js \ + scripts/shBrushCpp.js \ + scripts/shCore.js \ + scripts/shLegacy.js \ + scripts/narrow.js \ + scripts/superfish.js \ + style/shCore.css \ + style/shThemeDefault.css \ + style/narrow.css \ + style/superfish.css \ + style/superfish_skin.css \ + style/OfflineStyle.css \ style/style_ie6.css \ style/style_ie7.css \ style/style_ie8.css \ @@ -99,7 +110,8 @@ exampledirs = $QT_SOURCE_TREE/doc/src \ $QT_SOURCE_TREE/src/3rdparty/webkit/WebKit/qt/docs imagedirs = $QT_SOURCE_TREE/doc/src/images \ $QT_SOURCE_TREE/examples \ - $QT_SOURCE_TREE/doc/src/template/images + $QT_SOURCE_TREE/doc/src/declarative/pics \ + $QT_SOURCE_TREE/doc/src/template/images outputdir = $QT_BUILD_TREE/doc/html_zh_CN tagfile = $QT_BUILD_TREE/doc/html_zh_CN/qt.tags base = file:$QT_BUILD_TREE/doc/html_zh_CN -- cgit v0.12 From 3d2d0eb76e7d7a86065b74bc1c0a5346b8d7194d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 Jun 2010 15:35:41 +0200 Subject: Updated WebKit to b3589e88fb8d581fb523578763831109f914dc2e * Build fixes for package builds * Fix build with QT_NO_COMBOBOX * Upstream David's doc fix --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 9 +++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 2 ++ src/3rdparty/webkit/WebKit/qt/ChangeLog | 28 ++++++++++++++++++++++ .../WebKit/qt/WebCoreSupport/ChromeClientQt.cpp | 2 +- .../webkit/WebKit/qt/declarative/declarative.pro | 3 +++ .../webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc | 4 ++-- 8 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 1eb0d78..21b75f0 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -45d1c9149ef8940081fa8dd35854d2b95ebaf3cd +b3589e88fb8d581fb523578763831109f914dc2e diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 1a343eb..57c1cf6 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 45d1c9149ef8940081fa8dd35854d2b95ebaf3cd + b3589e88fb8d581fb523578763831109f914dc2e diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index fd259e0..687b76b 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,12 @@ +2010-06-22 Simon Hausmann + + Unreviewed Qt/Symbian build fix. + + Fix "make clean" to not try to execute clean commands for + the extra targets we use to simulate "make install". + + * WebCore.pro: Use no_clean in CONFIG of extra compilers. + 2010-06-21 Balazs Kelemen Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index e0b4905..f0e41bc 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2866,6 +2866,7 @@ HEADERS += $$WEBKIT_API_HEADERS # INSTALLS is not implemented in qmake's s60 generators, copy headers manually inst_headers.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT} inst_headers.input = WEBKIT_INSTALL_HEADERS + inst_headers.CONFIG = no_clean !isEmpty(INSTALL_HEADERS): inst_headers.output = $$INSTALL_HEADERS/QtWebKit/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} else: inst_headers.output = $$[QT_INSTALL_HEADERS]/QtWebKit/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} @@ -2875,6 +2876,7 @@ HEADERS += $$WEBKIT_API_HEADERS inst_modfile.commands = $$inst_headers.commands inst_modfile.input = moduleFile inst_modfile.output = $$[QMAKE_MKSPECS]/modules + inst_modfile.CONFIG = no_clean QMAKE_EXTRA_COMPILERS += inst_modfile diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 0e73680..050b1c1 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,31 @@ +2010-06-23 Alessandro Portale + + Reviewed by Simon Hausmann. + + [Qt] Provide the Webkit Qml plugin with a UID3 on Symbian + + ...otherwise we cannot Symbian sign it. + + * declarative/declarative.pro: + +2010-06-23 Simon Hausmann + + Unreviewed Qt package build fix. + + When building without build-webkit, set OUTPUT_DIR if necessary, like + in the other .pro files. + + * declarative/declarative.pro: + +2010-06-22 Tasuku Suzuki + + Reviewed by Simon Hausmann. + + [Qt] Fix compilation with QT_NO_COMBOBOX. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::createSelectPopup): + 2010-06-11 Jocelyn Turcotte Reviewed by nobody, build fix. diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index 7d1c794..e253161 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -576,7 +576,7 @@ QtAbstractWebPopup* ChromeClientQt::createSelectPopup() #elif !defined(QT_NO_COMBOBOX) return new QtFallbackWebPopup; #else - return result; + return 0; #endif } diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro index 122d90a..c75bbce 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro +++ b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro @@ -6,6 +6,8 @@ CONFIG += qt plugin win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release +isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../.. + QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir copy2build.input = QMLDIRFILE CONFIG(QTDIR_build) { @@ -64,6 +66,7 @@ qmldir.files += $$PWD/qmldir qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH symbian:{ + TARGET.UID3 = 0x20021321 load(data_caging_paths) include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc index c2a38fd..fa93293 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc @@ -8,7 +8,7 @@ The QtWebKit bridge is a mechanism that extends WebKit's JavaScript environment to access native objects that are represented as \l{QObject}s. It takes advantage of the \l{QObject} introspection, - a part of the \l{Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, + a part of the \l{Qt Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, for example \l{QObject} properties map directly to JavaScript properties. For example, both JavaScript and QObjects have properties: a construct that represent a getter/setter @@ -24,7 +24,7 @@ applications. For example, an application that contains a media-player, playlist manager, and music store. The playlist manager is usually best authored as a classic desktop application, with the native-looking robust \l{QWidget}s helping with producing that application. - The media-player control, which usually looks custom, can be written using the \l{Graphics View framework} + The media-player control, which usually looks custom, can be written using \l{The Graphics View framework} or with in a declarative way with \l{QtDeclarative}. The music store, which shows dynamic content from the internet and gets modified rapidly, is best authored in HTML and maintained on the server. -- cgit v0.12 From fdc0d441e1c1331fb639e5d5f59daf3fb22a7e24 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 24 Jun 2010 01:49:52 +0200 Subject: Make QtFontFamily::symbol_checked a bitfield. Reviewed-by: Benjamin Poulain --- src/gui/text/qfontdatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 139139f..e6c36a4 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -413,7 +413,7 @@ struct QtFontFamily bool fixedPitchComputed : 1; #endif #ifdef Q_WS_X11 - bool symbol_checked; + bool symbol_checked : 1; #endif QString name; -- cgit v0.12 From 793fbbbf5ae3860b5091c760b3cd0d467369cc1a Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 13:22:32 +1000 Subject: Cherry pick fix for QTMOBILITY-240 from Qt Mobility. c84a6d828bcb7f66d1ac06e1a7a84c5a8ba9cec4 --- .../bearer/symbian/qnetworksession_impl.cpp | 60 ++++++++++----- src/plugins/bearer/symbian/symbianengine.cpp | 90 ++++++++++++---------- 2 files changed, 88 insertions(+), 62 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index e08d135..20e13d2 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -694,8 +694,17 @@ void QNetworkSessionPrivateImpl::PreferredCarrierAvailable(TAccessPointInfo aOld SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(configs[i])); - if (symbianConfig->numericIdentifier() == aNewAPInfo.AccessPoint()) - emit preferredConfigurationChanged(configs[i], aIsSeamless); + if (symbianConfig->numericIdentifier() == aNewAPInfo.AccessPoint()) { + // Any slot connected to the signal might throw an std::exception, + // which must not propagate into Symbian code (this function is a callback + // from platform). We could convert exception to a symbian Leave, but since the + // prototype of this function bans this (no trailing 'L'), we just catch + // and drop. + QT_TRY { + emit preferredConfigurationChanged(configs[i], aIsSeamless); + } + QT_CATCH (std::exception&) {} + } } } else { migrate(); @@ -705,7 +714,10 @@ void QNetworkSessionPrivateImpl::PreferredCarrierAvailable(TAccessPointInfo aOld void QNetworkSessionPrivateImpl::NewCarrierActive(TAccessPointInfo /*aNewAPInfo*/, TBool /*aIsSeamless*/) { if (iALREnabled > 0) { - emit newConfigurationActivated(); + QT_TRY { + emit newConfigurationActivated(); + } + QT_CATCH (std::exception&) {} } else { accept(); } @@ -727,18 +739,24 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - syncStateWithInterface(); - // In some cases IAP is still in Connected state when - // syncStateWithInterface(); is called - // => Following call makes sure that Session state - // changes immediately to Disconnected. - newState(QNetworkSession::Disconnected); - emit closed(); + QT_TRY { + syncStateWithInterface(); + // In some cases IAP is still in Connected state when + // syncStateWithInterface(); is called + // => Following call makes sure that Session state + // changes immediately to Disconnected. + newState(QNetworkSession::Disconnected); + emit closed(); + } + QT_CATCH (std::exception&) {} } else if (iStoppedByUser) { // If the user of this session has called the stop() and // configuration is based on internet SNAP, this needs to be // done here because platform might roam. - newState(QNetworkSession::Disconnected); + QT_TRY { + newState(QNetworkSession::Disconnected); + } + QT_CATCH (std::exception&) {} } } #endif @@ -978,12 +996,12 @@ void QNetworkSessionPrivateImpl::RunL() if (error != KErrNone) { isOpen = false; iError = QNetworkSession::UnknownSessionError; - emit QNetworkSessionPrivate::error(iError); + QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - syncStateWithInterface(); + QT_TRYCATCH_LEAVING(syncStateWithInterface()); return; } @@ -1010,8 +1028,10 @@ void QNetworkSessionPrivateImpl::RunL() startTime = QDateTime::currentDateTime(); - newState(QNetworkSession::Connected); - emit quitPendingWaitsForOpened(); + QT_TRYCATCH_LEAVING({ + newState(QNetworkSession::Connected); + emit quitPendingWaitsForOpened(); + }); } break; case KErrNotFound: // Connection failed @@ -1019,12 +1039,12 @@ void QNetworkSessionPrivateImpl::RunL() activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::InvalidConfigurationError; - emit QNetworkSessionPrivate::error(iError); + QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - syncStateWithInterface(); + QT_TRYCATCH_LEAVING(syncStateWithInterface()); break; case KErrCancel: // Connection attempt cancelled case KErrAlreadyExists: // Connection already exists @@ -1038,12 +1058,12 @@ void QNetworkSessionPrivateImpl::RunL() } else { iError = QNetworkSession::UnknownSessionError; } - emit QNetworkSessionPrivate::error(iError); + QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - syncStateWithInterface(); + QT_TRYCATCH_LEAVING(syncStateWithInterface()); break; } } @@ -1364,7 +1384,7 @@ void ConnectionProgressNotifier::DoCancel() void ConnectionProgressNotifier::RunL() { if (iStatus == KErrNone) { - iOwner.handleSymbianConnectionStatusChange(iProgress().iStage, iProgress().iError); + QT_TRYCATCH_LEAVING(iOwner.handleSymbianConnectionStatusChange(iProgress().iStage, iProgress().iError)); SetActive(); iConnection.ProgressNotification(iProgress, iStatus); diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index ab1ba28..3d462ee 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -272,7 +272,11 @@ void SymbianEngine::updateConfigurationsL() accessPointConfigurations.insert(ptr->id, ptr); mutex.unlock(); - emit configurationAdded(ptr); + // Emit configuration added. Connected slots may throw execptions + // which propagate here --> must be converted to leaves (standard + // std::exception would cause any TRAP trapping this function to terminate + // program). + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); } } @@ -293,10 +297,9 @@ void SymbianEngine::updateConfigurationsL() knownSnapConfigs.removeOne(ident); } else { SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; - CleanupStack::PushL(cpPriv); HBufC *pName = destination.NameLC(); - cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length()); + QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); CleanupStack::PopAndDestroy(pName); pName = NULL; @@ -313,10 +316,8 @@ void SymbianEngine::updateConfigurationsL() snapConfigurations.insert(ident, ptr); mutex.unlock(); - emit configurationAdded(ptr); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); - - CleanupStack::Pop(cpPriv); } QNetworkConfigurationPrivatePointer privSNAP = snapConfigurations.value(ident); @@ -336,7 +337,7 @@ void SymbianEngine::updateConfigurationsL() accessPointConfigurations.insert(ptr->id, ptr); mutex.unlock(); - emit configurationAdded(ptr); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); QMutexLocker configLocker(&privSNAP->mutex); @@ -390,7 +391,7 @@ void SymbianEngine::updateConfigurationsL() accessPointConfigurations.insert(ident, ptr); mutex.unlock(); - emit configurationAdded(ptr); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); } else { delete cpPriv; @@ -400,7 +401,7 @@ void SymbianEngine::updateConfigurationsL() } CleanupStack::PopAndDestroy(pDbTView); #endif - updateActiveAccessPoints(); + QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); foreach (const QString &oldIface, knownConfigs) { //remove non existing IAP @@ -408,6 +409,7 @@ void SymbianEngine::updateConfigurationsL() mutex.unlock(); emit configurationRemoved(ptr); + QT_TRYCATCH_LEAVING(emit configurationRemoved(ptr)); mutex.lock(); // Remove non existing IAP from SNAPs @@ -431,6 +433,7 @@ void SymbianEngine::updateConfigurationsL() mutex.unlock(); emit configurationRemoved(ptr); + QT_TRYCATCH_LEAVING(emit configurationRemoved(ptr)); mutex.lock(); } @@ -445,14 +448,12 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( RCmConnectionMethod& connectionMethod) { SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; - CleanupStack::PushL(cpPriv); - TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); QString ident = QString::number(qHash(iapId)); HBufC *pName = connectionMethod.GetStringAttributeL(CMManager::ECmName); CleanupStack::PushL(pName); - cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length()); + QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); CleanupStack::PopAndDestroy(pName); pName = NULL; @@ -500,7 +501,7 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( if (error == KErrNone && pName) { CleanupStack::PushL(pName); - cpPriv->mappingName = QString::fromUtf16(pName->Ptr(),pName->Length()); + QT_TRYCATCH_LEAVING(cpPriv->mappingName = QString::fromUtf16(pName->Ptr(),pName->Length())); CleanupStack::PopAndDestroy(pName); pName = NULL; } @@ -518,8 +519,6 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( cpPriv->type = QNetworkConfiguration::InternetAccessPoint; cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; cpPriv->roamingSupported = false; - - CleanupStack::Pop(cpPriv); return cpPriv; } #else @@ -552,7 +551,7 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( QString ident = QString::number(qHash(aApId)); - apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length()); + QT_TRYCATCH_LEAVING(apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length())); apNetworkConfiguration->isValid = true; apNetworkConfiguration->id = ident; apNetworkConfiguration->numericId = aApId; @@ -902,7 +901,7 @@ void SymbianEngine::RunL() if (event == RDbNotifier::ECommit) { TRAPD(error, updateConfigurationsL()); if (error == KErrNone) { - updateStatesToSnaps(); + QT_TRYCATCH_LEAVING(updateStatesToSnaps()); } locker.unlock(); waitRandomTime(); @@ -913,7 +912,7 @@ void SymbianEngine::RunL() locker.relock(); TRAPD(error, updateConfigurationsL()); if (error == KErrNone) { - updateStatesToSnaps(); + QT_TRYCATCH_LEAVING(updateStatesToSnaps()); } } iIgnoringUpdates = false; // Wait time done, allow updating again @@ -966,8 +965,10 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; ptr->mutex.unlock(); - emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), - connectionId, QNetworkSession::Connecting); + QT_TRYCATCH_LEAVING( + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Connecting) + ); } } else if (connectionStatus == KLinkLayerOpen) { // Connection has been successfully opened @@ -985,23 +986,27 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) ptr->mutex.unlock(); // Configuration is Active - if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) { - updateStatesToSnaps(); - } - emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), - connectionId, QNetworkSession::Connected); + QT_TRYCATCH_LEAVING( + if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) { + updateStatesToSnaps(); + } + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Connected); - if (!iOnline) { - iOnline = true; - emit this->onlineStateChanged(iOnline); - } + if (!iOnline) { + iOnline = true; + emit this->onlineStateChanged(iOnline); + } + ); } } else if (connectionStatus == KConfigDaemonStartingDeregistration) { TUint connectionId = realEvent->ConnectionId(); QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); if (ptr) { - emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), - connectionId, QNetworkSession::Closing); + QT_TRYCATCH_LEAVING( + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Closing) + ); } } else if (connectionStatus == KLinkLayerClosed || connectionStatus == KConnectionClosed) { @@ -1011,12 +1016,13 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); if (ptr) { // Configuration is either Defined or Discovered - if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) { - updateStatesToSnaps(); - } - - emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), - connectionId, QNetworkSession::Disconnected); + QT_TRYCATCH_LEAVING( + if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) { + updateStatesToSnaps(); + } + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Disconnected); + ); } bool online = false; @@ -1030,7 +1036,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } if (iOnline != online) { iOnline = online; - emit this->onlineStateChanged(iOnline); + QT_TRYCATCH_LEAVING(emit this->onlineStateChanged(iOnline)); } } } @@ -1048,7 +1054,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { // Configuration is either Discovered or Active - changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered); + QT_TRYCATCH_LEAVING(changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered)); unDiscoveredConfigs.removeOne(ident); } } @@ -1056,7 +1062,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); if (ptr) { // Configuration is Defined - changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined); + QT_TRYCATCH_LEAVING(changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined)); } } } @@ -1198,9 +1204,9 @@ void AccessPointsAvailabilityScanner::RunL() if (iStatus.Int() != KErrNone) { iIapBuf().iCount = 0; - iOwner.accessPointScanningReady(false,iIapBuf()); + QT_TRYCATCH_LEAVING(iOwner.accessPointScanningReady(false,iIapBuf())); } else { - iOwner.accessPointScanningReady(true,iIapBuf()); + QT_TRYCATCH_LEAVING(iOwner.accessPointScanningReady(true,iIapBuf())); } } -- cgit v0.12 From 91ff19ea3233310f5db542e880661d1efe0151e2 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 14:31:01 +1000 Subject: Cherry pick fix for MOBILITY-938 from Qt Mobility. 216f4016d1b447d51630086afca179df11fd6997 --- src/plugins/bearer/symbian/symbianengine.cpp | 98 ++++++++-------- src/plugins/bearer/symbian/symbianengine.h | 5 +- tests/manual/bearerex/bearerex.cpp | 90 ++++++++------ tests/manual/bearerex/bearerex.h | 15 ++- tests/manual/bearerex/bearerex.pro | 6 +- tests/manual/bearerex/sessiondialog.ui | 168 +++++++++++++++++---------- 6 files changed, 223 insertions(+), 159 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 3d462ee..8780218 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include // For randgen seeding #include // For randgen seeding @@ -115,7 +114,7 @@ QString SymbianNetworkConfigurationPrivate::bearerName() const SymbianEngine::SymbianEngine(QObject *parent) : QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true), - iIgnoringUpdates(false) + iUpdatePending(false) { } @@ -190,6 +189,28 @@ SymbianEngine::~SymbianEngine() delete cleanup; } +void SymbianEngine::delayedConfigurationUpdate() +{ + QMutexLocker locker(&mutex); + + if (iUpdatePending) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM delayed configuration update (ECommit or ERecover occurred)."); +#endif + TRAPD(error, updateConfigurationsL()); + if (error == KErrNone) { + updateStatesToSnaps(); + } + iUpdatePending = false; + // Start monitoring again. + if (!IsActive()) { + SetActive(); + // Start waiting for new notification + ipCommsDB->RequestNotification(iStatus); + } + } +} + bool SymbianEngine::hasIdentifier(const QString &id) { QMutexLocker locker(&mutex); @@ -872,55 +893,30 @@ void SymbianEngine::RunL() { QMutexLocker locker(&mutex); - if (iIgnoringUpdates) { -#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug("QNCM CommsDB event handling postponed (postpone-timer running because IAPs/SNAPs were updated very recently)."); -#endif - return; - } - - RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); - - switch (event) { - case RDbNotifier::EUnlock: /** All read locks have been removed. */ - case RDbNotifier::ECommit: /** A transaction has been committed. */ - case RDbNotifier::ERollback: /** A transaction has been rolled back */ - case RDbNotifier::ERecover: /** The database has been recovered */ + if (iStatus != KErrCancel) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); #endif - iIgnoringUpdates = true; - // Other events than ECommit get lower priority. In practice with those events, - // we delay_before_updating methods, whereas - // with ECommit we _update_before_delaying the reaction to next event. - // Few important notes: 1) listening to only ECommit does not seem to be adequate, - // but updates will be missed. Hence other events are reacted upon too. - // 2) RDbNotifier records the most significant event, and that will be returned once - // we issue new RequestNotification, and hence updates will not be missed even - // when we are 'not reacting to them' for few seconds. - if (event == RDbNotifier::ECommit) { - TRAPD(error, updateConfigurationsL()); - if (error == KErrNone) { - QT_TRYCATCH_LEAVING(updateStatesToSnaps()); - } - locker.unlock(); - waitRandomTime(); - locker.relock(); - } else { - locker.unlock(); - waitRandomTime(); - locker.relock(); - TRAPD(error, updateConfigurationsL()); - if (error == KErrNone) { - QT_TRYCATCH_LEAVING(updateStatesToSnaps()); + // By default, start relistening notifications. Stop only if interesting event occured. + iWaitingCommsDatabaseNotifications = true; + RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); + switch (event) { + case RDbNotifier::ECommit: /** A transaction has been committed. */ + case RDbNotifier::ERecover: /** The database has been recovered */ + // Mark that there is update pending. No need to ask more events, + // as we know we will be updating anyway when the timer expires. + if (!iUpdatePending) { + iUpdatePending = true; + iWaitingCommsDatabaseNotifications = false; + // Update after random time, so that many processes won't + // start updating simultaneously + updateConfigurationsAfterRandomTime(); } + break; + default: + // Do nothing + break; } - iIgnoringUpdates = false; // Wait time done, allow updating again - iWaitingCommsDatabaseNotifications = true; - break; - default: - // Do nothing - break; } if (iWaitingCommsDatabaseNotifications) { @@ -1135,15 +1131,13 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo } // Waits for 2..6 seconds. -void SymbianEngine::waitRandomTime() +void SymbianEngine::updateConfigurationsAfterRandomTime() { - int iTimeToWait = qMax(2000, (qAbs(qrand()) % 7) * 1000); + int iTimeToWait = qMax(1000, (qAbs(qrand()) % 68) * 100); #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug("QNCM waiting random time: %d ms", iTimeToWait); #endif - QEventLoop loop; - QTimer::singleShot(iTimeToWait, &loop, SLOT(quit())); - loop.exec(); + QTimer::singleShot(iTimeToWait, this, SLOT(delayedConfigurationUpdate())); } QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aConnectionId) @@ -1164,7 +1158,7 @@ QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aCon AccessPointsAvailabilityScanner::AccessPointsAvailabilityScanner(SymbianEngine& owner, RConnectionMonitor& connectionMonitor) - : CActive(CActive::EPriorityStandard), iOwner(owner), iConnectionMonitor(connectionMonitor) + : CActive(CActive::EPriorityHigh), iOwner(owner), iConnectionMonitor(connectionMonitor) { CActiveScheduler::Add(this); } diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 18fd249..27f3db4 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -159,6 +159,7 @@ Q_SIGNALS: public Q_SLOTS: void updateConfigurations(); + void delayedConfigurationUpdate(); private: void updateStatesToSnaps(); @@ -183,7 +184,7 @@ private: void accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo); void startCommsDatabaseNotifications(); void stopCommsDatabaseNotifications(); - void waitRandomTime(); + void updateConfigurationsAfterRandomTime(); QNetworkConfigurationPrivatePointer defaultConfigurationL(); TBool GetS60PlatformVersion(TUint& aMajor, TUint& aMinor) const; @@ -211,7 +212,7 @@ private: // Data TBool iOnline; TBool iInitOk; TBool iUpdateGoingOn; - TBool iIgnoringUpdates; + TBool iUpdatePending; AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner; diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index bf60dd1..00cb481 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -40,6 +40,7 @@ ****************************************************************************/ #include "bearerex.h" +#include "datatransferer.h" #include @@ -261,8 +262,8 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration, QListWidget* eventListWidget, int index, BearerEx * parent) - : QWidget(parent), m_http(0), m_eventListWidget(eventListWidget), - m_index(index), m_httpRequestOngoing(false), m_alrEnabled (false) + : QWidget(parent), m_dataTransferer(0), m_eventListWidget(eventListWidget), + m_index(index), m_alrEnabled (false) { setupUi(this); @@ -300,41 +301,46 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration, SessionTab::~SessionTab() { - // Need to be nulled, because modal dialogs may return after destruction of this object and - // use already released resources. - delete m_NetworkSession; - m_NetworkSession = NULL; - delete m_http; - m_http = NULL; + delete m_NetworkSession; m_NetworkSession = 0; + delete m_dataTransferer; m_dataTransferer = 0; } -void SessionTab::on_createQHttpButton_clicked() +void SessionTab::on_createQNetworkAccessManagerButton_clicked() { - if (m_httpRequestOngoing) { - return; + if (m_dataTransferer) { + disconnect(m_dataTransferer, 0, 0, 0); + delete m_dataTransferer; + m_dataTransferer = 0; } - - if (m_http) { - disconnect(m_http, 0, 0, 0); - delete m_http; + // Create new object according to current selection + QString type(comboBox->currentText()); + if (type == "QNAM") { + m_dataTransferer = new DataTransfererQNam(this); + } else if (type == "QTcpSocket") { + m_dataTransferer = new DataTransfererQTcp(this); + } else if (type == "QHttp") { + m_dataTransferer = new DataTransfererQHttp(this); + } else { + qDebug("BearerEx Warning, unknown data transfer object requested, not creating anything."); + return; } - m_http = new QHttp(this); - createQHttpButton->setText("Recreate QHttp"); - connect(m_http, SIGNAL(done(bool)), this, SLOT(done(bool))); + createQNetworkAccessManagerButton->setText("Recreate"); + connect(m_dataTransferer, SIGNAL(finished(quint32, qint64, QString)), this, SLOT(finished(quint32, qint64, QString))); } void SessionTab::on_sendRequestButton_clicked() { - if (m_http) { - QString urlstring("http://www.google.com"); - QUrl url(urlstring); - m_http->setHost(url.host(), QHttp::ConnectionModeHttp, url.port() == -1 ? 0 : url.port()); - m_http->get(urlstring); - m_httpRequestOngoing = true; + if (m_dataTransferer) { + if (!m_dataTransferer->transferData()) { + QMessageBox msgBox; + msgBox.setStandardButtons(QMessageBox::Close); + msgBox.setText("Data transfer not started. \nVery likely data transfer ongoing."); + msgBox.exec(); + } } else { QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Close); - msgBox.setText("QHttp not created.\nCreate QHttp First."); + msgBox.setText("Data object not created.\nCreate data object first."); msgBox.exec(); } } @@ -419,7 +425,7 @@ void SessionTab::opened() listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Opened")); m_eventListWidget->addItem(listItem); - QVariant identifier = m_NetworkSession->property("ActiveConfiguration"); + QVariant identifier = m_NetworkSession->sessionProperty("ActiveConfiguration"); if (!identifier.isNull()) { QString configId = identifier.toString(); QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); @@ -429,7 +435,7 @@ void SessionTab::opened() } if (m_NetworkSession->configuration().type() == QNetworkConfiguration::UserChoice) { - QVariant identifier = m_NetworkSession->property("UserChoiceConfiguration"); + QVariant identifier = m_NetworkSession->sessionProperty("UserChoiceConfiguration"); if (!identifier.isNull()) { QString configId = identifier.toString(); QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); @@ -480,6 +486,18 @@ QString SessionTab::stateString(QNetworkSession::State state) return stateString; } +void SessionTab::on_dataObjectChanged(const QString &newObjectType) +{ + qDebug() << "BearerEx SessionTab dataObjectChanged to: " << newObjectType; + if (m_dataTransferer) { + disconnect(m_dataTransferer, 0, 0, 0); + delete m_dataTransferer; m_dataTransferer = 0; + qDebug() << "BearerEx SessionTab, previous data object deleted."; + } + createQNetworkAccessManagerButton->setText("Create"); +} + + void SessionTab::stateChanged(QNetworkSession::State state) { newState(state); @@ -491,7 +509,7 @@ void SessionTab::stateChanged(QNetworkSession::State state) void SessionTab::newState(QNetworkSession::State state) { - QVariant identifier = m_NetworkSession->property("ActiveConfiguration"); + QVariant identifier = m_NetworkSession->sessionProperty("ActiveConfiguration"); if (state == QNetworkSession::Connected && !identifier.isNull()) { QString configId = identifier.toString(); QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); @@ -542,18 +560,14 @@ void SessionTab::error(QNetworkSession::SessionError error) msgBox.exec(); } -void SessionTab::done(bool error) +void SessionTab::finished(quint32 errorCode, qint64 dataReceived, QString errorType) { - m_httpRequestOngoing = false; - QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Close); - if (error) { - msgBox.setText("HTTP request failed."); - } else { - QString result(m_http->readAll()); - msgBox.setText(QString("HTTP request finished successfully.\nReceived ")+QString::number(result.length())+QString(" bytes.")); - } + msgBox.setText(QString("Data transfer completed. \nError code: ") + QString::number(errorCode) + + "\nError type: " + errorType + + "\nBytes received: " + + QString::number(dataReceived)); msgBox.exec(); // Check if the networksession still exists - it may have gone after returning from // the modal dialog (in the case that app has been closed, and deleting QHttp will diff --git a/tests/manual/bearerex/bearerex.h b/tests/manual/bearerex/bearerex.h index 6bcb3e5..b81d486 100644 --- a/tests/manual/bearerex/bearerex.h +++ b/tests/manual/bearerex/bearerex.h @@ -55,13 +55,16 @@ #endif #include "qnetworkconfigmanager.h" #include "qnetworksession.h" +#include "datatransferer.h" #include "xqlistwidget.h" QT_BEGIN_NAMESPACE -class QHttp; +class QNetworkAccessManager; +class QNetworkReply; QT_END_NAMESPACE class SessionTab; +class DataTransferer; QT_USE_NAMESPACE @@ -113,14 +116,15 @@ public: QString stateString(QNetworkSession::State state); private Q_SLOTS: - void on_createQHttpButton_clicked(); + void on_createQNetworkAccessManagerButton_clicked(); void on_sendRequestButton_clicked(); void on_openSessionButton_clicked(); void on_closeSessionButton_clicked(); void on_stopConnectionButton_clicked(); void on_deleteSessionButton_clicked(); + void on_dataObjectChanged(const QString& newObjectType); void on_alrButton_clicked(); - void done(bool error); + void finished(quint32 errorCode, qint64 dataReceived, QString errorType); void newConfigurationActivated(); void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless); @@ -131,13 +135,14 @@ private Q_SLOTS: void error(QNetworkSession::SessionError error); private: //data - QHttp* m_http; + // QNetworkAccessManager* m_networkAccessManager; + DataTransferer* m_dataTransferer; QNetworkSession* m_NetworkSession; QNetworkConfigurationManager* m_ConfigManager; QListWidget* m_eventListWidget; QNetworkConfiguration m_config; int m_index; - bool m_httpRequestOngoing; + bool m_dataTransferOngoing; bool m_alrEnabled; }; diff --git a/tests/manual/bearerex/bearerex.pro b/tests/manual/bearerex/bearerex.pro index 7b21183..df39c85 100644 --- a/tests/manual/bearerex/bearerex.pro +++ b/tests/manual/bearerex/bearerex.pro @@ -17,10 +17,12 @@ maemo5|maemo6 { # Example headers and sources HEADERS += bearerex.h \ - xqlistwidget.h + xqlistwidget.h \ + datatransferer.h SOURCES += bearerex.cpp \ main.cpp \ - xqlistwidget.cpp + xqlistwidget.cpp \ + datatransferer.cpp symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData diff --git a/tests/manual/bearerex/sessiondialog.ui b/tests/manual/bearerex/sessiondialog.ui index fcf2136..c50af70 100644 --- a/tests/manual/bearerex/sessiondialog.ui +++ b/tests/manual/bearerex/sessiondialog.ui @@ -1,78 +1,87 @@ - + + SessionTab - - + + + + 0 + 0 + 192 + 262 + + + - - - - + + + + SNAP - - - + + + true - - - + + + IAP - - - + + + true - + true - - - + + + Bearer - - - + + + true - - - + + + Sent/Rec. - - - + + + true - - - + + + State - - - + + + true @@ -80,52 +89,71 @@ - - - - + + + + Open Session - - - + + + Close Session - - - + + + Stop Conn. - - - - Create QHttp + + + + Enable ALR - - - + + + Send Test Req. - - - - Enable ALR + + + + Create - - - + + + + + QNAM + + + + + QTcpSocket + + + + + QHttp + + + + + + + Delete Session @@ -135,5 +163,25 @@ - + + + comboBox + currentIndexChanged(QString) + SessionTab + on_dataObjectChanged(QString) + + + 40 + 211 + + + 10 + 258 + + + + + + on_dataObjectChanged(QString) + -- cgit v0.12 From 8d07f723041c223d0d1346a1ce5e5ede17af32ad Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 15:04:16 +1000 Subject: Cherry pick fix for MOBILITY-1031 from Qt Mobility. 7e8b55524bd8a00e49e11103e8c8091e1e59e612 --- .../bearer/symbian/qnetworksession_impl.cpp | 7 ++-- src/plugins/bearer/symbian/symbianengine.cpp | 41 ++++++++++++---------- src/plugins/bearer/symbian/symbianengine.h | 3 ++ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 20e13d2..04ae396 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -910,8 +910,8 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia // <=> Note: It's possible that in this case reported IAP is // clone of the one of the IAPs of the used SNAP // => If mappingName matches, clone has been found - QNetworkConfiguration pt = QNetworkConfigurationManager() - .configurationFromIdentifier(QString::number(qHash(iapId))); + QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier( + QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId))); SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(pt)); @@ -938,7 +938,8 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia if (publicConfig.type() == QNetworkConfiguration::UserChoice) { if (engine) { - QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier(QString::number(qHash(iapId))); + QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier( + QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId))); // Try to found User Selected IAP from known IAPs (accessPointConfigurations) if (pt.isValid()) { return pt; diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 8780218..cf7e7a5 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -72,9 +72,6 @@ QT_BEGIN_NAMESPACE -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - static const int KValueThatWillBeAddedToSNAPId = 1000; -#endif static const int KUserChoiceIAPId = 0; SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() @@ -113,7 +110,7 @@ QString SymbianNetworkConfigurationPrivate::bearerName() const } SymbianEngine::SymbianEngine(QObject *parent) -: QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true), +: QBearerEngine(parent), CActive(CActive::EPriorityHigh), iFirstUpdate(true), iInitOk(true), iUpdatePending(false) { } @@ -282,7 +279,7 @@ void SymbianEngine::updateConfigurationsL() RCmConnectionMethod connectionMethod = iCmManager.ConnectionMethodL(connectionMethods[i]); CleanupClosePushL(connectionMethod); TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString ident = QString::number(qHash(iapId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); if (accessPointConfigurations.contains(ident)) { knownConfigs.removeOne(ident); } else { @@ -313,7 +310,8 @@ void SymbianEngine::updateConfigurationsL() RCmDestination destination; destination = iCmManager.DestinationL(destinations[i]); CleanupClosePushL(destination); - QString ident = QString::number(qHash(destination.Id()+KValueThatWillBeAddedToSNAPId)); //TODO: Check if it's ok to add 1000 SNAP Id to prevent SNAP ids overlapping IAP ids + QString ident = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX + + QString::number(qHash(destination.Id())); if (snapConfigurations.contains(ident)) { knownSnapConfigs.removeOne(ident); } else { @@ -347,7 +345,7 @@ void SymbianEngine::updateConfigurationsL() CleanupClosePushL(connectionMethod); TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString iface = QString::number(qHash(iapId)); + QString iface = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); // Check that IAP can be found from accessPointConfigurations list QNetworkConfigurationPrivatePointer priv = accessPointConfigurations.value(iface); if (!priv) { @@ -402,7 +400,7 @@ void SymbianEngine::updateConfigurationsL() TInt retVal = pDbTView->GotoFirstRecord(); while (retVal == KErrNone) { pDbTView->ReadUintL(TPtrC(COMMDB_ID), apId); - QString ident = QString::number(qHash(apId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); if (accessPointConfigurations.contains(ident)) { knownConfigs.removeOne(ident); } else { @@ -470,7 +468,7 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( { SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString ident = QString::number(qHash(iapId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); HBufC *pName = connectionMethod.GetStringAttributeL(CMManager::ECmName); CleanupStack::PushL(pName); @@ -570,7 +568,7 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( User::Leave(KErrNotFound); } - QString ident = QString::number(qHash(aApId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(aApId)); QT_TRYCATCH_LEAVING(apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length())); apNetworkConfiguration->isValid = true; @@ -637,10 +635,12 @@ QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL() TCmDefConnValue defaultConnectionValue; iCmManager.ReadDefConnL(defaultConnectionValue); if (defaultConnectionValue.iType == ECmDefConnDestination) { - QString iface = QString::number(qHash(defaultConnectionValue.iId+KValueThatWillBeAddedToSNAPId)); + QString iface = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX + + QString::number(qHash(defaultConnectionValue.iId)); ptr = snapConfigurations.value(iface); } else if (defaultConnectionValue.iType == ECmDefConnConnectionMethod) { - QString iface = QString::number(qHash(defaultConnectionValue.iId)); + QString iface = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(defaultConnectionValue.iId)); ptr = accessPointConfigurations.value(iface); } #endif @@ -678,7 +678,7 @@ void SymbianEngine::updateActiveAccessPoints() iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); @@ -735,7 +735,8 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn // Set state of returned IAPs to Discovered // if state is not already Active for(TUint i=0; imutex.lock(); @@ -974,7 +975,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TRequestStatus status; iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { ptr->mutex.lock(); @@ -1045,7 +1046,8 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TConnMonIapInfo iaps = realEvent->IapAvailability(); QList unDiscoveredConfigs = accessPointConfigurations.keys(); for ( TUint i = 0; i < iaps.Count(); i++ ) { - QString ident = QString::number(qHash(iaps.iIap[i].iIapId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(iaps.iIap[i].iIapId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { @@ -1075,7 +1077,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TRequestStatus status; iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { QMutexLocker configLocker(&ptr->mutex); @@ -1109,7 +1111,8 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo switch (newState) { case QNetworkSession::Disconnected: { - QString ident = QString::number(qHash(accessPointId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(accessPointId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { // Configuration is either Defined or Discovered diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 27f3db4..8e58994 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -55,6 +55,9 @@ // Uncomment and compile QtBearer to gain detailed state tracing // #define QT_BEARERMGMT_SYMBIAN_DEBUG +#define QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX QLatin1String("S_") +#define QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX QLatin1String("I_") + class CCommsDatabase; class QEventLoop; -- cgit v0.12 From 3c766b835fd565e3a85606ae2d4891e3954b447a Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 15:43:31 +1000 Subject: Merge bearermanagement changes from Qt Mobility. cba220f177154428d6103a93a819668be689a591 --- config.tests/mac/corewlan/corewlantest.mm | 2 +- examples/network/bearercloud/bearercloud.cpp | 2 +- examples/network/bearercloud/main.cpp | 2 +- examples/network/bearermonitor/main.cpp | 2 +- tests/auto/qbearertestcommon.h | 2 +- tests/manual/bearerex/datatransferer.cpp | 220 +++++++++++++++++++++++++++ tests/manual/bearerex/datatransferer.h | 130 ++++++++++++++++ tests/manual/bearerex/main.cpp | 2 +- tests/manual/bearerex/xqlistwidget.cpp | 2 +- tests/manual/bearerex/xqlistwidget.h | 2 +- 10 files changed, 358 insertions(+), 8 deletions(-) create mode 100644 tests/manual/bearerex/datatransferer.cpp create mode 100644 tests/manual/bearerex/datatransferer.h diff --git a/config.tests/mac/corewlan/corewlantest.mm b/config.tests/mac/corewlan/corewlantest.mm index 3a29d84..ee6f661 100644 --- a/config.tests/mac/corewlan/corewlantest.mm +++ b/config.tests/mac/corewlan/corewlantest.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/examples/network/bearercloud/bearercloud.cpp b/examples/network/bearercloud/bearercloud.cpp index 9e58c73..cc73954 100644 --- a/examples/network/bearercloud/bearercloud.cpp +++ b/examples/network/bearercloud/bearercloud.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/examples/network/bearercloud/main.cpp b/examples/network/bearercloud/main.cpp index c0c0023..6665311 100644 --- a/examples/network/bearercloud/main.cpp +++ b/examples/network/bearercloud/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp index 0bbbb56..1a22c13 100644 --- a/examples/network/bearermonitor/main.cpp +++ b/examples/network/bearermonitor/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/qbearertestcommon.h b/tests/auto/qbearertestcommon.h index c9df249..138c444 100644 --- a/tests/auto/qbearertestcommon.h +++ b/tests/auto/qbearertestcommon.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/manual/bearerex/datatransferer.cpp b/tests/manual/bearerex/datatransferer.cpp new file mode 100644 index 0000000..c3c13a8 --- /dev/null +++ b/tests/manual/bearerex/datatransferer.cpp @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include "datatransferer.h" + +DataTransferer::DataTransferer(QObject *parent) : + QObject(parent), m_dataTransferOngoing(false) +{ +} + +bool DataTransferer::dataTransferOngoing() +{ + return m_dataTransferOngoing; +} + + + +// -------- Based on QTcp + +DataTransfererQTcp::DataTransfererQTcp(QObject* parent) +: DataTransferer(parent) +{ + qDebug("BearerEx DataTransferer QTcp created."); + + connect(&m_qsocket, SIGNAL(readyRead()), this, SLOT(readyRead())); + connect(&m_qsocket, SIGNAL(connected()), this, SLOT(connected())); + connect(&m_qsocket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(error(QAbstractSocket::SocketError))); +} + +DataTransfererQTcp::~DataTransfererQTcp() +{ + qDebug("BearerEx DataTransferer QTcp destroyed."); + m_qsocket.abort(); +} + +bool DataTransfererQTcp::transferData() +{ + if (m_dataTransferOngoing) { + return false; + } + qDebug("BearerEx datatransfer for QTcp requested."); + // Connect to host + QUrl url("http://www.google.com.au"); + m_qsocket.connectToHost(url.host(), url.port(80)); + + // m_qsocket.connectToHost("http://www.google.com", 80); + // Wait for connected() signal. + m_dataTransferOngoing = true; + return true; +} + +void DataTransfererQTcp::connected() +{ + qDebug("BearerEx DataTransfererQtcp connected, requesting data."); + // Establish HTTP request + //QByteArray request("GET / HTTP/1.1 \nHost: www.google.com\n\n"); + QByteArray request("GET / HTTP/1.1\n\n"); + + // QByteArray request("GET /index.html HTTP/1.1 \n Host: www.google.com \n\n"); + qint64 dataWritten = m_qsocket.write(request); + m_qsocket.flush(); + + qDebug() << "BearerEx DataTransferQTcp wrote " << dataWritten << " bytes"; + // Start waiting for readyRead() of error() +} + +void DataTransfererQTcp::readyRead() +{ + qDebug() << "BearerEx DataTransfererQTcp readyRead() with "; + qint64 bytesAvailable = m_qsocket.bytesAvailable(); + qDebug() << bytesAvailable << " bytes available."; + + // QDataStream in(&m_qsocket); + QByteArray array = m_qsocket.readAll(); + QString data = QString::fromAscii(array); + + // in >> data; + + qDebug() << "BearerEx DataTransferQTcp data received: " << data; + m_dataTransferOngoing = false; + // m_qsocket.error() returns uninitialized value in case no error has occured, + // so emit '0' + emit finished(0, bytesAvailable, "QAbstractSocket::SocketError"); +} + +void DataTransfererQTcp::error(QAbstractSocket::SocketError socketError) +{ + qDebug("BearerEx DataTransfererQTcp error(), aborting socket."); + m_qsocket.abort(); + m_dataTransferOngoing = false; + emit finished(socketError, 0, "QAbstractSocket::SocketError"); +} + +// -------- Based on QHttp + +DataTransfererQHttp::DataTransfererQHttp(QObject* parent) +: DataTransferer(parent) +{ + connect(&m_qhttp, SIGNAL(done(bool)), this, SLOT(done(bool))); + qDebug("BearerEx DataTransferer QHttp created."); +} + +DataTransfererQHttp::~DataTransfererQHttp() +{ + qDebug("BearerEx DataTransferer QHttp destroyed."); +} + +bool DataTransfererQHttp::transferData() +{ + qDebug("BearerEx datatransfer for QHttp requested."); + if (m_dataTransferOngoing) { + return false; + } + QString urlstring("http://www.google.com"); + QUrl url(urlstring); + m_qhttp.setHost(url.host(), QHttp::ConnectionModeHttp, url.port() == -1 ? 0 : url.port()); + m_qhttp.get(urlstring); + m_dataTransferOngoing = true; + return true; +} + +void DataTransfererQHttp::done(bool /*error*/ ) +{ + qDebug("BearerEx DatatransfererQHttp reply was finished (error code is type QHttp::Error)."); + qint64 dataReceived = 0; + quint32 errorCode = m_qhttp.error(); + if (m_qhttp.error() == QHttp::NoError) { + QString result(m_qhttp.readAll()); + dataReceived = result.length(); + } + m_dataTransferOngoing = false; + emit finished(errorCode, dataReceived, "QHttp::Error"); +} + +// -------- Based on QNetworkAccessManager + +DataTransfererQNam::DataTransfererQNam(QObject* parent) +: DataTransferer(parent) +{ + connect(&m_qnam, SIGNAL(finished(QNetworkReply*)), + this, SLOT(replyFinished(QNetworkReply*))); + qDebug("BearerEx DataTransferer QNam created."); +} + +DataTransfererQNam::~DataTransfererQNam() +{ + qDebug("BearerEx DataTransferer QNam destroyed."); +} + +bool DataTransfererQNam::transferData() +{ + qDebug("BearerEx datatransfer for QNam requested."); + if (m_dataTransferOngoing) { + return false; + } + m_qnam.get(QNetworkRequest(QUrl("http://www.google.com"))); + m_dataTransferOngoing = true; + return true; +} + +void DataTransfererQNam::replyFinished(QNetworkReply *reply) +{ + qDebug("BearerEx DatatransfererQNam reply was finished (error code is type QNetworkReply::NetworkError)."); + qint64 dataReceived = 0; + quint32 errorCode = (quint32)reply->error(); + + if (reply->error() == QNetworkReply::NoError) { + QString result(reply->readAll()); + dataReceived = result.length(); + } + m_dataTransferOngoing = false; + emit finished(errorCode, dataReceived, "QNetworkReply::NetworkError"); + reply->deleteLater(); +} + + + diff --git a/tests/manual/bearerex/datatransferer.h b/tests/manual/bearerex/datatransferer.h new file mode 100644 index 0000000..f2159b7 --- /dev/null +++ b/tests/manual/bearerex/datatransferer.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DATATRANSFERER_H +#define DATATRANSFERER_H + +#include +#include +#include +#include +#include +#include +#include + +// Interface-class for data transferring object + +class DataTransferer : public QObject +{ + Q_OBJECT +public: + explicit DataTransferer(QObject *parent = 0); + virtual ~DataTransferer() { + if (m_dataTransferOngoing) { + qDebug("BearerEx Warning: dataobjects transfer was ongoing when destroyed."); + } + } + virtual bool transferData() = 0; + bool dataTransferOngoing(); + +signals: + void finished(quint32 errorCode, qint64 dataReceived, QString errorType); + +public slots: + +protected: + bool m_dataTransferOngoing; +}; + + +// Specializations/concrete classes + +class DataTransfererQTcp : public DataTransferer +{ + Q_OBJECT +public: + DataTransfererQTcp(QObject* parent = 0); + ~DataTransfererQTcp(); + + virtual bool transferData(); + +public slots: + void readyRead(); + void error(QAbstractSocket::SocketError socketError); + void connected(); + +private: + QTcpSocket m_qsocket; +}; + +class DataTransfererQNam : public DataTransferer +{ + Q_OBJECT +public: + DataTransfererQNam(QObject* parent = 0); + ~DataTransfererQNam(); + + virtual bool transferData(); + +public slots: + void replyFinished(QNetworkReply* reply); + +private: + QNetworkAccessManager m_qnam; +}; + +class DataTransfererQHttp : public DataTransferer +{ + Q_OBJECT +public: + DataTransfererQHttp(QObject* parent = 0); + ~DataTransfererQHttp(); + + virtual bool transferData(); + +public slots: + void done(bool error); + +private: + QHttp m_qhttp; +}; + +#endif // DATATRANSFERER_H diff --git a/tests/manual/bearerex/main.cpp b/tests/manual/bearerex/main.cpp index 20b167e..704321a 100644 --- a/tests/manual/bearerex/main.cpp +++ b/tests/manual/bearerex/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/manual/bearerex/xqlistwidget.cpp b/tests/manual/bearerex/xqlistwidget.cpp index 8104779..e4b12f2 100644 --- a/tests/manual/bearerex/xqlistwidget.cpp +++ b/tests/manual/bearerex/xqlistwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/manual/bearerex/xqlistwidget.h b/tests/manual/bearerex/xqlistwidget.h index 0649c2b..7c12138 100644 --- a/tests/manual/bearerex/xqlistwidget.h +++ b/tests/manual/bearerex/xqlistwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -- cgit v0.12 From 12c06cfb761b1c8b3575df9ad6d1aabdbd2ed402 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 15:59:23 +1000 Subject: Cherry pick fix for MOBILITY-1047 from Qt Mobility. 4f74cd44d77349759096bed091913b188a9167e4 --- examples/network/bearermonitor/bearermonitor.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp index 4a04b4c..98869ea 100644 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ b/examples/network/bearermonitor/bearermonitor.cpp @@ -80,7 +80,7 @@ BearerMonitor::BearerMonitor(QWidget *parent) break; } } - + connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool))); connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), this, SLOT(configurationAdded(const QNetworkConfiguration&))); connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), @@ -88,7 +88,6 @@ BearerMonitor::BearerMonitor(QWidget *parent) connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), this, SLOT(configurationChanged(const QNetworkConfiguration))); connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations())); - connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool))); #ifdef Q_OS_WIN connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork())); @@ -111,6 +110,10 @@ BearerMonitor::BearerMonitor(QWidget *parent) #endif connect(scanButton, SIGNAL(clicked()), this, SLOT(performScan())); + + // Just in case update all configurations so that all + // configurations are up to date. + manager.updateConfigurations(); } BearerMonitor::~BearerMonitor() @@ -209,6 +212,10 @@ void BearerMonitor::updateConfigurations() progressBar->hide(); scanButton->show(); + // Just in case update online state, on Symbian platform + // WLAN scan needs to be triggered initially to have their true state. + onlineStateChanged(manager.isOnline()); + QList items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard); QMap itemMap; while (!items.isEmpty()) { -- cgit v0.12 From 4aeb66d9c3e22a84d3c9bd916b8277537a2c4a2f Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 16:02:23 +1000 Subject: Cherry pick fix for MOBILITY-853 from Qt Mobility. 256e67963c4cb0fc150e6c47193e7c9b17296611 --- src/plugins/bearer/symbian/symbianengine.cpp | 70 ++++++++++++++++++++++++++++ src/plugins/bearer/symbian/symbianengine.h | 1 + 2 files changed, 71 insertions(+) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index cf7e7a5..bda3e56 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -131,6 +131,9 @@ void SymbianEngine::initialize() } TRAP_IGNORE(iConnectionMonitor.ConnectL()); +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + TRAP_IGNORE(iConnectionMonitor.SetUintAttribute(EBearerIdAll, 0, KBearerGroupThreshold, 1)); +#endif TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -804,6 +807,59 @@ void SymbianEngine::updateStatesToSnaps() } } +#ifdef SNAP_FUNCTIONALITY_AVAILABLE +void SymbianEngine::updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo) +{ + QHash::const_iterator i = + accessPointConfigurations.constBegin(); + while (i != accessPointConfigurations.constEnd()) { + QNetworkConfigurationPrivatePointer ptr = i.value(); + + QMutexLocker locker(&ptr->mutex); + + SymbianNetworkConfigurationPrivate *p = toSymbianConfig(ptr); + + if (p->bearer >= SymbianNetworkConfigurationPrivate::Bearer2G && + p->bearer <= SymbianNetworkConfigurationPrivate::BearerHSPA) { + switch (bearerInfo) { + case EBearerInfoCSD: + p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EBearerInfoWCDMA: + p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; + break; + case EBearerInfoCDMA2000: + p->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000; + break; + case EBearerInfoGPRS: + p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EBearerInfoHSCSD: + p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EBearerInfoEdgeGPRS: + p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EBearerInfoWcdmaCSD: + p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; + break; + case EBearerInfoHSDPA: + p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + break; + case EBearerInfoHSUPA: + p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + break; + case EBearerInfoHSxPA: + p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + break; + } + } + + ++i; + } +} +#endif + bool SymbianEngine::changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState) { @@ -941,6 +997,20 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QMutexLocker locker(&mutex); switch (aEvent.EventType()) { +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + case EConnMonBearerInfoChange: + { + CConnMonBearerInfoChange* realEvent; + realEvent = (CConnMonBearerInfoChange*) &aEvent; + TUint connectionId = realEvent->ConnectionId(); + if (connectionId == EBearerIdAll) { + //Network level event + TConnMonBearerInfo bearerInfo = (TConnMonBearerInfo)realEvent->BearerInfo(); + updateMobileBearerToConfigs(bearerInfo); + } + break; + } +#endif case EConnMonConnectionStatusChange: { CConnMonConnectionStatusChange* realEvent; diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 8e58994..d95d4d5 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -173,6 +173,7 @@ private: bool changeConfigurationStateAtMaxTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState); #ifdef SNAP_FUNCTIONALITY_AVAILABLE + void updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo); SymbianNetworkConfigurationPrivate *configFromConnectionMethodL(RCmConnectionMethod& connectionMethod); #else bool readNetworkConfigurationValuesFromCommsDb( -- cgit v0.12 From 94797fdd2e752677a5665abc9b23aa22f8a9c4db Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 16:18:01 +1000 Subject: Cherry pick fix for MOBILITY-800 from Qt Mobility. a05504d2a0c643c6f253527f07bcc0dba8a799b4 --- .../bearer/symbian/qnetworksession_impl.cpp | 30 +++++++++++++++++----- src/plugins/bearer/symbian/qnetworksession_impl.h | 5 ++++ tests/manual/bearerex/bearerex.cpp | 3 ++- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 04ae396..b90d603 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -63,7 +63,12 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility = NULL; #endif - + // Try to load "Open C" dll dynamically and + // try to attach to unsetdefaultif function dynamically. + // This is to avoid build breaks with old OpenC versions. + if (iOpenCLibrary.Load(_L("libc")) == KErrNone) { + iDynamicUnSetdefaultif = (TOpenCUnSetdefaultifFunction)iOpenCLibrary.Lookup(597); + } TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -86,14 +91,15 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() iMobility = NULL; } #endif - iConnection.Close(); iSocketServ.Close(); // Close global 'Open C' RConnection + // Clears also possible unsetdefaultif() flags. setdefaultif(0); iConnectionMonitor.Close(); + iOpenCLibrary.Close(); } void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState) @@ -525,8 +531,15 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iConnection.Close(); iSocketServ.Close(); - // Close global 'Open C' RConnection - setdefaultif(0); + // Close global 'Open C' RConnection. If OpenC supports, + // close the defaultif for good to avoid difficult timing + // and bouncing issues of network going immediately back up + // because of e.g. select() thread etc. + if (iDynamicUnSetdefaultif) { + iDynamicUnSetdefaultif(); + } else { + setdefaultif(0); + } if (publicConfig.type() == QNetworkConfiguration::UserChoice) { newState(QNetworkSession::Closing); @@ -611,8 +624,13 @@ void QNetworkSessionPrivateImpl::migrate() { #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iMobility) { - // Close global 'Open C' RConnection - setdefaultif(0); + // Close global 'Open C' RConnection. If openC supports, use the 'heavy' + // version to block all subsequent requests. + if (iDynamicUnSetdefaultif) { + iDynamicUnSetdefaultif(); + } else { + setdefaultif(0); + } // Start migrating to new IAP iMobility->MigrateToPreferredCarrier(); } diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index b045ff1..4b4f28c 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -73,6 +73,8 @@ QT_BEGIN_NAMESPACE class ConnectionProgressNotifier; class SymbianEngine; +typedef void (*TOpenCUnSetdefaultifFunction)(); + class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive #ifdef SNAP_FUNCTIONALITY_AVAILABLE , public MMobilityProtocolResp @@ -153,6 +155,9 @@ private: // data QDateTime startTime; + RLibrary iOpenCLibrary; + TOpenCUnSetdefaultifFunction iDynamicUnSetdefaultif; + mutable RSocketServ iSocketServ; mutable RConnection iConnection; mutable RConnectionMonitor iConnectionMonitor; diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 00cb481..6f280db 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -564,7 +564,8 @@ void SessionTab::finished(quint32 errorCode, qint64 dataReceived, QString errorT { QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Close); - msgBox.setText(QString("Data transfer completed. \nError code: ") + QString::number(errorCode) + + msgBox.setText(QString("Data transfer completed. \nError code: ") + + QString::number(int(errorCode)) + "\nError type: " + errorType + "\nBytes received: " + QString::number(dataReceived)); -- cgit v0.12 From 94c64b9ae4d539e9578156a0df999de1605f858f Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 16:23:34 +1000 Subject: Cherry pick fix for MOBILITY-965 from Qt Mobility. 50de830ded2dcc1c6b4d8be71428d9a2bfed6ae7 --- .../bearer/symbian/qnetworksession_impl.cpp | 84 ++++++++++++++++++++-- src/plugins/bearer/symbian/symbianengine.cpp | 70 ++++++++++++++++-- src/plugins/bearer/symbian/symbianengine.h | 3 + 3 files changed, 147 insertions(+), 10 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index b90d603..940281c 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -69,6 +69,7 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) if (iOpenCLibrary.Load(_L("libc")) == KErrNone) { iDynamicUnSetdefaultif = (TOpenCUnSetdefaultifFunction)iOpenCLibrary.Lookup(597); } + TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -91,6 +92,7 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() iMobility = NULL; } #endif + iConnection.Close(); iSocketServ.Close(); @@ -433,6 +435,10 @@ void QNetworkSessionPrivateImpl::open() toSymbianConfig(privateConfiguration(publicConfig)); #ifdef OCC_FUNCTIONALITY_AVAILABLE + // On Symbian^3 if service network is not reachable, it triggers a UI (aka EasyWLAN) where + // user can create new IAPs. To detect this, we need to store the number of IAPs + // there was before connection was started. + iKnownConfigsBeforeConnectionStart = engine->accessPointConfigurationIdentifiers(); TConnPrefList snapPref; TExtendedConnPref prefs; prefs.SetSnapId(symbianConfig->numericIdentifier()); @@ -511,7 +517,11 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iClosedByUser = true; isOpen = false; +#ifndef OCC_FUNCTIONALITY_AVAILABLE + // On Symbian^3 we need to keep track of active configuration longer + // in case of empty-SNAP-triggered EasyWLAN. activeConfig = QNetworkConfiguration(); +#endif serviceConfig = QNetworkConfiguration(); Cancel(); @@ -906,7 +916,7 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia _LIT(KSetting, "IAP\\Id"); iConnection.GetIntSetting(KSetting, iapId); } - + #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { // Try to search IAP from the used SNAP using IAP Id @@ -943,17 +953,54 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia } } } else { +#ifdef OCC_FUNCTIONALITY_AVAILABLE + // On Symbian^3 (only, not earlier or Symbian^4) if the SNAP was not reachable, it triggers + // user choice type of activity (EasyWLAN). As a result, a new IAP may be created, and + // hence if was not found yet. Therefore update configurations and see if there is something new. + // 1. Update knowledge from the databases. + engine->requestUpdate(); + // 2. Check if new configuration was created during connection creation + QList knownConfigs = engine->accessPointConfigurationIdentifiers(); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "opened configuration was not known beforehand, looking for new."; +#endif + if (knownConfigs.count() > iKnownConfigsBeforeConnectionStart.count()) { + // Configuration count increased => new configuration was created + // => Search new, created configuration + QString newIapId; + for (int i=0; i < iKnownConfigsBeforeConnectionStart.count(); i++) { + if (knownConfigs[i] != iKnownConfigsBeforeConnectionStart[i]) { + newIapId = knownConfigs[i]; + break; + } + } + if (newIapId.isEmpty()) { + newIapId = knownConfigs[knownConfigs.count()-1]; + } + pt = QNetworkConfigurationManager().configurationFromIdentifier(newIapId); + if (pt.isValid()) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "new configuration was found, name, IAP id: " << pt.name() << pt.identifier(); +#endif + return pt; + } + } +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "configuration was not found, returning invalid."; +#endif +#endif // OCC_FUNCTIONALITY_AVAILABLE // Given IAP Id was not found from known IAPs array return QNetworkConfiguration(); } - // Matching IAP was not found from used SNAP // => IAP from another SNAP is returned // (Note: Returned IAP matches to given IAP Id) return pt; } #endif - if (publicConfig.type() == QNetworkConfiguration::UserChoice) { if (engine) { QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier( @@ -994,6 +1041,10 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia void QNetworkSessionPrivateImpl::RunL() { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "RConnection::RunL with status code: " << iStatus.Int(); +#endif TInt statusCode = iStatus.Int(); switch (statusCode) { @@ -1226,7 +1277,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint QNetworkConfiguration config = bestConfigFromSNAP(publicConfig); if ((config.state() == QNetworkConfiguration::Defined) || (config.state() == QNetworkConfiguration::Discovered)) { - + activeConfig = QNetworkConfiguration(); state = newState; #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed E to: " << state; @@ -1247,6 +1298,21 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint } } } +#ifdef OCC_FUNCTIONALITY_AVAILABLE + // If the retVal is not true here, it means that the status update may apply to an IAP outside of + // SNAP (session is based on SNAP but follows IAP outside of it), which may occur on Symbian^3 EasyWlan. + if (retVal == false && activeConfig.d.data() && activeConfig.d.data()->numericId == accessPointId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed G to: " << state; +#endif + if (newState == QNetworkSession::Disconnected) { + activeConfig = QNetworkConfiguration(); + } + state = newState; + emit q->stateChanged(state); + retVal = true; + } +#endif } } @@ -1262,9 +1328,15 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); - iDeprecatedConnectionId = symbianConfig->connectionIdentifier(); - } + symbianConfig->mutex.lock(); + iDeprecatedConnectionId = symbianConfig->connectionId; + symbianConfig->mutex.unlock(); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + // Just in case clear activeConfiguration. + activeConfig = QNetworkConfiguration(); +#endif + } return retVal; } diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index bda3e56..ca444c1 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -683,6 +683,12 @@ void SymbianEngine::updateActiveAccessPoints() User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // If IAP was not found, check if the update was about EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); User::WaitForRequest(status); @@ -713,7 +719,7 @@ void SymbianEngine::updateActiveAccessPoints() if (iOnline != online) { iOnline = online; mutex.unlock(); - emit this->onlineStateChanged(iOnline); + emit this->onlineStateChanged(online); mutex.lock(); } } @@ -951,15 +957,15 @@ void SymbianEngine::RunL() QMutexLocker locker(&mutex); if (iStatus != KErrCancel) { -#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); -#endif // By default, start relistening notifications. Stop only if interesting event occured. iWaitingCommsDatabaseNotifications = true; RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); switch (event) { case RDbNotifier::ECommit: /** A transaction has been committed. */ case RDbNotifier::ERecover: /** The database has been recovered */ +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); +#endif // Mark that there is update pending. No need to ask more events, // as we know we will be updating anyway when the timer expires. if (!iUpdatePending) { @@ -1026,8 +1032,15 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TRequestStatus status; iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // Check if status was regarding EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; @@ -1047,6 +1060,12 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // Check for EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; @@ -1149,6 +1168,12 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // If IAP was not found, check if the update was about EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { QMutexLocker configLocker(&ptr->mutex); #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG @@ -1164,6 +1189,43 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } } +#ifdef OCC_FUNCTIONALITY_AVAILABLE +// Tries to derive configuration from EasyWLAN. +// First checks if the interface brought up was EasyWLAN, then derives the real SSID, +// and looks up configuration based on that one. +QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUint32 apId, TUint connectionId) +{ + if (apId == iCmManager.EasyWlanIdL()) { + TRequestStatus status; + TBuf<50> easyWlanNetworkName; + iConnectionMonitor.GetStringAttribute( connectionId, 0, KNetworkName, + easyWlanNetworkName, status ); + User::WaitForRequest(status); + if (status.Int() == KErrNone) { + QString realSSID = QString::fromUtf16(easyWlanNetworkName.Ptr(), easyWlanNetworkName.Length()); + + // Browser through all items and check their name for match + QHash >::const_iterator i = + accessPointConfigurations.constBegin(); + while (i != accessPointConfigurations.constEnd()) { + QNetworkConfigurationPrivatePointer ptr = i.value(); + + QMutexLocker configLocker(&ptr->mutex); + + if (ptr->name == realSSID) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM EasyWlan uses real SSID: " << realSSID; +#endif + return ptr; + } + ++i; + } + } + } + return QNetworkConfigurationPrivatePointer(); +} +#endif + // Sessions may use this function to report configuration state changes, // because on some Symbian platforms (especially Symbian^3) all state changes are not // reported by the RConnectionMonitor, in particular in relation to stop() call, diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index d95d4d5..cfddc29 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -206,6 +206,9 @@ private: // For QNetworkSessionPrivate to indicate about state changes void configurationStateChangeReport(TUint32 accessPointId, QNetworkSession::State newState); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + QNetworkConfigurationPrivatePointer configurationFromEasyWlan(TUint32 apId, TUint connectionId); +#endif private: // Data bool iFirstUpdate; -- cgit v0.12 From 2faa2ff804a8ed4e0bb60a4d11cd424a0e160dc8 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 11 Jun 2010 13:03:19 +1000 Subject: Cherry pick fix for MOBILITY-1063 from Qt Mobility. 37ad80914f7acb8d4f3364d78e75d48cd14e8e2a --- .../bearer/symbian/qnetworksession_impl.cpp | 69 +++++------------- .../qnetworksession/test/tst_qnetworksession.cpp | 84 ++++++++++++++++++++-- 2 files changed, 96 insertions(+), 57 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 940281c..cce8095 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -83,9 +83,6 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() delete ipConnectionNotifier; ipConnectionNotifier = NULL; - // Cancel possible RConnection::Start() - Cancel(); - #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iMobility) { delete iMobility; @@ -93,7 +90,8 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() } #endif - iConnection.Close(); + // Cancel possible RConnection::Start() + Cancel(); iSocketServ.Close(); // Close global 'Open C' RConnection @@ -366,44 +364,6 @@ void QNetworkSessionPrivateImpl::open() } if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - // Search through existing connections. - // If there is already connection which matches to given IAP - // try to attach to existing connection. - TBool connected(EFalse); - TConnectionInfoBuf connInfo; - TUint count; - if (iConnection.EnumerateConnections(count) == KErrNone) { - for (TUint i=1; i<=count; i++) { - // Note: GetConnectionInfo expects 1-based index. - if (iConnection.GetConnectionInfo(i, connInfo) == KErrNone) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - if (connInfo().iIapId == symbianConfig->numericIdentifier()) { - if (iConnection.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { - activeConfig = publicConfig; -#ifndef QT_NO_NETWORKINTERFACE - activeInterface = interface(symbianConfig->numericIdentifier()); -#endif - connected = ETrue; - startTime = QDateTime::currentDateTime(); - // Use name of the IAP to open global 'Open C' RConnection - QByteArray nameAsByteArray = publicConfig.name().toUtf8(); - ifreq ifr; - memset(&ifr, 0, sizeof(struct ifreq)); - strcpy(ifr.ifr_name, nameAsByteArray.constData()); - error = setdefaultif(&ifr); - isOpen = true; - // Make sure that state will be Connected - newState(QNetworkSession::Connected); - emit quitPendingWaitsForOpened(); - break; - } - } - } - } - } - if (!connected) { SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); @@ -429,7 +389,6 @@ void QNetworkSessionPrivateImpl::open() SetActive(); } newState(QNetworkSession::Connecting); - } } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); @@ -508,15 +467,16 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) << "close() called, session state is: " << state << " and isOpen is : " << isOpen; #endif - if (!isOpen) { + + if (!isOpen && state != QNetworkSession::Connecting) { return; } // Mark this session as closed-by-user so that we are able to report // distinguish between stop() and close() state transitions // when reporting. iClosedByUser = true; - isOpen = false; + #ifndef OCC_FUNCTIONALITY_AVAILABLE // On Symbian^3 we need to keep track of active configuration longer // in case of empty-SNAP-triggered EasyWLAN. @@ -524,7 +484,6 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) #endif serviceConfig = QNetworkConfiguration(); - Cancel(); #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iMobility) { delete iMobility; @@ -538,7 +497,7 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iHandleStateNotificationsFromManager = true; } - iConnection.Close(); + Cancel(); // closes iConnection iSocketServ.Close(); // Close global 'Open C' RConnection. If OpenC supports, @@ -551,11 +510,20 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) setdefaultif(0); } - if (publicConfig.type() == QNetworkConfiguration::UserChoice) { + // If UserChoice, go down immediately. If some other configuration, + // go down immediately if there is no reports expected from the platform; + // in practice Connection Monitor is aware of connections only after + // KFinishedSelection event, and hence reports only after that event, but + // that does not seem to be trusted on all Symbian versions --> safest + // to go down. + if (publicConfig.type() == QNetworkConfiguration::UserChoice || state == QNetworkSession::Connecting) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "going Disconnected because session was Connecting."; +#endif newState(QNetworkSession::Closing); newState(QNetworkSession::Disconnected); } - if (allowSignals) { emit closed(); } @@ -755,7 +723,7 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "roaming Error() occured"; + << "roaming Error() occured, isOpen is: " << isOpen; #endif if (isOpen) { isOpen = false; @@ -1361,7 +1329,6 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne case KFinishedSelection: if (aError == KErrNone) { - // The user successfully selected an IAP to be used break; } else diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index e4f2486..e4b8c14 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -75,17 +75,20 @@ private slots: void robustnessBombing(); + void sessionClosing_data(); + void sessionClosing(); + void outOfProcessSession(); void invalidSession(); void repeatedOpenClose_data(); void repeatedOpenClose(); - - void roamingErrorCodes(); - + void sessionStop_data(); void sessionStop(); + void roamingErrorCodes(); + void sessionProperties_data(); void sessionProperties(); @@ -131,6 +134,7 @@ void tst_QNetworkSession::initTestCase() // If you wish to skip tests, set value as false. This is often very convinient because tests are so lengthy. // Better way still would be to make this readable from a file. testsToRun["robustnessBombing"] = true; + testsToRun["sessionClosing"] = true; testsToRun["outOfProcessSession"] = true; testsToRun["invalidSession"] = true; testsToRun["repeatedOpenClose"] = true; @@ -265,6 +269,53 @@ void tst_QNetworkSession::robustnessBombing() testSession.reject(); } +void tst_QNetworkSession::sessionClosing_data() { + QTest::addColumn("bearerType"); + QTest::addColumn("configurationType"); + + QTest::newRow("WLAN_IAP") << "WLAN" << QNetworkConfiguration::InternetAccessPoint; + QTest::newRow("Cellular_IAP") << "cellular" << QNetworkConfiguration::InternetAccessPoint; + QTest::newRow("SNAP") << "bearer_type_not_relevant_with_SNAPs" << QNetworkConfiguration::ServiceNetwork; +} + +// Testcase for closing the session at unexpected times +void tst_QNetworkSession::sessionClosing() +{ + if (!testsToRun["sessionClosing"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } + QFETCH(QString, bearerType); + QFETCH(QNetworkConfiguration::Type, configurationType); + + // Update configurations so that WLANs are discovered too. + updateConfigurations(); + + // First check that opening once succeeds and determine if test is doable + QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType); + if (!config.isValid()) { + QSKIP("No suitable configurations, skipping this round of repeated open-close test.", SkipSingle); + } + qDebug() << "Using following configuration to bomb with close(): " << config.name(); + QNetworkSession session(config); + if (!openSession(&session) || + !closeSession(&session)) { + QSKIP("Unable to open/close session, skipping this round of close() bombing.", SkipSingle); + } + + qDebug() << "Closing without issuing open()"; + session.close(); + + for (int i = 0; i < 25; i++) { + qDebug() << "Opening and then waiting: " << i * 100 << " ms before closing."; + session.open(); + QTest::qWait(i*100); + session.close(); + // Sooner or later session must end in Disconnected state, + // no matter what the phase was. + QTRY_VERIFY(session.state() == QNetworkSession::Disconnected); + QTest::qWait(200); // Give platform a breathe, otherwise we'll be catching other errors + } +} void tst_QNetworkSession::invalidSession() { @@ -1060,15 +1111,27 @@ void tst_QNetworkSession::sessionOpenCloseStop() QTRY_VERIFY(stateChangedSpy.count() > 0); state = qvariant_cast(stateChangedSpy.at(stateChangedSpy.count() - 1).at(0)); + for (int i = 0; i < stateChangedSpy.count(); i++) { + QNetworkSession::State state_temp = + qvariant_cast(stateChangedSpy.at(i).at(0)); + // Extra debug because a fragile point in testcase because statuses vary. + qDebug() << "------- Statechange spy at: " << i << " is " << state_temp; + } + if (state == QNetworkSession::Roaming) { QTRY_VERIFY(session.state() == QNetworkSession::Connected); QTRY_VERIFY(session2.state() == QNetworkSession::Connected); roamedSuccessfully = true; + } else if (state == QNetworkSession::Closing) { + QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); + QTRY_VERIFY(session.state() == QNetworkSession::Connected); + roamedSuccessfully = true; } else if (state == QNetworkSession::Disconnected) { QTRY_VERIFY(!errorSpy.isEmpty()); QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); } else if (state == QNetworkSession::Connected) { QTRY_VERIFY(errorSpy.isEmpty()); + if (stateChangedSpy.count() > 1) { state = qvariant_cast(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0)); QVERIFY(state == QNetworkSession::Roaming); @@ -1102,9 +1165,18 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(state == QNetworkSession::Closing); state = qvariant_cast(stateChangedSpy2.at(1).at(0)); QVERIFY(state == QNetworkSession::Disconnected); - } else { // Assume .count() == 1 - QCOMPARE(stateChangedSpy2.count(), 1); - QNetworkSession::State state = qvariant_cast(stateChangedSpy2.at(0).at(0)); + } else { + QVERIFY(stateChangedSpy2.count() >= 1); + + for (int i = 0; i < stateChangedSpy2.count(); i++) { + QNetworkSession::State state_temp = + qvariant_cast(stateChangedSpy2.at(i).at(0)); + // Extra debug because a fragile point in testcase. + qDebug() << "+++++ Statechange spy at: " << i << " is " << state_temp; + } + + QNetworkSession::State state = + qvariant_cast(stateChangedSpy2.at(stateChangedSpy2.count() - 1).at(0)); // Symbian version dependant. QVERIFY(state == QNetworkSession::Disconnected); } -- cgit v0.12 From 91413d5ad27e97a95df4ab9a25f8c71548dbf3c3 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 11 Jun 2010 13:11:06 +1000 Subject: Cherry pick fix for QTMOBILITY-253 from Qt Mobility. f3d7f49b7f6975cbfa65adeb10b281e2b37172ce --- examples/network/bearermonitor/bearermonitor_240_320.ui | 2 +- examples/network/bearermonitor/bearermonitor_640_480.ui | 2 +- examples/network/bearermonitor/bearermonitor_maemo.ui | 2 +- examples/network/bearermonitor/sessionwidget.ui | 2 +- examples/network/bearermonitor/sessionwidget_maemo.ui | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/network/bearermonitor/bearermonitor_240_320.ui b/examples/network/bearermonitor/bearermonitor_240_320.ui index ce9c2d1..93cfc5e 100644 --- a/examples/network/bearermonitor/bearermonitor_240_320.ui +++ b/examples/network/bearermonitor/bearermonitor_240_320.ui @@ -11,7 +11,7 @@ - Form + BearerMonitor diff --git a/examples/network/bearermonitor/bearermonitor_640_480.ui b/examples/network/bearermonitor/bearermonitor_640_480.ui index 941eaa0..52866bc 100644 --- a/examples/network/bearermonitor/bearermonitor_640_480.ui +++ b/examples/network/bearermonitor/bearermonitor_640_480.ui @@ -11,7 +11,7 @@ - Form + BearerMonitor diff --git a/examples/network/bearermonitor/bearermonitor_maemo.ui b/examples/network/bearermonitor/bearermonitor_maemo.ui index 5f17e7d..a7940c6 100644 --- a/examples/network/bearermonitor/bearermonitor_maemo.ui +++ b/examples/network/bearermonitor/bearermonitor_maemo.ui @@ -11,7 +11,7 @@ - Form + BearerMonitor diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui index 56a2d0e..4199109 100644 --- a/examples/network/bearermonitor/sessionwidget.ui +++ b/examples/network/bearermonitor/sessionwidget.ui @@ -11,7 +11,7 @@ - Form + Session Details diff --git a/examples/network/bearermonitor/sessionwidget_maemo.ui b/examples/network/bearermonitor/sessionwidget_maemo.ui index 86f915c..ca68246 100644 --- a/examples/network/bearermonitor/sessionwidget_maemo.ui +++ b/examples/network/bearermonitor/sessionwidget_maemo.ui @@ -11,7 +11,7 @@ - Form + Session Details -- cgit v0.12 From e8fb98b6fcbace6ed7be3e4112b6a7516129ade2 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 11 Jun 2010 13:17:25 +1000 Subject: Cherry pick fix for MOBILITY-1063 from Qt Mobility. 4713262c16cb3eba1f4beccb6962a1ae210479c0 --- .../bearer/symbian/qnetworksession_impl.cpp | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index cce8095..1c581b6 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -53,10 +53,11 @@ QT_BEGIN_NAMESPACE QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) - : CActive(CActive::EPriorityUserInput), engine(engine), - ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), - iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iDeprecatedConnectionId(0), - iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) +: CActive(CActive::EPriorityUserInput), engine(engine), + iDynamicUnSetdefaultif(0), ipConnectionNotifier(0), + iHandleStateNotificationsFromManager(false), iFirstSync(true), iStoppedByUser(false), + iClosedByUser(false), iDeprecatedConnectionId(0), + iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) { CActiveScheduler::Add(this); @@ -69,6 +70,13 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) if (iOpenCLibrary.Load(_L("libc")) == KErrNone) { iDynamicUnSetdefaultif = (TOpenCUnSetdefaultifFunction)iOpenCLibrary.Lookup(597); } +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - "; + if (iDynamicUnSetdefaultif) + qDebug() << "dynamic setdefaultif() resolution succeeded. "; + else + qDebug() << "dynamic setdefaultif() resolution failed. "; +#endif TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -517,10 +525,25 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // that does not seem to be trusted on all Symbian versions --> safest // to go down. if (publicConfig.type() == QNetworkConfiguration::UserChoice || state == QNetworkSession::Connecting) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "going Disconnected because session was Connecting."; + + symbianConfig->mutex.lock(); + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "going Disconnected right away. Deprecating connection monitor ID: " + << symbianConfig->connectionId; + symbianConfig->mutex.unlock(); #endif + + // The connection has gone down, and processing of status updates must be + // stopped. Depending on platform, there may come 'connecting/connected' states + // considerably later (almost a second). Connection id is an increasing + // number, so this does not affect next _real_ 'conneting/connected' states. + symbianConfig->mutex.lock(); + iDeprecatedConnectionId = symbianConfig->connectionId; + symbianConfig->mutex.unlock(); newState(QNetworkSession::Closing); newState(QNetworkSession::Disconnected); } -- cgit v0.12 From d24c09fe2354135d233ca3374f0b6a7488f0615c Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 11 Jun 2010 13:42:13 +1000 Subject: Cherry pick fix for MOBILITY-800 from Qt Mobility. 21abc07dc396f08c888bf3cac96b535cc296cb00 --- .../bearer/symbian/qnetworksession_impl.cpp | 91 +++++++++------------- src/plugins/bearer/symbian/qnetworksession_impl.h | 1 - .../qnetworksession/test/tst_qnetworksession.cpp | 39 ++++++---- 3 files changed, 61 insertions(+), 70 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 1c581b6..15123be 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -56,8 +56,8 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) : CActive(CActive::EPriorityUserInput), engine(engine), iDynamicUnSetdefaultif(0), ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), iFirstSync(true), iStoppedByUser(false), - iClosedByUser(false), iDeprecatedConnectionId(0), - iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) + iClosedByUser(false), iError(QNetworkSession::UnknownSessionError), iALREnabled(0), + iConnectInBackground(false) { CActiveScheduler::Add(this); @@ -73,9 +73,9 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - "; if (iDynamicUnSetdefaultif) - qDebug() << "dynamic setdefaultif() resolution succeeded. "; + qDebug() << "dynamic unsetdefaultif() is present in PIPS library. "; else - qDebug() << "dynamic setdefaultif() resolution failed. "; + qDebug() << "dynamic unsetdefaultif() not present in PIPS library. "; #endif TRAP_IGNORE(iConnectionMonitor.ConnectL()); @@ -108,6 +108,9 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() iConnectionMonitor.Close(); iOpenCLibrary.Close(); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - destroyed (and setdefaultif(0))"; +#endif } void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState) @@ -115,18 +118,12 @@ void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId if (iHandleStateNotificationsFromManager) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "configurationStateChanged from manager for IAP : " << QString::number(accessPointId) - << "configurationStateChanged connMon ID : " << QString::number(connMonId) - << " : to a state: " << newState - << " whereas my current state is: " << state; -#endif - if (connMonId == iDeprecatedConnectionId) { -#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "however status update from manager ignored because it related to already closed connection."; + << "configurationStateChanged from manager for IAP : " << QString::number(accessPointId) + << "connMon ID : " << QString::number(connMonId) << " : to a state: " << newState + << "whereas my current state is: " << state; +#else + Q_UNUSED(connMonId); #endif - return; - } this->newState(newState, accessPointId); } } @@ -250,6 +247,14 @@ QNetworkInterface QNetworkSessionPrivateImpl::interface(TUint iapId) const #ifndef QT_NO_NETWORKINTERFACE QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "currentInterface() requested, state: " << state + << "publicConfig validity: " << publicConfig.isValid(); + if (activeInterface.isValid()) + qDebug() << "interface is: " << activeInterface.humanReadableName(); +#endif + if (!publicConfig.isValid() || state != QNetworkSession::Connected) { return QNetworkInterface(); } @@ -339,7 +344,6 @@ void QNetworkSessionPrivateImpl::open() // Clear possible previous states iStoppedByUser = false; iClosedByUser = false; - iDeprecatedConnectionId = 0; TInt error = iSocketServ.Connect(); if (error != KErrNone) { @@ -396,7 +400,11 @@ void QNetworkSessionPrivateImpl::open() if (!IsActive()) { SetActive(); } - newState(QNetworkSession::Connecting); + // Avoid flip flop of states if the configuration is already + // active. IsOpen/opened() will indicate when ready. + if (state != QNetworkSession::Connected) { + newState(QNetworkSession::Connecting); + } } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); @@ -420,7 +428,11 @@ void QNetworkSessionPrivateImpl::open() if (!IsActive()) { SetActive(); } - newState(QNetworkSession::Connecting); + // Avoid flip flop of states if the configuration is already + // active. IsOpen/opened() will indicate when ready. + if (state != QNetworkSession::Connected) { + newState(QNetworkSession::Connecting); + } } else if (publicConfig.type() == QNetworkConfiguration::UserChoice) { iKnownConfigsBeforeConnectionStart = engine->accessPointConfigurationIdentifiers(); iConnection.Start(iStatus); @@ -485,11 +497,6 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iClosedByUser = true; isOpen = false; -#ifndef OCC_FUNCTIONALITY_AVAILABLE - // On Symbian^3 we need to keep track of active configuration longer - // in case of empty-SNAP-triggered EasyWLAN. - activeConfig = QNetworkConfiguration(); -#endif serviceConfig = QNetworkConfiguration(); #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -525,25 +532,10 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // that does not seem to be trusted on all Symbian versions --> safest // to go down. if (publicConfig.type() == QNetworkConfiguration::UserChoice || state == QNetworkSession::Connecting) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - - symbianConfig->mutex.lock(); qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "going Disconnected right away. Deprecating connection monitor ID: " - << symbianConfig->connectionId; - symbianConfig->mutex.unlock(); + << "going disconnected right away, since either UserChoice or Connecting"; #endif - - // The connection has gone down, and processing of status updates must be - // stopped. Depending on platform, there may come 'connecting/connected' states - // considerably later (almost a second). Connection id is an increasing - // number, so this does not affect next _real_ 'conneting/connected' states. - symbianConfig->mutex.lock(); - iDeprecatedConnectionId = symbianConfig->connectionId; - symbianConfig->mutex.unlock(); newState(QNetworkSession::Closing); newState(QNetworkSession::Disconnected); } @@ -1191,6 +1183,12 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint return false; } + // Make sure that some lagging 'connecting' state-changes do not overwrite + // if we are already connected (may righfully still happen with roaming though). + if (state == QNetworkSession::Connected && newState == QNetworkSession::Connecting) { + return false; + } + bool emitSessionClosed = false; // If we abruptly go down and user hasn't closed the session, we've been aborted. @@ -1306,27 +1304,12 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint #endif } } - if (emitSessionClosed) { emit closed(); } if (state == QNetworkSession::Disconnected) { - // The connection has gone down, and processing of status updates must be - // stopped. Depending on platform, there may come 'connecting/connected' states - // considerably later (almost a second). Connection id is an increasing - // number, so this does not affect next _real_ 'conneting/connected' states. - - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - iDeprecatedConnectionId = symbianConfig->connectionId; - symbianConfig->mutex.unlock(); - -#ifdef OCC_FUNCTIONALITY_AVAILABLE // Just in case clear activeConfiguration. activeConfig = QNetworkConfiguration(); -#endif } return retVal; } diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 4b4f28c..284e771 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -167,7 +167,6 @@ private: // data bool iFirstSync; bool iStoppedByUser; bool iClosedByUser; - TUint32 iDeprecatedConnectionId; #ifdef SNAP_FUNCTIONALITY_AVAILABLE CActiveCommsMobilityApiExt* iMobility; diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index e4b8c14..24f6e52 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -680,7 +680,7 @@ void tst_QNetworkSession::sessionStop() QVERIFY(openSession(&innocentSession)); qDebug("Waiting for %d ms after open to make sure all platform indications are propagated", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); - qDebug("----------4.2 Calling closedSession.stop()"); + qDebug("----------4.2 Calling closedSession.stop()"); closedSession.stop(); qDebug("Waiting for %d ms to get all configurationChange signals from platform..", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals @@ -1088,21 +1088,28 @@ void tst_QNetworkSession::sessionOpenCloseStop() if (configuration.type() == QNetworkConfiguration::ServiceNetwork) { bool roamedSuccessfully = false; - QCOMPARE(stateChangedSpy2.count(), 4); + QNetworkSession::State state; + if (stateChangedSpy2.count() == 4) { + state = qvariant_cast(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Connecting); - QNetworkSession::State state = - qvariant_cast(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Connecting); + state = qvariant_cast(stateChangedSpy2.at(1).at(0)); + QVERIFY(state == QNetworkSession::Connected); - state = qvariant_cast(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Connected); + state = qvariant_cast(stateChangedSpy2.at(2).at(0)); + QVERIFY(state == QNetworkSession::Closing); - state = qvariant_cast(stateChangedSpy2.at(2).at(0)); - QVERIFY(state == QNetworkSession::Closing); + state = qvariant_cast(stateChangedSpy2.at(3).at(0)); + QVERIFY(state == QNetworkSession::Disconnected); + } else if (stateChangedSpy2.count() == 2) { + state = qvariant_cast(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Closing); - state = qvariant_cast(stateChangedSpy2.at(3).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); - + state = qvariant_cast(stateChangedSpy2.at(1).at(0)); + QVERIFY(state == QNetworkSession::Disconnected); + } else { + QFAIL("Unexpected amount of state changes when roaming."); + } QTRY_VERIFY(session.state() == QNetworkSession::Roaming || session.state() == QNetworkSession::Connected || @@ -1137,16 +1144,18 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(state == QNetworkSession::Roaming); } roamedSuccessfully = true; - } + } if (roamedSuccessfully) { + // Verify that you can open session based on the disconnected configuration QString configId = session.sessionProperty("ActiveConfiguration").toString(); - QNetworkConfiguration config = manager.configurationFromIdentifier(configId); + QNetworkConfiguration config = manager.configurationFromIdentifier(configId); QNetworkSession session3(config); QSignalSpy errorSpy3(&session3, SIGNAL(error(QNetworkSession::SessionError))); QSignalSpy sessionOpenedSpy3(&session3, SIGNAL(opened())); session3.open(); - session3.waitForOpened(); + session3.waitForOpened(); + QTest::qWait(1000); // Wait awhile to get all signals from platform if (session.isOpen()) QVERIFY(!sessionOpenedSpy3.isEmpty() || !errorSpy3.isEmpty()); session.stop(); -- cgit v0.12 From c5fa9ed38561a05325c798918e87549dd880af63 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 21 Jun 2010 15:55:18 +1000 Subject: Abort open early if network session is in the process of openning. --- .../bearer/symbian/qnetworksession_impl.cpp | 23 +++++++++++++++++----- src/plugins/bearer/symbian/qnetworksession_impl.h | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 15123be..b6e11df 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -57,7 +57,7 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) iDynamicUnSetdefaultif(0), ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iError(QNetworkSession::UnknownSessionError), iALREnabled(0), - iConnectInBackground(false) + iConnectInBackground(false), isOpening(false) { CActiveScheduler::Add(this); @@ -84,6 +84,7 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() { isOpen = false; + isOpening = false; // Cancel Connection Progress Notifications first. // Note: ConnectionNotifier must be destroyed before Canceling RConnection::Start() @@ -311,12 +312,14 @@ void QNetworkSessionPrivateImpl::open() #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "open() called, session state is: " << state << " and isOpen is: " - << isOpen; + << isOpen << isOpening; #endif - if (isOpen || (state == QNetworkSession::Connecting)) { + + if (isOpen || isOpening) return; - } - + + isOpening = true; + // Stop handling IAP state change signals from QNetworkConfigurationManagerPrivate // => RConnection::ProgressNotification will be used for IAP/SNAP monitoring iHandleStateNotificationsFromManager = false; @@ -444,6 +447,7 @@ void QNetworkSessionPrivateImpl::open() if (error != KErrNone) { isOpen = false; + isOpening = false; iError = QNetworkSession::UnknownSessionError; emit QNetworkSessionPrivate::error(iError); if (ipConnectionNotifier) { @@ -496,6 +500,7 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // when reporting. iClosedByUser = true; isOpen = false; + isOpening = false; serviceConfig = QNetworkConfiguration(); @@ -599,6 +604,7 @@ void QNetworkSessionPrivateImpl::stop() #endif // Since we are open, use RConnection to stop the interface isOpen = false; + isOpening = false; iStoppedByUser = true; newState(QNetworkSession::Closing); if (ipConnectionNotifier) { @@ -608,6 +614,7 @@ void QNetworkSessionPrivateImpl::stop() } iConnection.Stop(RConnection::EStopAuthoritative); isOpen = true; + isOpening = false; close(false); emit closed(); } @@ -742,6 +749,7 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) #endif if (isOpen) { isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::RoamingError; @@ -1048,6 +1056,7 @@ void QNetworkSessionPrivateImpl::RunL() if (error != KErrNone) { isOpen = false; + isOpening = false; iError = QNetworkSession::UnknownSessionError; QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); Cancel(); @@ -1066,6 +1075,7 @@ void QNetworkSessionPrivateImpl::RunL() #endif isOpen = true; + isOpening = false; activeConfig = newActiveConfig; SymbianNetworkConfigurationPrivate *symbianConfig = @@ -1089,6 +1099,7 @@ void QNetworkSessionPrivateImpl::RunL() break; case KErrNotFound: // Connection failed isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::InvalidConfigurationError; @@ -1103,6 +1114,7 @@ void QNetworkSessionPrivateImpl::RunL() case KErrAlreadyExists: // Connection already exists default: isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); if (publicConfig.state() == QNetworkConfiguration::Undefined || @@ -1202,6 +1214,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint // application or session stops connection or when network drops // unexpectedly). isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::SessionAbortedError; diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 284e771..0754ace 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -182,6 +182,8 @@ private: // data TUint32 iOldRoamingIap; TUint32 iNewRoamingIap; + bool isOpening; + friend class ConnectionProgressNotifier; }; -- cgit v0.12 From d63e7d8ec0c9337999a3d90b594eb3e955145de9 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 24 Jun 2010 10:34:56 +0200 Subject: QKeyEvent::text() inconsistency between Linux and Mac For a key event triggered by the cursor keys, QKeyEvent::text() returns char with value 0x14 or similar. This patch (Cocoa only)will remove text from all key events for the unicode range 0xF700-0xF747. This is part of the corporate unicode range used by apple for keyboard function keys. [http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT] Task-number: QTBUG-11225 Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qkeymapper_mac.cpp | 15 ++++++++++++++- src/gui/kernel/qt_cocoa_helpers_mac.mm | 7 ++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp index 873b8f9..3dc6afc 100644 --- a/src/gui/kernel/qkeymapper_mac.cpp +++ b/src/gui/kernel/qkeymapper_mac.cpp @@ -866,14 +866,27 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e UInt32 macModifiers = 0; GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0, sizeof(macModifiers), 0, &macModifiers); +#ifdef QT_MAC_USE_COCOA + // The unicode characters in the range 0xF700-0xF747 are reserved + // by Mac OS X for transient use as keyboard function keys. We + // wont send 'text' for such key events. This is done to match + // behavior on other platforms. + unsigned int *unicodeKey = (unsigned int*)info; + if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747) + text = QString(); + bool isAccepted; +#endif handled_event = QKeyMapper::sendKeyEvent(widget, grab, (ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress, qtKey, modifiers, text, ekind == kEventRawKeyRepeat, 0, macScanCode, macVirtualKey, macModifiers #ifdef QT_MAC_USE_COCOA - ,static_cast(info) + ,&isAccepted #endif ); +#ifdef QT_MAC_USE_COCOA + *unicodeKey = (unsigned int)isAccepted; +#endif } return handled_event; } diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 8cef03c..3fc27f4 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -682,10 +682,12 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve NSEvent *event = static_cast(keyEvent); EventRef key_event = static_cast(const_cast([event eventRef])); Q_ASSERT(key_event); + unsigned int info = 0; if ([event type] == NSKeyDown) { NSString *characters = [event characters]; unichar value = [characters characterAtIndex:0]; qt_keymapper_private()->updateKeyMap(0, key_event, (void *)&value); + info = value; } // Redirect keys to alien widgets. @@ -701,9 +703,8 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve if (mustUseCocoaKeyEvent()) return qt_dispatchKeyEventWithCocoa(keyEvent, widgetToGetEvent); - bool isAccepted; - bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &isAccepted, true); - return consumed && isAccepted; + bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &info, true); + return consumed && (info != 0); #endif } -- cgit v0.12 From b60be84ad8121f9562f1ab4193136426df6dc6d4 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 24 Jun 2010 10:18:18 +0200 Subject: Fixed memory restrictions not being passed on to elf2e32. Task: QTBUG-11351 RevBy: Trust me --- mkspecs/common/symbian/symbian-makefile.conf | 2 -- mkspecs/features/symbian/symbian_building.prf | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mkspecs/common/symbian/symbian-makefile.conf b/mkspecs/common/symbian/symbian-makefile.conf index ab0c5b9..b1ca367 100644 --- a/mkspecs/common/symbian/symbian-makefile.conf +++ b/mkspecs/common/symbian/symbian-makefile.conf @@ -14,8 +14,6 @@ QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< QMAKE_ELF2E32_FLAGS = --dlldata \ - --heap=0x00020000,0x00800000 \ - --stack=0x00014000 \ --fpu=softvfp \ --unfrozen \ --compressionmethod bytepair \ diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index 9fc4d1e..5861bb6 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -8,6 +8,9 @@ QMAKE_LFLAGS += -Ttext 0x80000 -Tdata 0x400000 } +isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000 +isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000 + symbianObjdir=$$OBJECTS_DIR isEmpty(symbianObjdir) { symbianObjdir = . @@ -114,6 +117,8 @@ contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) { --dso=$$symbianObjdir/$${TARGET}.dso \ --defoutput=$$symbianObjdir/$${TARGET}.def \ --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].dll \ + --heap=$$join(TARGET.EPOCHEAPSIZE, ",") \ + --stack=$$TARGET.EPOCSTACKSIZE \ $$elf2e32_LIBPATH \ $$capability \ $$QMAKE_ELF2E32_FLAGS \ @@ -163,6 +168,8 @@ contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@.*") { --elfinput=$${symbianDestdir}/$${TARGET}.sym \ --output=$${symbianDestdir}/$${TARGET}.exe \ --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].exe \ + --heap=$$join(TARGET.EPOCHEAPSIZE, ",") \ + --stack=$$TARGET.EPOCSTACKSIZE \ $$elf2e32_LIBPATH \ $$capability \ $$QMAKE_ELF2E32_FLAGS \ -- cgit v0.12 From 9f7a9b1272357a06cd721d64e66fcde1921bd325 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 24 Jun 2010 10:56:08 +0200 Subject: Updated Harfbuzz from git+ssh://git.freedesktop.org/git/harfbuzz to a80fd59e3b3b18116803a14e6369345933994236 * Disable data structure packing with RVCT, as it appears that the compiler miscompiles the code. --- src/3rdparty/harfbuzz/src/harfbuzz-global.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-global.h b/src/3rdparty/harfbuzz/src/harfbuzz-global.h index 5b2b679..bccd6a2 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-global.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-global.h @@ -39,7 +39,7 @@ #define HB_END_HEADER /* nothing */ #endif -#if defined(__GNUC__) || defined(__ARMCC__) || defined(__CC_ARM) || defined(_MSC_VER) +#if defined(__GNUC__) || defined(_MSC_VER) #define HB_USE_PACKED_STRUCTS #endif -- cgit v0.12 From d8ffdacc0aa0b22a02b8ac3bae03570049b65d5d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 24 Jun 2010 10:56:08 +0200 Subject: Updated Harfbuzz from git+ssh://git.freedesktop.org/git/harfbuzz to a80fd59e3b3b18116803a14e6369345933994236 * Disable data structure packing with RVCT, as it appears that the compiler miscompiles the code. --- src/3rdparty/harfbuzz/src/harfbuzz-global.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-global.h b/src/3rdparty/harfbuzz/src/harfbuzz-global.h index 5b2b679..bccd6a2 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-global.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-global.h @@ -39,7 +39,7 @@ #define HB_END_HEADER /* nothing */ #endif -#if defined(__GNUC__) || defined(__ARMCC__) || defined(__CC_ARM) || defined(_MSC_VER) +#if defined(__GNUC__) || defined(_MSC_VER) #define HB_USE_PACKED_STRUCTS #endif -- cgit v0.12 From 06aaa4bc68a1ee10d2a7bb8de4928c92ce84546d Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 24 Jun 2010 11:58:42 +0200 Subject: Revert "Fixing race condition in qeventdispatcher_symbian.cpp code path" This reverts commit 3a9ca8ba50a63e564c15023f65cbac36d365d309. It's the wrong fix for the problem. The socket operations in the select thread are not supposed to be thread safe. It is thread safe between the select thread and the caller thread, but not if there are more than one caller thread. Ensuring complete thread safety would probably require fixes in other areas as well. The correct fix is for the client to ensure that calls to the socket registering functions are either serialized or contained within one thread. Task: QT-3496 RevBy: Aleksandar Sasha Babic --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 101 ++++++++++-------------- src/corelib/kernel/qeventdispatcher_symbian_p.h | 5 -- 2 files changed, 40 insertions(+), 66 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 75b7619..d00a623 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -114,13 +114,9 @@ public: // is in select call if (m_selectCallMutex->tryLock()) { m_selectCallMutex->unlock(); - - //m_threadMutex->lock(); - //bHasThreadLock = true; return; } - char dummy = 0; qt_pipe_write(fd, &dummy, 1); @@ -409,14 +405,11 @@ void QSelectThread::run() FD_ZERO(&exceptionfds); int maxfd = 0; - { - QMutexLocker asoLocker(&m_AOStatusesMutex); - maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Read, &readfds)); - maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Write, &writefds)); - maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Exception, &exceptionfds)); - maxfd = qMax(maxfd, m_pipeEnds[0]); - maxfd++; - } + maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Read, &readfds)); + maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Write, &writefds)); + maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Exception, &exceptionfds)); + maxfd = qMax(maxfd, m_pipeEnds[0]); + maxfd++; FD_SET(m_pipeEnds[0], &readfds); @@ -461,42 +454,40 @@ void QSelectThread::run() FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptionfds); - { - QMutexLocker asoLocker(&m_AOStatusesMutex); - for (QHash::const_iterator i = m_AOStatuses.begin(); - i != m_AOStatuses.end(); ++i) { + for (QHash::const_iterator i = m_AOStatuses.begin(); + i != m_AOStatuses.end(); ++i) { - fd_set onefds; - FD_ZERO(&onefds); - FD_SET(i.key()->socket(), &onefds); + fd_set onefds; + FD_ZERO(&onefds); + FD_SET(i.key()->socket(), &onefds); - fd_set excfds; - FD_ZERO(&excfds); - FD_SET(i.key()->socket(), &excfds); + fd_set excfds; + FD_ZERO(&excfds); + FD_SET(i.key()->socket(), &excfds); - maxfd = i.key()->socket() + 1; + maxfd = i.key()->socket() + 1; - struct timeval timeout; - timeout.tv_sec = 0; - timeout.tv_usec = 0; + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; - ret = 0; + ret = 0; - if(i.key()->type() == QSocketNotifier::Read) { - ret = ::select(maxfd, &onefds, 0, &excfds, &timeout); - if(ret != 0) FD_SET(i.key()->socket(), &readfds); - } else if(i.key()->type() == QSocketNotifier::Write) { - ret = ::select(maxfd, 0, &onefds, &excfds, &timeout); - if(ret != 0) FD_SET(i.key()->socket(), &writefds); - } + if(i.key()->type() == QSocketNotifier::Read) { + ret = ::select(maxfd, &onefds, 0, &excfds, &timeout); + if(ret != 0) FD_SET(i.key()->socket(), &readfds); + } else if(i.key()->type() == QSocketNotifier::Write) { + ret = ::select(maxfd, 0, &onefds, &excfds, &timeout); + if(ret != 0) FD_SET(i.key()->socket(), &writefds); + } - } // end for + } // end for + + // traversed all, so update + updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); + updateActivatedNotifiers(QSocketNotifier::Read, &readfds); + updateActivatedNotifiers(QSocketNotifier::Write, &writefds); - // traversed all, so update - updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); - updateActivatedNotifiers(QSocketNotifier::Read, &readfds); - updateActivatedNotifiers(QSocketNotifier::Write, &writefds); - } break; case EINTR: // Should never occur on Symbian, but this is future proof! default: @@ -505,12 +496,9 @@ void QSelectThread::run() break; } } else { - { - QMutexLocker asoLocker(&m_AOStatusesMutex); - updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); - updateActivatedNotifiers(QSocketNotifier::Read, &readfds); - updateActivatedNotifiers(QSocketNotifier::Write, &writefds); - } + updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); + updateActivatedNotifiers(QSocketNotifier::Read, &readfds); + updateActivatedNotifiers(QSocketNotifier::Write, &writefds); } m_waitCond.wait(&m_mutex); @@ -529,16 +517,12 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta QMutexLocker locker(&m_grabberMutex); - { - // first do the thing - QMutexLocker aosLocker(&m_AOStatusesMutex); - Q_ASSERT(!m_AOStatuses.contains(notifier)); - m_AOStatuses.insert(notifier, status); - } - - // and now tell it to the others QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + Q_ASSERT(!m_AOStatuses.contains(notifier)); + + m_AOStatuses.insert(notifier, status); + m_waitCond.wakeAll(); } @@ -546,15 +530,10 @@ void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) { QMutexLocker locker(&m_grabberMutex); - { - // first do the thing - QMutexLocker aosLocker(&m_AOStatusesMutex); - m_AOStatuses.remove(notifier); - } - - // and now tell it to the others QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + m_AOStatuses.remove(notifier); + m_waitCond.wakeAll(); } diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 68d5833..7021314 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -231,11 +231,6 @@ private: // causes later in locking // of the thread in waitcond QMutex m_selectCallMutex; - - // Argh ... not again - // one more unprotected - // resource is m_AOStatuses - QMutex m_AOStatusesMutex; }; class Q_CORE_EXPORT CQtActiveScheduler : public CActiveScheduler -- cgit v0.12 From 7ae5285132db6c435e91ab097f41097217d68a2c Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 24 Jun 2010 10:57:23 +0200 Subject: Revert "Fixing the race condition in event dispatcher implementation on" This reverts commit 5f21450a61ba2459e6dc5b08b236b15a067bf81f. It's the wrong fix for the problem. The socket operations in the select thread are not supposed to be thread safe. It is thread safe between the select thread and the caller thread, but not if there are more than one caller thread. Ensuring complete thread safety would probably require fixes in other areas as well. The correct fix is for the client to ensure that calls to the socket registering functions are either serialized or contained within one thread. Task: QT-3358 RevBy: Aleksandar Sasha Babic --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 46 ++++++------------------- src/corelib/kernel/qeventdispatcher_symbian_p.h | 20 ----------- 2 files changed, 10 insertions(+), 56 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index d00a623..826caf2 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -100,40 +100,25 @@ static inline int qt_socket_select(int nfds, fd_set *readfds, fd_set *writefds, class QSelectMutexGrabber { public: - QSelectMutexGrabber(int fd, QMutex *threadMutex, QMutex *selectCallMutex) - : m_threadMutex(threadMutex), m_selectCallMutex(selectCallMutex), bHasThreadLock(false) + QSelectMutexGrabber(int fd, QMutex *mutex) + : m_mutex(mutex) { - // see if selectThread is waiting m_waitCond - // if yes ... dont write to pipe - if (m_threadMutex->tryLock()) { - bHasThreadLock = true; + if (m_mutex->tryLock()) return; - } - - // still check that SelectThread - // is in select call - if (m_selectCallMutex->tryLock()) { - m_selectCallMutex->unlock(); - return; - } char dummy = 0; qt_pipe_write(fd, &dummy, 1); - m_threadMutex->lock(); - bHasThreadLock = true; + m_mutex->lock(); } ~QSelectMutexGrabber() { - if(bHasThreadLock) - m_threadMutex->unlock(); + m_mutex->unlock(); } private: - QMutex *m_threadMutex; - QMutex *m_selectCallMutex; - bool bHasThreadLock; + QMutex *m_mutex; }; /* @@ -415,12 +400,7 @@ void QSelectThread::run() int ret; int savedSelectErrno; - { - // helps fighting the race condition between - // selctthread and new socket requests (cancel, restart ...) - QMutexLocker locker(&m_selectCallMutex); - ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0); - } + ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0); savedSelectErrno = errno; char buffer; @@ -515,9 +495,7 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta start(); } - QMutexLocker locker(&m_grabberMutex); - - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); Q_ASSERT(!m_AOStatuses.contains(notifier)); @@ -528,9 +506,7 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) { - QMutexLocker locker(&m_grabberMutex); - - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); m_AOStatuses.remove(notifier); @@ -539,9 +515,7 @@ void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) void QSelectThread::restart() { - QMutexLocker locker(&m_grabberMutex); - - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); m_waitCond.wakeAll(); } diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 7021314..8a9c9a0 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -211,26 +211,6 @@ private: QMutex m_mutex; QWaitCondition m_waitCond; bool m_quit; - - // to protect when several - // requests like: - // requestSocketEvents - // cancelSocketEvents - // kick in the same time - // all will fight for m_mutex - // - // TODO: fix more elegantely - // - QMutex m_grabberMutex; - - // this one will tell - // if selectthread is - // really in select call - // and will prevent - // writing to pipe that - // causes later in locking - // of the thread in waitcond - QMutex m_selectCallMutex; }; class Q_CORE_EXPORT CQtActiveScheduler : public CActiveScheduler -- cgit v0.12 From 598ba59b9d2e4b28469088d4ef12407b0c27514a Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 24 Jun 2010 12:32:42 +0200 Subject: Child windows shown automatically when their parent is shown(Cocoa). While setting up the stacking order for child windows, their hidden state was never taken into consideration. Task-number: QTBUG-11239 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwidget_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 280712a..a9bb691 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2804,7 +2804,7 @@ void QWidgetPrivate::setSubWindowStacking(bool set) QList widgets = q->findChildren(); for (int i=0; iisWindow() && child->testAttribute(Qt::WA_WState_Created)) { + if (child->isWindow() && child->testAttribute(Qt::WA_WState_Created) && child->isVisibleTo(q)) { if (set) [qt_mac_window_for(q) addChildWindow:qt_mac_window_for(child) ordered:NSWindowAbove]; else -- cgit v0.12 From 4df92b8b5e7f44d7a5e2b91f23638c92512b41f9 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 24 Jun 2010 12:45:27 +0200 Subject: Don't crash when cleaning the uninitialized fontdatabase (Symbian) Applications that do not render fonts will not cause a call to initializeDb(). In that case, there will be no creation of QSymbianFontDatabaseExtras. This fix adds a NULL-pointer check before cleaning the QSymbianFontDatabaseExtras instance. Task-number: QTBUG-11683 Reviewed-by: Miikka Heikkinen --- src/gui/text/qfontdatabase_s60.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 5148568..0b38aab 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -162,6 +162,8 @@ void qt_cleanup_symbianFontDatabaseExtras() { const QSymbianFontDatabaseExtrasImplementation *dbExtras = static_cast(privateDb()->symbianExtras); + if (!dbExtras) + return; // initializeDb() has never been called #ifdef Q_SYMBIAN_HAS_FONTTABLE_API qDeleteAll(dbExtras->m_extrasHash); #else // Q_SYMBIAN_HAS_FONTTABLE_API -- cgit v0.12 From 3119f5e2d675ba5d39e94cdae26db9eb8f373eab Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 24 Jun 2010 13:55:31 +0200 Subject: Moved the QML WebKit integration into QtWebKit.sis Reviewed-by: Alessandro Portale Reviewed-by: Janne Koskinen --- src/3rdparty/webkit/WebCore/WebCore.pro | 7 +++++++ src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro | 7 ------- src/s60installs/s60installs.pro | 7 ------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index f0e41bc..e208b5f 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -25,6 +25,13 @@ symbian: { webkitbackup.sources = ../WebKit/qt/symbian/backup_registration.xml webkitbackup.path = /private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,) + contains(QT_CONFIG, declarative): { + declarativeImport.sources = qmlwebkitplugin$${QT_LIBINFIX}.dll + declarativeImport.sources += ../WebKit/qt/declarative/qmldir + declarativeImport.path = c:$$QT_IMPORTS_BASE_DIR/QtWebKit + DEPLOYMENT += declarativeImport + } + DEPLOYMENT += webkitlibs webkitbackup # Need to guarantee that these come before system includes of /epoc32/include diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro index c75bbce..75268f3 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro +++ b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro @@ -67,13 +67,6 @@ qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH symbian:{ TARGET.UID3 = 0x20021321 - load(data_caging_paths) - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - - importFiles.sources = qmlwebkitplugin.dll qmldir - importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH - - DEPLOYMENT = importFiles } INSTALLS += target qmldir diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index a093e4c..4addb84 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -175,13 +175,6 @@ symbian: { particlesImport.path = c:$$QT_IMPORTS_BASE_DIR/Qt/labs/particles DEPLOYMENT += folderlistmodelImport gesturesImport particlesImport - - contains(QT_CONFIG, webkit): { - webkitImport.sources = $$QT_BUILD_TREE/imports/QtWebKit/qmlwebkitplugin$${QT_LIBINFIX}.dll - webkitImport.sources += $$QT_SOURCE_TREE/src/3rdparty/webkit/WebKit/qt/declarative/qmldir - webkitImport.path = c:$$QT_IMPORTS_BASE_DIR/QtWebKit - DEPLOYMENT += webkitImport - } } graphicssystems_plugins.path = c:$$QT_PLUGINS_BASE_DIR/graphicssystems -- cgit v0.12 From 9dc6dc38bf9035ec6460fa20159c33d5ad7084ca Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 24 Jun 2010 14:05:08 +0200 Subject: Updated WebKit to 2f598e9b7b376d851fe089bc1dc729bcf0393a06 * Fixed QML packaging || || Add an inlineCapacity template parameter to ListHashSet and use it to shrink the positioned object list hash set. || || || Allocate the m_preloads list hash set dynamically and free it when done. || || || Do not render the full frame when there is some elements with fixed positioning || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/JavaScriptCore/ChangeLog | 34 ++++ .../webkit/JavaScriptCore/wtf/ListHashSet.h | 206 ++++++++++----------- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 78 ++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- src/3rdparty/webkit/WebCore/loader/DocLoader.cpp | 15 +- src/3rdparty/webkit/WebCore/loader/DocLoader.h | 5 +- src/3rdparty/webkit/WebCore/page/FrameView.cpp | 12 +- .../webkit/WebCore/rendering/RenderBlock.cpp | 8 +- .../webkit/WebCore/rendering/RenderBlock.h | 9 +- .../webkit/WebCore/rendering/RenderLayer.cpp | 8 + .../webkit/WebCore/rendering/RenderLayer.h | 1 + src/3rdparty/webkit/WebKit/qt/ChangeLog | 16 ++ .../webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc | 4 +- 15 files changed, 274 insertions(+), 128 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 21b75f0..24cf142 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -b3589e88fb8d581fb523578763831109f914dc2e +2f598e9b7b376d851fe089bc1dc729bcf0393a06 diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 676ed23..8fa3a72 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,37 @@ +2010-05-18 Anders Carlsson + + Reviewed by Sam Weinig. + + Add an inlineCapacity template parameter to ListHashSet and use it to shrink the positioned object list hash set. + https://bugs.webkit.org/show_bug.cgi?id=39304 + + + Add an inlineCapacity template parameter to ListHashSet. + + * wtf/ListHashSet.h: + (WTF::::ListHashSet): + (WTF::::operator): + (WTF::::swap): + (WTF::::~ListHashSet): + (WTF::::size): + (WTF::::capacity): + (WTF::::isEmpty): + (WTF::::begin): + (WTF::::end): + (WTF::::find): + (WTF::::contains): + (WTF::::add): + (WTF::::insertBefore): + (WTF::::remove): + (WTF::::clear): + (WTF::::unlinkAndDelete): + (WTF::::appendNode): + (WTF::::insertNodeBefore): + (WTF::::deleteAllNodes): + (WTF::::makeIterator): + (WTF::::makeConstIterator): + (WTF::deleteAllValues): + 2010-06-18 Jocelyn Turcotte Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/ListHashSet.h b/src/3rdparty/webkit/JavaScriptCore/wtf/ListHashSet.h index 54ed36b..09355ad 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/ListHashSet.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/ListHashSet.h @@ -37,27 +37,27 @@ namespace WTF { // and an append that moves the element to the end even if already present, // but unclear yet if these are needed. - template class ListHashSet; + template class ListHashSet; template struct IdentityExtractor; - template - void deleteAllValues(const ListHashSet&); + template + void deleteAllValues(const ListHashSet&); - template class ListHashSetIterator; - template class ListHashSetConstIterator; + template class ListHashSetIterator; + template class ListHashSetConstIterator; - template struct ListHashSetNode; - template struct ListHashSetNodeAllocator; - template struct ListHashSetNodeHashFunctions; + template struct ListHashSetNode; + template struct ListHashSetNodeAllocator; + template struct ListHashSetNodeHashFunctions; - template::Hash> class ListHashSet : public FastAllocBase { + template::Hash> class ListHashSet : public FastAllocBase { private: - typedef ListHashSetNode Node; - typedef ListHashSetNodeAllocator NodeAllocator; + typedef ListHashSetNode Node; + typedef ListHashSetNodeAllocator NodeAllocator; typedef HashTraits NodeTraits; - typedef ListHashSetNodeHashFunctions NodeHash; + typedef ListHashSetNodeHashFunctions NodeHash; typedef HashTable, NodeHash, NodeTraits, NodeTraits> ImplType; typedef HashTableIterator, NodeHash, NodeTraits, NodeTraits> ImplTypeIterator; @@ -67,10 +67,10 @@ namespace WTF { public: typedef ValueArg ValueType; - typedef ListHashSetIterator iterator; - typedef ListHashSetConstIterator const_iterator; + typedef ListHashSetIterator iterator; + typedef ListHashSetConstIterator const_iterator; - friend class ListHashSetConstIterator; + friend class ListHashSetConstIterator; ListHashSet(); ListHashSet(const ListHashSet&); @@ -119,9 +119,9 @@ namespace WTF { OwnPtr m_allocator; }; - template struct ListHashSetNodeAllocator { - typedef ListHashSetNode Node; - typedef ListHashSetNodeAllocator NodeAllocator; + template struct ListHashSetNodeAllocator { + typedef ListHashSetNode Node; + typedef ListHashSetNodeAllocator NodeAllocator; ListHashSetNodeAllocator() : m_freeList(pool()) @@ -181,15 +181,15 @@ namespace WTF { Node* m_freeList; bool m_isDoneWithInitialFreeList; - static const size_t m_poolSize = 256; + static const size_t m_poolSize = inlineCapacity; union { char pool[sizeof(Node) * m_poolSize]; double forAlignment; } m_pool; }; - template struct ListHashSetNode { - typedef ListHashSetNodeAllocator NodeAllocator; + template struct ListHashSetNode { + typedef ListHashSetNodeAllocator NodeAllocator; ListHashSetNode(ValueArg value) : m_value(value) @@ -220,25 +220,25 @@ namespace WTF { #endif }; - template struct ListHashSetNodeHashFunctions { - typedef ListHashSetNode Node; + template struct ListHashSetNodeHashFunctions { + typedef ListHashSetNode Node; static unsigned hash(Node* const& key) { return HashArg::hash(key->m_value); } static bool equal(Node* const& a, Node* const& b) { return HashArg::equal(a->m_value, b->m_value); } static const bool safeToCompareToEmptyOrDeleted = false; }; - template class ListHashSetIterator { + template class ListHashSetIterator { private: - typedef ListHashSet ListHashSetType; - typedef ListHashSetIterator iterator; - typedef ListHashSetConstIterator const_iterator; - typedef ListHashSetNode Node; + typedef ListHashSet ListHashSetType; + typedef ListHashSetIterator iterator; + typedef ListHashSetConstIterator const_iterator; + typedef ListHashSetNode Node; typedef ValueArg ValueType; typedef ValueType& ReferenceType; typedef ValueType* PointerType; - friend class ListHashSet; + friend class ListHashSet; ListHashSetIterator(const ListHashSetType* set, Node* position) : m_iterator(set, position) { } @@ -271,18 +271,18 @@ namespace WTF { const_iterator m_iterator; }; - template class ListHashSetConstIterator { + template class ListHashSetConstIterator { private: - typedef ListHashSet ListHashSetType; - typedef ListHashSetIterator iterator; - typedef ListHashSetConstIterator const_iterator; - typedef ListHashSetNode Node; + typedef ListHashSet ListHashSetType; + typedef ListHashSetIterator iterator; + typedef ListHashSetConstIterator const_iterator; + typedef ListHashSetNode Node; typedef ValueArg ValueType; typedef const ValueType& ReferenceType; typedef const ValueType* PointerType; - friend class ListHashSet; - friend class ListHashSetIterator; + friend class ListHashSet; + friend class ListHashSetIterator; ListHashSetConstIterator(const ListHashSetType* set, Node* position) : m_set(set) @@ -341,11 +341,11 @@ namespace WTF { }; - template + template struct ListHashSetTranslator { private: - typedef ListHashSetNode Node; - typedef ListHashSetNodeAllocator NodeAllocator; + typedef ListHashSetNode Node; + typedef ListHashSetNodeAllocator NodeAllocator; public: static unsigned hash(const ValueType& key) { return HashFunctions::hash(key); } static bool equal(Node* const& a, const ValueType& b) { return HashFunctions::equal(a->m_value, b); } @@ -355,16 +355,16 @@ namespace WTF { } }; - template - inline ListHashSet::ListHashSet() + template + inline ListHashSet::ListHashSet() : m_head(0) , m_tail(0) , m_allocator(new NodeAllocator) { } - template - inline ListHashSet::ListHashSet(const ListHashSet& other) + template + inline ListHashSet::ListHashSet(const ListHashSet& other) : m_head(0) , m_tail(0) , m_allocator(new NodeAllocator) @@ -374,16 +374,16 @@ namespace WTF { add(*it); } - template - inline ListHashSet& ListHashSet::operator=(const ListHashSet& other) + template + inline ListHashSet& ListHashSet::operator=(const ListHashSet& other) { ListHashSet tmp(other); swap(tmp); return *this; } - template - inline void ListHashSet::swap(ListHashSet& other) + template + inline void ListHashSet::swap(ListHashSet& other) { m_impl.swap(other.m_impl); std::swap(m_head, other.m_head); @@ -391,95 +391,95 @@ namespace WTF { m_allocator.swap(other.m_allocator); } - template - inline ListHashSet::~ListHashSet() + template + inline ListHashSet::~ListHashSet() { deleteAllNodes(); } - template - inline int ListHashSet::size() const + template + inline int ListHashSet::size() const { return m_impl.size(); } - template - inline int ListHashSet::capacity() const + template + inline int ListHashSet::capacity() const { return m_impl.capacity(); } - template - inline bool ListHashSet::isEmpty() const + template + inline bool ListHashSet::isEmpty() const { return m_impl.isEmpty(); } - template - inline typename ListHashSet::iterator ListHashSet::begin() + template + inline typename ListHashSet::iterator ListHashSet::begin() { return makeIterator(m_head); } - template - inline typename ListHashSet::iterator ListHashSet::end() + template + inline typename ListHashSet::iterator ListHashSet::end() { return makeIterator(0); } - template - inline typename ListHashSet::const_iterator ListHashSet::begin() const + template + inline typename ListHashSet::const_iterator ListHashSet::begin() const { return makeConstIterator(m_head); } - template - inline typename ListHashSet::const_iterator ListHashSet::end() const + template + inline typename ListHashSet::const_iterator ListHashSet::end() const { return makeConstIterator(0); } - template - inline typename ListHashSet::iterator ListHashSet::find(const ValueType& value) + template + inline typename ListHashSet::iterator ListHashSet::find(const ValueType& value) { - typedef ListHashSetTranslator Translator; + typedef ListHashSetTranslator Translator; ImplTypeIterator it = m_impl.template find(value); if (it == m_impl.end()) return end(); return makeIterator(*it); } - template - inline typename ListHashSet::const_iterator ListHashSet::find(const ValueType& value) const + template + inline typename ListHashSet::const_iterator ListHashSet::find(const ValueType& value) const { - typedef ListHashSetTranslator Translator; + typedef ListHashSetTranslator Translator; ImplTypeConstIterator it = m_impl.template find(value); if (it == m_impl.end()) return end(); return makeConstIterator(*it); } - template - inline bool ListHashSet::contains(const ValueType& value) const + template + inline bool ListHashSet::contains(const ValueType& value) const { - typedef ListHashSetTranslator Translator; + typedef ListHashSetTranslator Translator; return m_impl.template contains(value); } - template - pair::iterator, bool> ListHashSet::add(const ValueType &value) + template + pair::iterator, bool> ListHashSet::add(const ValueType &value) { - typedef ListHashSetTranslator Translator; + typedef ListHashSetTranslator Translator; pair result = m_impl.template add(value, m_allocator.get()); if (result.second) appendNode(*result.first); return std::make_pair(makeIterator(*result.first), result.second); } - template - pair::iterator, bool> ListHashSet::insertBefore(iterator it, const ValueType& newValue) + template + pair::iterator, bool> ListHashSet::insertBefore(iterator it, const ValueType& newValue) { - typedef ListHashSetTranslator Translator; + typedef ListHashSetTranslator Translator; pair result = m_impl.template add(newValue, m_allocator.get()); if (result.second) insertNodeBefore(it.node(), *result.first); @@ -487,14 +487,14 @@ namespace WTF { } - template - pair::iterator, bool> ListHashSet::insertBefore(const ValueType& beforeValue, const ValueType& newValue) + template + pair::iterator, bool> ListHashSet::insertBefore(const ValueType& beforeValue, const ValueType& newValue) { return insertBefore(find(beforeValue), newValue); } - template - inline void ListHashSet::remove(iterator it) + template + inline void ListHashSet::remove(iterator it) { if (it == end()) return; @@ -502,14 +502,14 @@ namespace WTF { unlinkAndDelete(it.node()); } - template - inline void ListHashSet::remove(const ValueType& value) + template + inline void ListHashSet::remove(const ValueType& value) { remove(find(value)); } - template - inline void ListHashSet::clear() + template + inline void ListHashSet::clear() { deleteAllNodes(); m_impl.clear(); @@ -517,8 +517,8 @@ namespace WTF { m_tail = 0; } - template - void ListHashSet::unlinkAndDelete(Node* node) + template + void ListHashSet::unlinkAndDelete(Node* node) { if (!node->m_prev) { ASSERT(node == m_head); @@ -539,8 +539,8 @@ namespace WTF { node->destroy(m_allocator.get()); } - template - void ListHashSet::appendNode(Node* node) + template + void ListHashSet::appendNode(Node* node) { node->m_prev = m_tail; node->m_next = 0; @@ -556,8 +556,8 @@ namespace WTF { m_tail = node; } - template - void ListHashSet::insertNodeBefore(Node* beforeNode, Node* newNode) + template + void ListHashSet::insertNodeBefore(Node* beforeNode, Node* newNode) { if (!beforeNode) return appendNode(newNode); @@ -572,8 +572,8 @@ namespace WTF { m_head = newNode; } - template - void ListHashSet::deleteAllNodes() + template + void ListHashSet::deleteAllNodes() { if (!m_head) return; @@ -582,16 +582,16 @@ namespace WTF { node->destroy(m_allocator.get()); } - template - inline ListHashSetIterator ListHashSet::makeIterator(Node* position) + template + inline ListHashSetIterator ListHashSet::makeIterator(Node* position) { - return ListHashSetIterator(this, position); + return ListHashSetIterator(this, position); } - template - inline ListHashSetConstIterator ListHashSet::makeConstIterator(Node* position) const + template + inline ListHashSetConstIterator ListHashSet::makeConstIterator(Node* position) const { - return ListHashSetConstIterator(this, position); + return ListHashSetConstIterator(this, position); } template @@ -603,10 +603,10 @@ namespace WTF { delete (*it)->m_value; } - template - inline void deleteAllValues(const ListHashSet& collection) + template + inline void deleteAllValues(const ListHashSet& collection) { - deleteAllValues::ValueType>(collection.m_impl); + deleteAllValues::ValueType>(collection.m_impl); } } // namespace WTF diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 57c1cf6..924b120 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - b3589e88fb8d581fb523578763831109f914dc2e + 2f598e9b7b376d851fe089bc1dc729bcf0393a06 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 687b76b..a84f177 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,81 @@ +2010-06-24 Simon Hausmann + + Unreviewed Symbian build fix. + + The QML WebKit integration needs to be part of QtWebKit.sis + + * WebCore.pro: Deploy qmlwebkitplugin.dll. + +2010-06-23 Benjamin Poulain + + Reviewed by Kenneth Rohde Christiansen. + + Do not render the full frame when there is some elements with fixed positioning + https://bugs.webkit.org/show_bug.cgi?id=33150 + + Do not render the full frame when there is some elements with fixed positioning + https://bugs.webkit.org/show_bug.cgi?id=33150 + + The frame view take into acount the list of fixed object when scrolling + the view. If the number of object is lower than a certain threshold, the pixel + are blitted, and the invalidated area updated. + + * page/FrameView.cpp: + (WebCore::FrameView::addFixedObject): + (WebCore::FrameView::removeFixedObject): + (WebCore::FrameView::scrollContentsFastPath): + * page/FrameView.h: + * platform/ScrollView.cpp: + (WebCore::ScrollView::scrollContents): + (WebCore::ScrollView::scrollContentsFastPath): + * platform/ScrollView.h: + * rendering/RenderLayer.cpp: + (WebCore::RenderLayer::repaintRectIncludingDescendants): + * rendering/RenderLayer.h: + * rendering/RenderObject.cpp: + (WebCore::RenderObject::styleWillChange): + +2010-05-18 Anders Carlsson + + Reviewed by Sam Weinig. + + Allocate the m_preloads list hash set dynamically and free it when done. + https://bugs.webkit.org/show_bug.cgi?id=39309 + + + This saves about 6000 bytes on a fully loaded document. + + * loader/DocLoader.cpp: + (WebCore::DocLoader::requestPreload): + (WebCore::DocLoader::clearPreloads): + * loader/DocLoader.h: + +2010-05-18 Anders Carlsson + + Revert unintended indentation and unnecessary nested name specifier. + + * rendering/RenderBlock.cpp: + (WebCore::clipOutPositionedObjects): + (WebCore::RenderBlock::insertPositionedObject): + +2010-05-18 Anders Carlsson + + Reviewed by Sam Weinig. + + Add an inlineCapacity template parameter to ListHashSet and use it to shrink the positioned object list hash set. + https://bugs.webkit.org/show_bug.cgi?id=39304 + + + Set the inlineCapacity for the positionedObjects ListHashSet to 4 instead of 256. Since a RenderBlock usually has + few positioned objects, this saves memory. + + * WebCore.base.exp: + * rendering/RenderBlock.cpp: + (WebCore::clipOutPositionedObjects): + (WebCore::RenderBlock::insertPositionedObject): + * rendering/RenderBlock.h: + (WebCore::RenderBlock::positionedObjects): + 2010-06-22 Simon Hausmann Unreviewed Qt/Symbian build fix. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index e208b5f..1162a52 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -25,7 +25,7 @@ symbian: { webkitbackup.sources = ../WebKit/qt/symbian/backup_registration.xml webkitbackup.path = /private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,) - contains(QT_CONFIG, declarative): { + contains(QT_CONFIG, declarative) { declarativeImport.sources = qmlwebkitplugin$${QT_LIBINFIX}.dll declarativeImport.sources += ../WebKit/qt/declarative/qmldir declarativeImport.path = c:$$QT_IMPORTS_BASE_DIR/QtWebKit diff --git a/src/3rdparty/webkit/WebCore/loader/DocLoader.cpp b/src/3rdparty/webkit/WebCore/loader/DocLoader.cpp index 0053e7b..4597704 100644 --- a/src/3rdparty/webkit/WebCore/loader/DocLoader.cpp +++ b/src/3rdparty/webkit/WebCore/loader/DocLoader.cpp @@ -407,10 +407,14 @@ void DocLoader::requestPreload(CachedResource::Type type, const String& url, con encoding = charset.isEmpty() ? m_doc->frame()->loader()->encoding() : charset; CachedResource* resource = requestResource(type, url, encoding, true); - if (!resource || m_preloads.contains(resource)) + if (!resource || (m_preloads && m_preloads->contains(resource))) return; resource->increasePreloadCount(); - m_preloads.add(resource); + + if (!m_preloads) + m_preloads.set(new ListHashSet); + m_preloads->add(resource); + #if PRELOAD_DEBUG printf("PRELOADING %s\n", resource->url().latin1().data()); #endif @@ -421,8 +425,11 @@ void DocLoader::clearPreloads() #if PRELOAD_DEBUG printPreloadStats(); #endif - ListHashSet::iterator end = m_preloads.end(); - for (ListHashSet::iterator it = m_preloads.begin(); it != end; ++it) { + if (!m_preloads) + return; + + ListHashSet::iterator end = m_preloads->end(); + for (ListHashSet::iterator it = m_preloads->begin(); it != end; ++it) { CachedResource* res = *it; res->decreasePreloadCount(); if (res->canDelete() && !res->inCache()) diff --git a/src/3rdparty/webkit/WebCore/loader/DocLoader.h b/src/3rdparty/webkit/WebCore/loader/DocLoader.h index 8ec73e1..66e4164 100644 --- a/src/3rdparty/webkit/WebCore/loader/DocLoader.h +++ b/src/3rdparty/webkit/WebCore/loader/DocLoader.h @@ -47,8 +47,7 @@ class ImageLoader; class KURL; // The DocLoader manages the loading of scripts/images/stylesheets for a single document. -class DocLoader : public Noncopyable -{ +class DocLoader : public Noncopyable { friend class Cache; friend class ImageLoader; @@ -117,7 +116,7 @@ private: int m_requestCount; - ListHashSet m_preloads; + OwnPtr > m_preloads; struct PendingPreload { CachedResource::Type m_type; String m_url; diff --git a/src/3rdparty/webkit/WebCore/page/FrameView.cpp b/src/3rdparty/webkit/WebCore/page/FrameView.cpp index a53db36..639414b 100644 --- a/src/3rdparty/webkit/WebCore/page/FrameView.cpp +++ b/src/3rdparty/webkit/WebCore/page/FrameView.cpp @@ -884,7 +884,7 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect { const size_t fixedObjectThreshold = 5; - ListHashSet* positionedObjects = 0; + RenderBlock::PositionedObjectsListHashSet* positionedObjects = 0; if (RenderView* root = m_frame->contentRenderer()) positionedObjects = root->positionedObjects(); @@ -896,14 +896,14 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect // Get the rects of the fixed objects visible in the rectToScroll Vector subRectToUpdate; bool updateInvalidatedSubRect = true; - ListHashSet::const_iterator end = positionedObjects->end(); - for (ListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) { + RenderBlock::PositionedObjectsListHashSet::const_iterator end = positionedObjects->end(); + for (RenderBlock::PositionedObjectsListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) { RenderBox* renderBox = *it; if (renderBox->style()->position() != FixedPosition) continue; - IntRect topLevelRect; - IntRect updateRect = renderBox->paintingRootRect(topLevelRect); - updateRect.move(-scrollX(), -scrollY()); + IntRect updateRect = renderBox->layer()->repaintRectIncludingDescendants(); + updateRect = contentsToWindow(updateRect); + updateRect.intersect(rectToScroll); if (!updateRect.isEmpty()) { if (subRectToUpdate.size() >= fixedObjectThreshold) { diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.cpp index a7b8a02..798663e 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.cpp @@ -1982,13 +1982,13 @@ void RenderBlock::paintSelection(PaintInfo& paintInfo, int tx, int ty) } #ifndef BUILDING_ON_TIGER -static void clipOutPositionedObjects(const RenderObject::PaintInfo* paintInfo, int tx, int ty, ListHashSet* positionedObjects) +static void clipOutPositionedObjects(const RenderObject::PaintInfo* paintInfo, int tx, int ty, RenderBlock::PositionedObjectsListHashSet* positionedObjects) { if (!positionedObjects) return; - ListHashSet::const_iterator end = positionedObjects->end(); - for (ListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) { + RenderBlock::PositionedObjectsListHashSet::const_iterator end = positionedObjects->end(); + for (RenderBlock::PositionedObjectsListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) { RenderBox* r = *it; paintInfo->context->clipOut(IntRect(tx + r->x(), ty + r->y(), r->width(), r->height())); } @@ -2274,7 +2274,7 @@ void RenderBlock::insertPositionedObject(RenderBox* o) { // Create the list of special objects if we don't aleady have one if (!m_positionedObjects) - m_positionedObjects = new ListHashSet; + m_positionedObjects = new PositionedObjectsListHashSet; m_positionedObjects->add(o); } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h index 184f983..d555d31 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h @@ -74,7 +74,9 @@ public: void insertPositionedObject(RenderBox*); void removePositionedObject(RenderBox*); void removePositionedObjects(RenderBlock*); - ListHashSet* positionedObjects() const { return m_positionedObjects; } + + typedef ListHashSet PositionedObjectsListHashSet; + PositionedObjectsListHashSet* positionedObjects() const { return m_positionedObjects; } void addPercentHeightDescendant(RenderBox*); static void removePercentHeightDescendant(RenderBox*); @@ -483,9 +485,10 @@ private: void setCollapsedBottomMargin(const MarginInfo&); // End helper functions and structs used by layoutBlockChildren. - typedef ListHashSet::const_iterator Iterator; + typedef PositionedObjectsListHashSet::const_iterator Iterator; DeprecatedPtrList* m_floatingObjects; - ListHashSet* m_positionedObjects; + + PositionedObjectsListHashSet* m_positionedObjects; // An inline can be split with blocks occurring in between the inline content. // When this occurs we need a pointer to our next object. We can basically be diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp index 3314772..a012868 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp @@ -325,6 +325,14 @@ void RenderLayer::updateLayerPositions(UpdateLayerPositionsFlags flags) m_marquee->updateMarqueePosition(); } +IntRect RenderLayer::repaintRectIncludingDescendants() const +{ + IntRect repaintRect = m_repaintRect; + for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) + repaintRect.unite(child->repaintRectIncludingDescendants()); + return repaintRect; +} + void RenderLayer::computeRepaintRects() { RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint(); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h index 81a66e1..e221f28 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h @@ -394,6 +394,7 @@ public: // Return a cached repaint rect, computed relative to the layer renderer's containerForRepaint. IntRect repaintRect() const { return m_repaintRect; } + IntRect repaintRectIncludingDescendants() const; void computeRepaintRects(); void updateRepaintRectsAfterScroll(bool fixed = false); void setNeedsFullRepaint(bool f = true) { m_needsFullRepaint = f; } diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 050b1c1..69a431f 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,19 @@ +2010-06-24 Simon Hausmann + + Unreviewed Symbian build fix. + + The QML WebKit integration needs to be part of QtWebKit.sis + + * declarative/declarative.pro: Removed non-working deployment. + +2010-06-23 David Boddie + + Reviewed by Simon Hausmann. + + [Qt] Doc: Fixed documentation errors. + + * docs/qtwebkit-bridge.qdoc: + 2010-06-23 Alessandro Portale Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc index fa93293..c2a38fd 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc @@ -8,7 +8,7 @@ The QtWebKit bridge is a mechanism that extends WebKit's JavaScript environment to access native objects that are represented as \l{QObject}s. It takes advantage of the \l{QObject} introspection, - a part of the \l{Qt Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, + a part of the \l{Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, for example \l{QObject} properties map directly to JavaScript properties. For example, both JavaScript and QObjects have properties: a construct that represent a getter/setter @@ -24,7 +24,7 @@ applications. For example, an application that contains a media-player, playlist manager, and music store. The playlist manager is usually best authored as a classic desktop application, with the native-looking robust \l{QWidget}s helping with producing that application. - The media-player control, which usually looks custom, can be written using \l{The Graphics View framework} + The media-player control, which usually looks custom, can be written using the \l{Graphics View framework} or with in a declarative way with \l{QtDeclarative}. The music store, which shows dynamic content from the internet and gets modified rapidly, is best authored in HTML and maintained on the server. -- cgit v0.12 From 5b5ae51b22b57897dd61b9f8910e510757fa59c5 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 24 Jun 2010 14:07:49 +0200 Subject: Fixed several problems with the postlinker for Symbian (elf2e32). The fixes were too complicated for a profile and so a perl script was introduced. These are the issues that were addressed: - Made sure that we link correctly in all cases where there is a mismatch between the DEF file and the ELF file. Specifically, these two cases: - If elf2e32 detects a symbols in the ELF file that is marked as absent in the DEF file, an ordinal mapping will not be generated in the dso file. This means that binaries linking to the library will not find the symbol, even though it exists in the code. Since this is completely useless behavior, this was fixed to include the symbol regardless. - If the DEF file contains a symbol that is not present in the ELF file, an ordinal mapping will be created in the dso file regardless, which means applications can link to a symbol that does not exist. This is even worse than point one, since it is not detected until runtime, when the dynamic link will fail. Fixed by leaving the symbol out of the dso file if it does not exist in the ELF file. Both fixes require rerunning elf2e32 to fix the symbol mappings that were broken in the first run, but it only happens if at least one symbol is broken in the way described above. Also, freezing the DEF files will "save" the symbols, so that it does not occur after that. Note that this does not remove the ability to get the postlinker to tell you about mismatches. By doing "QMAKE_ELF2E32_FLAGS -= --unfrozen", the symbol mismatches will be considered errors instead of warnings, and they can be caught that way. - Code that was previously in the profile was moved to the perl script: - Detecting that there are errors in the postlink and return nonzero. elf2e32 does not do this on its own (at least not when using Wine). - Only overwriting the old dso file if the new one is different. This saves build time, since binaries that depend on the library do not trigger relink if the dso has not changed. These two points simplify the code, and they will also help the porting to Windows, since the old shell script tricks would not have worked there. RevBy: Trust me --- bin/elf2e32_qtwrapper | 145 ++++++++++++++++++++++++++ mkspecs/features/symbian/def_files.prf | 4 +- mkspecs/features/symbian/symbian_building.prf | 13 +-- 3 files changed, 151 insertions(+), 11 deletions(-) create mode 100755 bin/elf2e32_qtwrapper diff --git a/bin/elf2e32_qtwrapper b/bin/elf2e32_qtwrapper new file mode 100755 index 0000000..694d54a --- /dev/null +++ b/bin/elf2e32_qtwrapper @@ -0,0 +1,145 @@ +#!/usr/bin/perl -w + +# A script to get around some shortcomings in elf2e32, namely: +# - Returning 0 even when there are errors. +# - Excluding symbols from the dso file even when they are present in the ELF file. +# - Including symbols in the the dso file even when they are not present in the ELF file. +# - Overwriting the old dso file even when there are no changes (increases build time). + +use File::Copy; + +my @args = (); +my @definput; +my @defoutput; +my @dso; +my @tmpdso; +foreach (@ARGV) { + if (/^--definput/o) { + @definput = split('=', $_); + } elsif (/^--defoutput/o) { + @defoutput = split('=', $_); + } elsif (/^--dso/o) { + @dso = split('=', $_); + } elsif (/^--tmpdso/o) { + @tmpdso = split('=', $_); + $tmpdso[0] = "--dso"; + } else { + push(@args, $_); + } +} + +@definput = () if (!@definput || ! -e $definput[1]); + +if (@dso && !@tmpdso || !@dso && @tmpdso) { + print("--dso and --tmpdso must be used together.\n"); + exit 1; +} + +my $buildingLibrary = (@defoutput && @dso) ? 1 : 0; + +my $fixupFile = ""; +my $runCount = 0; +my $returnCode = 0; + +while (1) { + if (++$runCount > 2) { + print("Internal error in $0, link succeeded, but exports may be wrong.\n"); + last; + } + + my $elf2e32Pipe; + my $elf2e32Cmd = "elf2e32 @args" + . " " . join("=", @definput) + . " " . join("=", @defoutput) + . " " . join("=", @tmpdso); + open($elf2e32Pipe, "$elf2e32Cmd 2>&1 |") or die ("Could not run elf2e32"); + + my %fixupSymbols; + my $foundBrokenSymbols = 0; + my $errors = 0; + while (<$elf2e32Pipe>) { + print; + if (/Error:/io) { + $errors = 1; + } elsif (/symbol ([a-z0-9_]+) absent in the DEF file, but present in the ELF file/io) { + $fixupSymbols{$1} = 1; + $foundBrokenSymbols = 1; + } elsif (/[0-9]+ Frozen Export\(s\) missing from the ELF file/io) { + $foundBrokenSymbols = 1; + } + } + close($elf2e32Pipe); + + if ($errors) { + $returnCode = 1; + last; + } + + if ($buildingLibrary) { + my $tmpDefFile; + my $defFile; + open($defFile, "< $defoutput[1]") or die("Could not open $defoutput[1]"); + open($tmpDefFile, "> $defoutput[1].tmp") or die("Could not open $defoutput[1].tmp"); + $fixupFile = "$defoutput[1].tmp"; + while (<$defFile>) { + s/\r//; + s/\n//; + next if (/; NEW:/); + if (/([a-z0-9_]+) @/i) { + if (exists($fixupSymbols{$1})) { + s/ ABSENT//; + } elsif (s/; MISSING://) { + s/$/ ABSENT/; + } + } + print($tmpDefFile "$_\n"); + } + close($defFile); + close($tmpDefFile); + + $definput[1] = "$defoutput[1].tmp"; + + if (!$foundBrokenSymbols || $errors) { + last; + } + + print("Rerunning elf2e32 due to DEF file / ELF file mismatch\n"); + } else { + last; + } +}; + +if ($fixupFile) { + unlink($defoutput[1]); + move($fixupFile, $defoutput[1]); +} + +exit $returnCode if ($returnCode != 0); + +if ($buildingLibrary) { + my $differenceFound = 0; + + if (-e $dso[1]) { + my $dsoFile; + my $tmpdsoFile; + my $dsoBuf; + my $tmpdsoBuf; + open($dsoFile, "< $dso[1]") or die("Could not open $dso[1]"); + open($tmpdsoFile, "< $tmpdso[1]") or die("Could not open $tmpdso[1]"); + binmode($dsoFile); + binmode($tmpdsoFile); + while(read($dsoFile, $dsoBuf, 4096) && read($tmpdsoFile, $tmpdsoBuf, 4096)) { + if ($dsoBuf ne $tmpdsoBuf) { + $differenceFound = 1; + } + } + close($tmpdsoFile); + close($dsoFile); + } else { + $differenceFound = 1; + } + + if ($differenceFound) { + copy($tmpdso[1], $dso[1]); + } +} diff --git a/mkspecs/features/symbian/def_files.prf b/mkspecs/features/symbian/def_files.prf index 1b8e551..bae9d2d 100644 --- a/mkspecs/features/symbian/def_files.prf +++ b/mkspecs/features/symbian/def_files.prf @@ -56,7 +56,7 @@ symbian-abld|symbian-sbsv2 { } else { elf2e32FileToAdd = $$_PRO_FILE_PWD_/$$defFile } - QMAKE_ELF2E32_FLAGS += "`test -e $$elf2e32FileToAdd && echo --definput=$$elf2e32FileToAdd`" + QMAKE_ELF2E32_FLAGS += "--definput=$$elf2e32FileToAdd" symbianObjdir = $$OBJECTS_DIR isEmpty(symbianObjdir):symbianObjdir = . @@ -64,7 +64,7 @@ symbian-abld|symbian-sbsv2 { freeze_target.target = freeze freeze_target.depends = first # The perl part is to convert to unix line endings and remove comments, which the s60 tools refuse to do. - freeze_target.commands = perl -n -e \'next if (/; NEW/); s/\\r//g; if (/MISSING:(.*)/x) { print(\"\$\$1 ABSENT\\n\"); } else { print; }\' < $$symbianObjdir/$${TARGET}.def > $$elf2e32FileToAdd + freeze_target.commands = $$QMAKE_COPY $$symbianObjdir/$${TARGET}.def $$elf2e32FileToAdd QMAKE_EXTRA_TARGETS += freeze_target } else:contains(TEMPLATE, subdirs) { freeze_target.target = freeze diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index 5861bb6..bdab8d5 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -106,7 +106,7 @@ contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) { # The comparison of dso files is to avoid extra building of modules that depend on this dso, in # case it has not changed. QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${TARGET}.dll $$symbianDestdir/$${TARGET}.sym \ - && elf2e32 --version=$$decVersion \ + && elf2e32_qtwrapper --version=$$decVersion \ --sid=$$TARGET.SID \ --uid1=0x10000079 \ --uid2=$$TARGET.UID2 \ @@ -114,7 +114,8 @@ contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) { --targettype=DLL \ --elfinput=$${symbianDestdir}/$${TARGET}.sym \ --output=$${symbianDestdir}/$${TARGET}.dll \ - --dso=$$symbianObjdir/$${TARGET}.dso \ + --tmpdso=$${symbianObjdir}/$${TARGET}.dso \ + --dso=$${symbianDestdir}/$${TARGET}.dso \ --defoutput=$$symbianObjdir/$${TARGET}.def \ --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].dll \ --heap=$$join(TARGET.EPOCHEAPSIZE, ",") \ @@ -122,11 +123,6 @@ contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) { $$elf2e32_LIBPATH \ $$capability \ $$QMAKE_ELF2E32_FLAGS \ - | tee elf2e32.log && test `grep -c 'Error:' elf2e32.log` = 0 && rm elf2e32.log \ - && if ! diff -q $${symbianObjdir}/$${TARGET}.dso $${symbianDestdir}/$${TARGET}.dso \ - > /dev/null 2>&1; then \ - $$QMAKE_COPY $${symbianObjdir}/$${TARGET}.dso $${symbianDestdir}/$${TARGET}.dso; \ - fi \ $$QMAKE_POST_LINK QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.sym QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.dso @@ -159,7 +155,7 @@ contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@.*") { } # the tee and grep at the end work around the issue that elf2e32 doesn't return non-null on error QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${TARGET} $$symbianDestdir/$${TARGET}.sym \ - && elf2e32 --version $$decVersion \ + && elf2e32_qtwrapper --version $$decVersion \ --sid=$$TARGET.SID \ --uid1=0x1000007a \ --uid2=$$TARGET.UID2 \ @@ -173,7 +169,6 @@ contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@.*") { $$elf2e32_LIBPATH \ $$capability \ $$QMAKE_ELF2E32_FLAGS \ - | tee elf2e32.log && test `grep -c 'Error:' elf2e32.log` = 0 && rm elf2e32.log \ && ln "$${symbianDestdir}/$${TARGET}.exe" "$${symbianDestdir}/$$TARGET" \ $$QMAKE_POST_LINK QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.sym -- cgit v0.12 From d806b996beab76cbc43ffa11bc38721fa19c9c81 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 24 Jun 2010 15:02:02 +0200 Subject: No more enter & leave events after a popup menu is closed on Windows We use the TrackMouseEvent() to keep track of enter and leave messages. Upon receiving a WM_MOUSELEAVE, the effect of that function call is over, we need to call it again if we need more messages. This was not done when we close a popup because of mouse click outside. Task-number: QTBUG-11582 Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qapplication_win.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 2a85fdc..ef719ca 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -3065,6 +3065,11 @@ bool QETWidget::translateMouseEvent(const MSG &msg) break; } } +#ifndef Q_OS_WINCE + static bool trackMouseEventLookup = false; + typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT); + static PtrTrackMouseEvent ptrTrackMouseEvent = 0; +#endif state = translateButtonState(msg.wParam, type, button); // button state const QPoint widgetPos = mapFromGlobal(QPoint(msg.pt.x, msg.pt.y)); QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos); @@ -3129,9 +3134,6 @@ bool QETWidget::translateMouseEvent(const MSG &msg) #ifndef Q_OS_WINCE if (curWin != 0) { - static bool trackMouseEventLookup = false; - typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT); - static PtrTrackMouseEvent ptrTrackMouseEvent = 0; if (!trackMouseEventLookup) { trackMouseEventLookup = true; ptrTrackMouseEvent = (PtrTrackMouseEvent)QLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent"); @@ -3245,6 +3247,21 @@ bool QETWidget::translateMouseEvent(const MSG &msg) qt_button_down = 0; } +#ifndef Q_OS_WINCE + if (type == QEvent::MouseButtonPress + && QApplication::activePopupWidget() != activePopupWidget + && ptrTrackMouseEvent + && curWin) { + // Since curWin is already the window we clicked on, + // we have to setup the mouse tracking here. + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = 0x00000002; // TME_LEAVE + tme.hwndTrack = curWin; // Track on window receiving msgs + tme.dwHoverTime = (DWORD)-1; // HOVER_DEFAULT + ptrTrackMouseEvent(&tme); + } +#endif if (type == QEvent::MouseButtonPress && QApplication::activePopupWidget() != activePopupWidget && replayPopupMouseEvent) { -- cgit v0.12 From 0531b97863f93c5a141bd9ef0b58bcf6282024e7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 24 Jun 2010 15:27:13 +0200 Subject: Manipulate buffer position via 'pPos' in peek() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Abecasis --- src/corelib/io/qiodevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index ea60792..26e587d 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1452,7 +1452,7 @@ qint64 QIODevicePrivate::peek(char *data, qint64 maxSize) return readBytes; buffer.ungetBlock(data, readBytes); - pos -= readBytes; + *pPos -= readBytes; return readBytes; } @@ -1467,7 +1467,7 @@ QByteArray QIODevicePrivate::peek(qint64 maxSize) return result; buffer.ungetBlock(result.constData(), result.size()); - pos -= result.size(); + *pPos -= result.size(); return result; } -- cgit v0.12 From 415eab3eab1a037badec279dbfd41278f0f92719 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 24 Jun 2010 15:15:28 +0200 Subject: Fixed make runonphone that looked for the package in the wrong place. Task: QTBUG-11670 RevBy: Trust me --- mkspecs/features/symbian/run_on_phone.prf | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/symbian/run_on_phone.prf b/mkspecs/features/symbian/run_on_phone.prf index 6948a48..818151a 100644 --- a/mkspecs/features/symbian/run_on_phone.prf +++ b/mkspecs/features/symbian/run_on_phone.prf @@ -11,9 +11,13 @@ else:!equals(DEPLOYMENT, default_deployment) { } equals(GENERATE_RUN_TARGETS, true) { - sis_destdir = $$DESTDIR - !isEmpty(sis_destdir):!contains(sis_destdir, "[/\\\\]$"):sis_destdir = $${sis_destdir}/ - contains(QMAKE_HOST.os, "Windows"):sis_destdir = $$replace(sis_destdir, "/", "\\") + symbian-abld|symbian-sbsv2 { + sis_destdir = + } else { + sis_destdir = $$DESTDIR + !isEmpty(sis_destdir):!contains(sis_destdir, "[/\\\\]$"):sis_destdir = $${sis_destdir}/ + contains(QMAKE_HOST.os, "Windows"):sis_destdir = $$replace(sis_destdir, "/", "\\") + } contains(SYMBIAN_PLATFORMS, "WINSCW"):contains(TEMPLATE, "app") { run_target.target = run -- cgit v0.12 From 7bc00632dde1b718cbe1412e988ad006dc3d125f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 24 Jun 2010 15:11:05 +0200 Subject: Add a new (internal) flag QGraphicsItem::ItemStopsClickFocusPropagation. This flag allows you to create a non-focusable item that can be clicked on without changing the focus. This is also possible to achieve by using focus scopes / panels, however the implementation is then way more complex. Thew new flag is tailored for simple uses cases where you simply want to stop the propagation and nothing more. Auto test included. Task-number: QT-3499 Reviewed-by: yoann --- src/gui/graphicsview/qgraphicsitem.cpp | 8 ++++ src/gui/graphicsview/qgraphicsitem.h | 3 +- src/gui/graphicsview/qgraphicsitem_p.h | 6 +-- src/gui/graphicsview/qgraphicsscene.cpp | 2 + tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 54 ++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 2de3638..61285d2 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -411,6 +411,11 @@ these notifications are disabled by default. You must enable this flag to receive notifications for scene position changes. This flag was introduced in Qt 4.6. + + \omitvalue ItemStopsClickFocusPropagation \omit The item stops propagating + click focus to items underneath when being clicked on. This flag + allows you create a non-focusable item that can be clicked on without + changing the focus. \endomit */ /*! @@ -11432,6 +11437,9 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag) case QGraphicsItem::ItemSendsScenePositionChanges: str = "ItemSendsScenePositionChanges"; break; + case QGraphicsItem::ItemStopsClickFocusPropagation: + str = "ItemStopsClickFocusPropagation"; + break; } debug << str; return debug; diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index d7d5332..3c193cd 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -106,7 +106,8 @@ public: ItemNegativeZStacksBehindParent = 0x2000, ItemIsPanel = 0x4000, ItemIsFocusScope = 0x8000, // internal - ItemSendsScenePositionChanges = 0x10000 + ItemSendsScenePositionChanges = 0x10000, + ItemStopsClickFocusPropagation = 0x20000 // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag. }; Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index bde6e7d..f9f5d3d 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -556,7 +556,7 @@ public: quint32 dirtyChildrenBoundingRect : 1; // Packed 32 bits - quint32 flags : 17; + quint32 flags : 18; quint32 paintedViewBoundingRectsNeedRepaint : 1; quint32 dirtySceneTransform : 1; quint32 geometryChanged : 1; @@ -571,9 +571,9 @@ public: quint32 notifyBoundingRectChanged : 1; quint32 notifyInvalidated : 1; quint32 mouseSetsFocus : 1; - quint32 explicitActivate : 1; // New 32 bits + quint32 explicitActivate : 1; quint32 wantsActive : 1; quint32 holesInSiblingIndex : 1; quint32 sequentialOrdering : 1; @@ -582,7 +582,7 @@ public: quint32 pendingPolish : 1; quint32 mayHaveChildWithGraphicsEffect : 1; quint32 isDeclarativeItem : 1; - quint32 padding : 24; + quint32 padding : 23; // Optional stacking order int globalStackingOrder; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index ca3b56f..d04074a 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1336,6 +1336,8 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou break; } } + if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation) + break; if (item->isPanel()) break; } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index fe68c8e..31a6845 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -442,6 +442,7 @@ private slots: void updateMicroFocus(); void textItem_shortcuts(); void scroll(); + void stopClickFocusPropagation(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -10268,6 +10269,59 @@ void tst_QGraphicsItem::scroll() QCOMPARE(item2->lastExposedRect, expectedItem2Expose); } +void tst_QGraphicsItem::stopClickFocusPropagation() +{ + class MyItem : public QGraphicsRectItem + { + public: + MyItem() : QGraphicsRectItem(0, 0, 100, 100) {} + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->fillRect(boundingRect(), hasFocus() ? QBrush(Qt::red) : brush()); + } + }; + + QGraphicsScene scene(-50, -50, 400, 400); + scene.setStickyFocus(true); + + QGraphicsRectItem *noFocusOnTop = new MyItem; + noFocusOnTop->setBrush(Qt::yellow); + noFocusOnTop->setFlag(QGraphicsItem::ItemStopsClickFocusPropagation); + + QGraphicsRectItem *focusableUnder = new MyItem; + focusableUnder->setBrush(Qt::blue); + focusableUnder->setFlag(QGraphicsItem::ItemIsFocusable); + focusableUnder->setPos(50, 50); + + QGraphicsRectItem *itemWithFocus = new MyItem; + itemWithFocus->setBrush(Qt::black); + itemWithFocus->setFlag(QGraphicsItem::ItemIsFocusable); + itemWithFocus->setPos(250, 10); + + scene.addItem(noFocusOnTop); + scene.addItem(focusableUnder); + scene.addItem(itemWithFocus); + focusableUnder->stackBefore(noFocusOnTop); + itemWithFocus->setFocus(); + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QApplication::setActiveWindow(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); + QVERIFY(itemWithFocus->hasFocus()); + + QPointF mousePressPoint = noFocusOnTop->mapToScene(QPointF()); + mousePressPoint.rx() += 60; + mousePressPoint.ry() += 60; + const QList itemsAtMousePressPosition = scene.items(mousePressPoint); + QVERIFY(itemsAtMousePressPosition.contains(focusableUnder)); + + sendMousePress(&scene, mousePressPoint); + QVERIFY(itemWithFocus->hasFocus()); +} + void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() { struct Item : public QGraphicsTextItem -- cgit v0.12 From 8d88f35f5f5c06277e2a54b6aea48b7f3e2e1c51 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 24 Jun 2010 16:23:16 +0200 Subject: Fixed incorrect parsing of TARGET.EPOCHEAPSIZE. RevBy: Trust me --- mkspecs/features/symbian/symbian_building.prf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index bdab8d5..08ab3e7 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -10,6 +10,8 @@ isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000 isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000 +epoc_heap_size = $$split(TARGET.EPOCHEAPSIZE, " ") +epoc_heap_size = $$join(epoc_heap_size, ",") symbianObjdir=$$OBJECTS_DIR isEmpty(symbianObjdir) { @@ -118,7 +120,7 @@ contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) { --dso=$${symbianDestdir}/$${TARGET}.dso \ --defoutput=$$symbianObjdir/$${TARGET}.def \ --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].dll \ - --heap=$$join(TARGET.EPOCHEAPSIZE, ",") \ + --heap=$$epoc_heap_size \ --stack=$$TARGET.EPOCSTACKSIZE \ $$elf2e32_LIBPATH \ $$capability \ @@ -164,7 +166,7 @@ contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@.*") { --elfinput=$${symbianDestdir}/$${TARGET}.sym \ --output=$${symbianDestdir}/$${TARGET}.exe \ --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].exe \ - --heap=$$join(TARGET.EPOCHEAPSIZE, ",") \ + --heap=$$epoc_heap_size \ --stack=$$TARGET.EPOCSTACKSIZE \ $$elf2e32_LIBPATH \ $$capability \ -- cgit v0.12 From 72acc2eac69a5f58f8d99c25cb58f0afaebec7a4 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Thu, 24 Jun 2010 13:38:49 +0200 Subject: qmake: Fix CONFIG += exceptions_off with the MSVC project generator, take 2. The previous patch caused the pch header to be compiled without exception handling since the compilertool for the pch compilation do not get its options filled from the compiler flags. This patch instead set the value to off before calling parseOptions. This also reverts commit 73fa311f67b21c9b897de0196d3b8227f27d828f. Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msbuild_objectmodel.cpp | 1 - qmake/generators/win32/msvc_objectmodel.cpp | 7 ++----- qmake/generators/win32/msvc_vcproj.cpp | 1 + qmake/generators/win32/msvc_vcxproj.cpp | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index bf874b2..75fc910 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -385,7 +385,6 @@ VCXCLCompilerTool::VCXCLCompilerTool() DisableLanguageExtensions(unset), EnableFiberSafeOptimizations(unset), EnablePREfast(unset), - ExceptionHandling("false"), ExpandAttributedSource(unset), FloatingPointExceptions(unset), ForceConformanceInForLoopScope(unset), diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index e23e119..1e060a0 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -360,11 +360,8 @@ inline XmlOutput::xml_output xformUsePrecompiledHeaderForNET2005(pchOption whatP inline XmlOutput::xml_output xformExceptionHandlingNET2005(exceptionHandling eh, DotNET compilerVersion) { - if (eh == ehDefault) { - if (compilerVersion >= NET2005) - return attrE(_ExceptionHandling, ehNone); - return attrS(_ExceptionHandling, "false"); - } + if (eh == ehDefault) + return noxml(); if (compilerVersion >= NET2005) return attrE(_ExceptionHandling, eh); diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 35e4896..8686ae8 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -900,6 +900,7 @@ void VcprojGenerator::initCompilerTool() conf.compiler.AssemblerListingLocation = placement ; conf.compiler.ProgramDataBaseFileName = ".\\" ; conf.compiler.ObjectFile = placement ; + conf.compiler.ExceptionHandling = ehNone; // PCH if (usePCH) { conf.compiler.UsePrecompiledHeader = pchUseUsingSpecific; diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index 05c1511..f68a435 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -274,6 +274,7 @@ void VcxprojGenerator::initCompilerTool() conf.compiler.AssemblerListingLocation = placement ; conf.compiler.ProgramDataBaseFileName = ".\\" ; conf.compiler.ObjectFileName = placement ; + conf.compiler.ExceptionHandling = "false"; // PCH if (usePCH) { conf.compiler.PrecompiledHeader = "Use"; -- cgit v0.12 From a91f8d704c3ff3826f0ea8b7e73fc6d91dd5b836 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 23 Jun 2010 17:22:47 +0200 Subject: Use custom static scopes to improve QML/JavaScript performance This commit introduces a new internal JS object type, QScriptStaticScopeObject, that enables the JS compiler to make more aggressive optimizations of scoped property access. QScriptStaticScopeObject registers all its properties in a symbol table that the JS compiler has access to. If the compiler finds the property in the symbol table, it will generate the fast index-based op_{get,put}_scoped_var bytecodes, rather than the dynamic (slow) op_resolve and friends. If the compiler _doesn't_ find the property in the symbol table, it infers that it's safe to skip the scope object when later resolving the property, which will also improve performance (see op_resolve_skip bytecode). QScriptStaticScopeObject is only safe to use when all relevant properties are known at JS compile time; that is, when a function that has the static scope object in its scope chain is compiled. It's up to the user of the class (e.g. QtDeclarative) to ensure that this constraint is not violated. The API for constructing QScriptStaticScopeObject instances is not public; it lives in QScriptDeclarativeClass for now, an internal class exported for the purpose of QML. The instance is returned as a QScriptValue and can be manipulated like any other JS object (e.g. by QScriptValue::setProperty()). The other part of this commit utilizes QScriptStaticScopeObject in QtDeclarative in the two major places where it's currently possible: 1) QML disallows adding properties to the Global Object. Furthermore, it's not possible for QML IDs and properties to "shadow" global variables. Hence, a QScriptStaticScopeObject can be used to hold all the standard ECMA properties, and this scope object can come _before_ the QML component in the scope chain. This enables binding expressions and scripts to have optimized (direct) access to e.g. Math.sin. 2) Imported scripts can have their properties (resulting from variable declarations ("var" statements) and function declarations) added to a static scope object. This enables functions in the script to have optimized (direct) access to the script's own properties, as well as to global properties such as Math. With this change, it's no longer possible to delete properties of the Global Object, nor delete properties of an imported script. It's a compromise we make in order to make the optimization safe. Task-number: QTBUG-8576 Reviewed-by: Aaron Kennedy Reviewed-by: Olivier Goffart Reviewed-by: Jedrzej Nowacki --- src/declarative/qml/qdeclarativecontext.cpp | 12 +- src/declarative/qml/qdeclarativeexpression.cpp | 8 +- .../qml/qdeclarativeglobalscriptclass.cpp | 39 ++-- .../qml/qdeclarativeglobalscriptclass_p.h | 4 +- src/declarative/qml/qdeclarativeinclude.cpp | 2 +- src/script/api/qscriptengine.cpp | 12 +- src/script/api/qscriptengine_p.h | 15 ++ src/script/bridge/bridge.pri | 2 + src/script/bridge/qscriptdeclarativeclass.cpp | 36 +++ src/script/bridge/qscriptdeclarativeclass_p.h | 5 + src/script/bridge/qscriptstaticscopeobject.cpp | 157 +++++++++++++ src/script/bridge/qscriptstaticscopeobject_p.h | 103 +++++++++ tests/auto/qscriptengine/tst_qscriptengine.cpp | 242 +++++++++++++++++++++ .../script/qscriptengine/tst_qscriptengine.cpp | 52 +++++ 14 files changed, 652 insertions(+), 37 deletions(-) create mode 100644 src/script/bridge/qscriptstaticscopeobject.cpp create mode 100644 src/script/bridge/qscriptstaticscopeobject_p.h diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 2221d78..60e9dd3 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -660,10 +660,9 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); scriptContext->pushScope(enginePriv->contextClass->newUrlContext(url)); - scriptContext->pushScope(enginePriv->globalClass->globalObject()); + scriptContext->pushScope(enginePriv->globalClass->staticGlobalObject()); - QScriptValue scope = scriptEngine->newObject(); - scriptContext->setActivationObject(scope); + QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(scriptEngine); scriptContext->pushScope(scope); scriptEngine->evaluate(code, url, 1); @@ -686,10 +685,9 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); scriptContext->pushScope(enginePriv->contextClass->newUrlContext(this, 0, url)); - scriptContext->pushScope(enginePriv->globalClass->globalObject()); - - QScriptValue scope = scriptEngine->newObject(); - scriptContext->setActivationObject(scope); + scriptContext->pushScope(enginePriv->globalClass->staticGlobalObject()); + + QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(scriptEngine); scriptContext->pushScope(scope); scriptEngine->evaluate(code, url, 1); diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index b1aecfa..8ae5f2f 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -145,7 +145,7 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *ex if (!dd->cachedClosures.at(progIdx)) { QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); scriptContext->pushScope(ep->contextClass->newSharedContext()); - scriptContext->pushScope(ep->globalClass->globalObject()); + scriptContext->pushScope(ep->globalClass->staticGlobalObject()); dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line)); scriptEngine->popContext(); } @@ -188,7 +188,7 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex } else { scriptContext->pushScope(ep->contextClass->newContext(context, object)); } - scriptContext->pushScope(ep->globalClass->globalObject()); + scriptContext->pushScope(ep->globalClass->staticGlobalObject()); QScriptValue rv = ep->scriptEngine.evaluate(program, fileName, lineNumber); ep->scriptEngine.popContext(); return rv; @@ -206,7 +206,7 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex } else { scriptContext->pushScope(ep->contextClass->newContext(context, object)); } - scriptContext->pushScope(ep->globalClass->globalObject()); + scriptContext->pushScope(ep->globalClass->staticGlobalObject()); QScriptValue rv = ep->scriptEngine.evaluate(program); ep->scriptEngine.popContext(); return rv; @@ -369,7 +369,7 @@ QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool * QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); data->expressionContext = ep->contextClass->newContext(data->context(), data->me); scriptContext->pushScope(data->expressionContext); - scriptContext->pushScope(ep->globalClass->globalObject()); + scriptContext->pushScope(ep->globalClass->staticGlobalObject()); if (data->expressionRewritten) { data->expressionFunction = scriptEngine->evaluate(data->expression, diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp index 6e107fb..39ea101 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp @@ -41,10 +41,13 @@ #include "private/qdeclarativeglobalscriptclass_p.h" +#include #include #include #include +#include + QT_BEGIN_NAMESPACE /* @@ -55,23 +58,31 @@ QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engi { QString eval = QLatin1String("eval"); - QScriptValue globalObject = engine->globalObject(); + QScriptValue originalGlobalObject = engine->globalObject(); - m_globalObject = engine->newObject(); QScriptValue newGlobalObject = engine->newObject(); - QScriptValueIterator iter(globalObject); - - while (iter.hasNext()) { - iter.next(); - - QString name = iter.name(); - - if (name != eval) - m_globalObject.setProperty(iter.scriptName(), iter.value()); - newGlobalObject.setProperty(iter.scriptName(), iter.value()); - - m_illegalNames.insert(name); + { + QScriptValueIterator iter(originalGlobalObject); + QVector names; + QVector values; + QVector flags; + while (iter.hasNext()) { + iter.next(); + + QString name = iter.name(); + + if (name != eval) { + names.append(name); + values.append(iter.value()); + flags.append(iter.flags() | QScriptValue::Undeletable); + } + newGlobalObject.setProperty(iter.scriptName(), iter.value()); + + m_illegalNames.insert(name); + } + m_staticGlobalObject = QScriptDeclarativeClass::newStaticScopeObject( + engine, names.size(), names.constData(), values.constData(), flags.constData()); } newGlobalObject.setScriptClass(this); diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h index 7690edd..414bf02 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h @@ -75,13 +75,13 @@ public: void explicitSetProperty(const QString &, const QScriptValue &); - const QScriptValue &globalObject() const { return m_globalObject; } + const QScriptValue &staticGlobalObject() const { return m_staticGlobalObject; } const QSet &illegalNames() const { return m_illegalNames; } private: QSet m_illegalNames; - QScriptValue m_globalObject; + QScriptValue m_staticGlobalObject; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index c29005a..f26b54f 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -240,7 +240,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine); scriptContext->pushScope(ep->contextClass->newUrlContext(context, 0, urlString)); - scriptContext->pushScope(ep->globalClass->globalObject()); + scriptContext->pushScope(ep->globalClass->staticGlobalObject()); QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -5); scriptContext->pushScope(scope); scriptContext->setActivationObject(scope); diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index e2999c1..655026c 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -64,6 +64,7 @@ #include "bridge/qscriptqobject_p.h" #include "bridge/qscriptglobalobject_p.h" #include "bridge/qscriptactivationobject_p.h" +#include "bridge/qscriptstaticscopeobject_p.h" #ifndef QT_NO_QOBJECT #include @@ -905,6 +906,7 @@ QScriptEnginePrivate::QScriptEnginePrivate() JSC::ExecState* exec = globalObject->globalExec(); scriptObjectStructure = QScriptObject::createStructure(globalObject->objectPrototype()); + staticScopeObjectStructure = QScriptStaticScopeObject::createStructure(JSC::jsNull()); qobjectPrototype = new (exec) QScript::QObjectPrototype(exec, QScript::QObjectPrototype::createStructure(globalObject->objectPrototype()), globalObject->prototypeFunctionStructure()); qobjectWrapperObjectStructure = QScriptObject::createStructure(qobjectPrototype); @@ -1770,15 +1772,7 @@ void QScriptEnginePrivate::setProperty(JSC::ExecState *exec, JSC::JSValue object } else if (flags != QScriptValue::KeepExistingFlags) { if (thisObject->hasOwnProperty(exec, id)) thisObject->deleteProperty(exec, id); // ### hmmm - can't we just update the attributes? - unsigned attribs = 0; - if (flags & QScriptValue::ReadOnly) - attribs |= JSC::ReadOnly; - if (flags & QScriptValue::SkipInEnumeration) - attribs |= JSC::DontEnum; - if (flags & QScriptValue::Undeletable) - attribs |= JSC::DontDelete; - attribs |= flags & QScriptValue::UserRange; - thisObject->putWithAttributes(exec, id, value, attribs); + thisObject->putWithAttributes(exec, id, value, propertyFlagsToJSCAttributes(flags)); } else { JSC::PutPropertySlot slot; thisObject->put(exec, id, value, slot); diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 56366e2..1b35704 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -205,6 +205,7 @@ public: inline QScriptValue scriptValueFromJSCValue(JSC::JSValue value); inline JSC::JSValue scriptValueToJSCValue(const QScriptValue &value); + static inline unsigned propertyFlagsToJSCAttributes(const QScriptValue::PropertyFlags &flags); static inline JSC::JSValue jscValueFromVariant(JSC::ExecState*, const QVariant &value); static QVariant jscValueToVariant(JSC::ExecState*, JSC::JSValue value, int targetType); @@ -346,6 +347,7 @@ public: JSC::ExecState *currentFrame; WTF::RefPtr scriptObjectStructure; + WTF::RefPtr staticScopeObjectStructure; QScript::QObjectPrototype *qobjectPrototype; WTF::RefPtr qobjectWrapperObjectStructure; @@ -639,6 +641,19 @@ inline JSC::JSValue QScriptEnginePrivate::scriptValueToJSCValue(const QScriptVal return vv->jscValue; } +inline unsigned QScriptEnginePrivate::propertyFlagsToJSCAttributes(const QScriptValue::PropertyFlags &flags) +{ + unsigned attribs = 0; + if (flags & QScriptValue::ReadOnly) + attribs |= JSC::ReadOnly; + if (flags & QScriptValue::SkipInEnumeration) + attribs |= JSC::DontEnum; + if (flags & QScriptValue::Undeletable) + attribs |= JSC::DontDelete; + attribs |= flags & QScriptValue::UserRange; + return attribs; +} + inline QScriptValuePrivate::~QScriptValuePrivate() { if (engine) diff --git a/src/script/bridge/bridge.pri b/src/script/bridge/bridge.pri index 09e2dfb..ab0a322 100644 --- a/src/script/bridge/bridge.pri +++ b/src/script/bridge/bridge.pri @@ -6,6 +6,7 @@ SOURCES += \ $$PWD/qscriptqobject.cpp \ $$PWD/qscriptglobalobject.cpp \ $$PWD/qscriptactivationobject.cpp \ + $$PWD/qscriptstaticscopeobject.cpp \ $$PWD/qscriptdeclarativeobject.cpp \ $$PWD/qscriptdeclarativeclass.cpp @@ -17,5 +18,6 @@ HEADERS += \ $$PWD/qscriptqobject_p.h \ $$PWD/qscriptglobalobject_p.h \ $$PWD/qscriptactivationobject_p.h \ + $$PWD/qscriptstaticscopeobject_p.h \ $$PWD/qscriptdeclarativeobject_p.h \ $$PWD/qscriptdeclarativeclass_p.h diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp index 1093448..8080b9f 100644 --- a/src/script/bridge/qscriptdeclarativeclass.cpp +++ b/src/script/bridge/qscriptdeclarativeclass.cpp @@ -24,6 +24,7 @@ #include "qscriptdeclarativeclass_p.h" #include "qscriptdeclarativeobject_p.h" #include "qscriptobject_p.h" +#include "qscriptstaticscopeobject_p.h" #include #include #include @@ -549,4 +550,39 @@ QScriptContext *QScriptDeclarativeClass::context() const return d_ptr->context; } +/*! + Creates a scope object with a fixed set of undeletable properties. +*/ +QScriptValue QScriptDeclarativeClass::newStaticScopeObject( + QScriptEngine *engine, int propertyCount, const QString *names, + const QScriptValue *values, const QScriptValue::PropertyFlags *flags) +{ + QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); + QScript::APIShim shim(eng_p); + JSC::ExecState *exec = eng_p->currentFrame; + QScriptStaticScopeObject::PropertyInfo *props = new QScriptStaticScopeObject::PropertyInfo[propertyCount]; + for (int i = 0; i < propertyCount; ++i) { + unsigned attribs = QScriptEnginePrivate::propertyFlagsToJSCAttributes(flags[i]); + Q_ASSERT_X(attribs & JSC::DontDelete, Q_FUNC_INFO, "All properties must be undeletable"); + JSC::Identifier id = JSC::Identifier(exec, names[i]); + JSC::JSValue jsval = eng_p->scriptValueToJSCValue(values[i]); + props[i] = QScriptStaticScopeObject::PropertyInfo(id, jsval, attribs); + } + QScriptValue result = eng_p->scriptValueFromJSCValue(new (exec)QScriptStaticScopeObject(eng_p->staticScopeObjectStructure, + propertyCount, props)); + delete[] props; + return result; +} + +/*! + Creates a static scope object that's initially empty, but to which new + properties can be added. +*/ +QScriptValue QScriptDeclarativeClass::newStaticScopeObject(QScriptEngine *engine) +{ + QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); + QScript::APIShim shim(eng_p); + return eng_p->scriptValueFromJSCValue(new (eng_p->currentFrame)QScriptStaticScopeObject(eng_p->staticScopeObjectStructure)); +} + QT_END_NAMESPACE diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h index 714a67c..420b133 100644 --- a/src/script/bridge/qscriptdeclarativeclass_p.h +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -92,6 +92,11 @@ public: static QScriptValue scopeChainValue(QScriptContext *, int index); static QScriptContext *pushCleanContext(QScriptEngine *); + static QScriptValue newStaticScopeObject( + QScriptEngine *, int propertyCount, const QString *names, + const QScriptValue *values, const QScriptValue::PropertyFlags *flags); + static QScriptValue newStaticScopeObject(QScriptEngine *); + class Q_SCRIPT_EXPORT PersistentIdentifier { public: diff --git a/src/script/bridge/qscriptstaticscopeobject.cpp b/src/script/bridge/qscriptstaticscopeobject.cpp new file mode 100644 index 0000000..44548a4 --- /dev/null +++ b/src/script/bridge/qscriptstaticscopeobject.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** GNU Lesser General Public License Usage +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "config.h" +#include "qscriptstaticscopeobject_p.h" + +namespace JSC +{ + ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptStaticScopeObject)); +} + +QT_BEGIN_NAMESPACE + +/*! + \class QScriptStaticScopeObject + \internal + + Represents a static scope object. + + This class allows the VM to determine at JS script compile time whether + the object has a given property or not. If the object has the property, + a fast, index-based read/write operation will be used. If the object + doesn't have the property, the compiler knows it can safely skip this + object when dynamically resolving the property. Either way, this can + greatly improve performance. + + \sa QScriptContext::pushScope() +*/ + +const JSC::ClassInfo QScriptStaticScopeObject::info = { "QScriptStaticScopeObject", 0, 0, 0 }; + +/*! + Creates a static scope object with a fixed set of undeletable properties. + + It's not possible to add new properties to the object after construction. +*/ +QScriptStaticScopeObject::QScriptStaticScopeObject(WTF::NonNullPassRefPtr structure, + int propertyCount, const PropertyInfo* props) + : JSC::JSVariableObject(structure, new Data(/*canGrow=*/false)) +{ + int index = growRegisterArray(propertyCount); + for (int i = 0; i < propertyCount; ++i, --index) { + const PropertyInfo& prop = props[i]; + JSC::SymbolTableEntry entry(index, prop.attributes); + symbolTable().add(prop.identifier.ustring().rep(), entry); + registerAt(index) = prop.value; + } +} + +/*! + Creates an empty static scope object. + + Properties can be added to the object after construction, either by + calling QScriptValue::setProperty(), or by pushing the object on the + scope chain; variable declarations ("var" statements) and function + declarations in JavaScript will create properties on the scope object. + + Note that once the scope object has been used in a closure and the + resulting function has been compiled, it's no longer safe to add + properties to the scope object (because the VM will bypass this + object the next time the function is executed). +*/ +QScriptStaticScopeObject::QScriptStaticScopeObject(WTF::NonNullPassRefPtr structure) + : JSC::JSVariableObject(structure, new Data(/*canGrow=*/true)) +{ +} + +QScriptStaticScopeObject::~QScriptStaticScopeObject() +{ + delete d; +} + +bool QScriptStaticScopeObject::getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot& slot) +{ + return symbolTableGet(propertyName, slot); +} + +bool QScriptStaticScopeObject::getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor) +{ + return symbolTableGet(propertyName, descriptor); +} + +void QScriptStaticScopeObject::putWithAttributes(JSC::ExecState* exec, const JSC::Identifier &propertyName, JSC::JSValue value, unsigned attributes) +{ + if (symbolTablePutWithAttributes(propertyName, value, attributes)) + return; + Q_ASSERT(d_ptr()->canGrow); + addSymbolTableProperty(propertyName, value, attributes); +} + +void QScriptStaticScopeObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot&) +{ + if (symbolTablePut(propertyName, value)) + return; + Q_ASSERT(d_ptr()->canGrow); + addSymbolTableProperty(propertyName, value, /*attributes=*/0); +} + +bool QScriptStaticScopeObject::deleteProperty(JSC::ExecState*, const JSC::Identifier&) +{ + return false; +} + +void QScriptStaticScopeObject::markChildren(JSC::MarkStack& markStack) +{ + JSC::Register* registerArray = d_ptr()->registerArray.get(); + if (!registerArray) + return; + markStack.appendValues(reinterpret_cast(registerArray), d_ptr()->registerArraySize); +} + +void QScriptStaticScopeObject::addSymbolTableProperty(const JSC::Identifier& name, JSC::JSValue value, unsigned attributes) +{ + int index = growRegisterArray(1); + JSC::SymbolTableEntry newEntry(index, attributes | JSC::DontDelete); + symbolTable().add(name.ustring().rep(), newEntry); + registerAt(index) = value; +} + +/*! + Grows the register array by \a count elements, and returns the offset of + the newly added elements (note that the register file grows downwards, + starting at index -1). +*/ +int QScriptStaticScopeObject::growRegisterArray(int count) +{ + size_t oldSize = d_ptr()->registerArraySize; + size_t newSize = oldSize + count; + JSC::Register* registerArray = new JSC::Register[newSize]; + if (d_ptr()->registerArray) + memcpy(registerArray + count, d_ptr()->registerArray.get(), oldSize * sizeof(JSC::Register)); + setRegisters(registerArray + newSize, registerArray); + d_ptr()->registerArraySize = newSize; + return -oldSize - 1; +} + +QT_END_NAMESPACE diff --git a/src/script/bridge/qscriptstaticscopeobject_p.h b/src/script/bridge/qscriptstaticscopeobject_p.h new file mode 100644 index 0000000..0a0e7ef --- /dev/null +++ b/src/script/bridge/qscriptstaticscopeobject_p.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** GNU Lesser General Public License Usage +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCRIPTSTATICSCOPEOBJECT_P_H +#define QSCRIPTSTATICSCOPEOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include "JSVariableObject.h" + +QT_BEGIN_NAMESPACE + +class QScriptStaticScopeObject : public JSC::JSVariableObject { +public: + struct PropertyInfo { + PropertyInfo(const JSC::Identifier& i, JSC::JSValue v, unsigned a) + : identifier(i), value(v), attributes(a) + { } + PropertyInfo() {} + + JSC::Identifier identifier; + JSC::JSValue value; + unsigned attributes; + }; + + QScriptStaticScopeObject(WTF::NonNullPassRefPtr structure, + int propertyCount, const PropertyInfo*); + QScriptStaticScopeObject(WTF::NonNullPassRefPtr structure); + virtual ~QScriptStaticScopeObject(); + + virtual bool isDynamicScope() const { return false; } + + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + + virtual void putWithAttributes(JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue value, unsigned attributes); + virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot&); + + virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier& propertyName); + + virtual void markChildren(JSC::MarkStack&); + + virtual const JSC::ClassInfo* classInfo() const { return &info; } + static const JSC::ClassInfo info; + + static WTF::PassRefPtr createStructure(JSC::JSValue proto) { + return JSC::Structure::create(proto, JSC::TypeInfo(JSC::ObjectType, StructureFlags)); + } + +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::NeedsThisConversion | JSC::OverridesMarkChildren | JSC::OverridesGetPropertyNames | JSC::JSVariableObject::StructureFlags; + + struct Data : public JSVariableObjectData { + Data(bool canGrow_) + : JSVariableObjectData(&symbolTable, /*registers=*/0), + canGrow(canGrow_), registerArraySize(0) + { } + bool canGrow; + int registerArraySize; + JSC::SymbolTable symbolTable; + }; + + Data* d_ptr() const { return static_cast(JSVariableObject::d); } + +private: + void addSymbolTableProperty(const JSC::Identifier&, JSC::JSValue, unsigned attributes); + int growRegisterArray(int); +}; + +QT_END_NAMESPACE + +#endif diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 5e59950..6885adf 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -51,6 +51,8 @@ #include #include +#include + Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QObjectList) Q_DECLARE_METATYPE(QScriptProgram) @@ -169,6 +171,8 @@ private slots: void qRegExpInport_data(); void qRegExpInport(); void reentrency(); + void newFixedStaticScopeObject(); + void newGrowingStaticScopeObject(); }; tst_QScriptEngine::tst_QScriptEngine() @@ -4955,5 +4959,243 @@ void tst_QScriptEngine::reentrency() QCOMPARE(eng.evaluate("foo() + hello").toInt32(), 5+6+9); } +void tst_QScriptEngine::newFixedStaticScopeObject() +{ + QScriptEngine eng; + static const int propertyCount = 4; + QString names[] = { "foo", "bar", "baz", "Math" }; + QScriptValue values[] = { 123, "ciao", true, false }; + QScriptValue::PropertyFlags flags[] = { QScriptValue::Undeletable, + QScriptValue::ReadOnly | QScriptValue::Undeletable, + QScriptValue::SkipInEnumeration | QScriptValue::Undeletable, + QScriptValue::Undeletable }; + QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(&eng, propertyCount, names, values, flags); + + // Query property. + for (int i = 0; i < propertyCount; ++i) { + for (int x = 0; x < 2; ++x) { + if (x) { + // Properties can't be deleted. + scope.setProperty(names[i], QScriptValue()); + } + QVERIFY(scope.property(names[i]).equals(values[i])); + QCOMPARE(scope.propertyFlags(names[i]), flags[i]); + } + } + + // Property that doesn't exist. + QVERIFY(!scope.property("noSuchProperty").isValid()); + QCOMPARE(scope.propertyFlags("noSuchProperty"), QScriptValue::PropertyFlags()); + + // Write to writable property. + { + QScriptValue oldValue = scope.property("foo"); + QVERIFY(oldValue.isNumber()); + QScriptValue newValue = oldValue.toNumber() * 2; + scope.setProperty("foo", newValue); + QVERIFY(scope.property("foo").equals(newValue)); + scope.setProperty("foo", oldValue); + QVERIFY(scope.property("foo").equals(oldValue)); + } + + // Write to read-only property. + scope.setProperty("bar", 456); + QVERIFY(scope.property("bar").equals("ciao")); + + // Iterate. + { + QScriptValueIterator it(scope); + QSet iteratedNames; + while (it.hasNext()) { + it.next(); + iteratedNames.insert(it.name()); + } + for (int i = 0; i < propertyCount; ++i) + QVERIFY(iteratedNames.contains(names[i])); + } + + // Push it on the scope chain of a new context. + QScriptContext *ctx = eng.pushContext(); + ctx->pushScope(scope); + QCOMPARE(ctx->scopeChain().size(), 3); // Global Object, native activation, custom scope + QVERIFY(ctx->activationObject().equals(scope)); + + // Read property from JS. + for (int i = 0; i < propertyCount; ++i) { + for (int x = 0; x < 2; ++x) { + if (x) { + // Property can't be deleted from JS. + QScriptValue ret = eng.evaluate(QString::fromLatin1("delete %0").arg(names[i])); + QVERIFY(ret.equals(false)); + } + QVERIFY(eng.evaluate(names[i]).equals(values[i])); + } + } + + // Property that doesn't exist. + QVERIFY(eng.evaluate("noSuchProperty").equals("ReferenceError: Can't find variable: noSuchProperty")); + + // Write property from JS. + { + QScriptValue oldValue = eng.evaluate("foo"); + QVERIFY(oldValue.isNumber()); + QScriptValue newValue = oldValue.toNumber() * 2; + QVERIFY(eng.evaluate("foo = foo * 2; foo").equals(newValue)); + scope.setProperty("foo", oldValue); + QVERIFY(eng.evaluate("foo").equals(oldValue)); + } + + // Write to read-only property. + QVERIFY(eng.evaluate("bar = 456; bar").equals("ciao")); + + // Create a closure and return properties from there. + { + QScriptValue props = eng.evaluate("(function() { var baz = 'shadow'; return [foo, bar, baz, Math, Array]; })()"); + QVERIFY(props.isArray()); + // "foo" and "bar" come from scope object. + QVERIFY(props.property(0).equals(scope.property("foo"))); + QVERIFY(props.property(1).equals(scope.property("bar"))); + // "baz" shadows property in scope object. + QVERIFY(props.property(2).equals("shadow")); + // "Math" comes from scope object, and shadows Global Object's "Math". + QVERIFY(props.property(3).equals(scope.property("Math"))); + QVERIFY(!props.property(3).equals(eng.globalObject().property("Math"))); + // "Array" comes from Global Object. + QVERIFY(props.property(4).equals(eng.globalObject().property("Array"))); + } + + // As with normal JS, assigning to an undefined variable will create + // the property on the Global Object, not the inner scope. + QVERIFY(!eng.globalObject().property("newProperty").isValid()); + QVERIFY(eng.evaluate("(function() { newProperty = 789; })()").isUndefined()); + QVERIFY(!scope.property("newProperty").isValid()); + QVERIFY(eng.globalObject().property("newProperty").isNumber()); + + // Nested static scope. + { + static const int propertyCount2 = 2; + QString names2[] = { "foo", "hum" }; + QScriptValue values2[] = { 321, "hello" }; + QScriptValue::PropertyFlags flags2[] = { QScriptValue::Undeletable, + QScriptValue::ReadOnly | QScriptValue::Undeletable }; + QScriptValue scope2 = QScriptDeclarativeClass::newStaticScopeObject(&eng, propertyCount2, names2, values2, flags2); + ctx->pushScope(scope2); + + // "foo" shadows scope.foo. + QVERIFY(eng.evaluate("foo").equals(scope2.property("foo"))); + QVERIFY(!eng.evaluate("foo").equals(scope.property("foo"))); + // "hum" comes from scope2. + QVERIFY(eng.evaluate("hum").equals(scope2.property("hum"))); + // "Array" comes from Global Object. + QVERIFY(eng.evaluate("Array").equals(eng.globalObject().property("Array"))); + + ctx->popScope(); + } + + QScriptValue fun = eng.evaluate("(function() { return foo; })"); + QVERIFY(fun.isFunction()); + eng.popContext(); + // Function's scope chain persists after popContext(). + QVERIFY(fun.call().equals(scope.property("foo"))); +} + +void tst_QScriptEngine::newGrowingStaticScopeObject() +{ + QScriptEngine eng; + QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(&eng); + + // Initially empty. + QVERIFY(!QScriptValueIterator(scope).hasNext()); + QVERIFY(!scope.property("foo").isValid()); + + // Add a static property. + scope.setProperty("foo", 123); + QVERIFY(scope.property("foo").equals(123)); + QCOMPARE(scope.propertyFlags("foo"), QScriptValue::Undeletable); + + // Modify existing property. + scope.setProperty("foo", 456); + QVERIFY(scope.property("foo").equals(456)); + + // Add a read-only property. + scope.setProperty("bar", "ciao", QScriptValue::ReadOnly); + QVERIFY(scope.property("bar").equals("ciao")); + QCOMPARE(scope.propertyFlags("bar"), QScriptValue::ReadOnly | QScriptValue::Undeletable); + + // Attempt to modify read-only property. + scope.setProperty("bar", "hello"); + QVERIFY(scope.property("bar").equals("ciao")); + + // Properties can't be deleted. + scope.setProperty("foo", QScriptValue()); + QVERIFY(scope.property("foo").equals(456)); + scope.setProperty("bar", QScriptValue()); + QVERIFY(scope.property("bar").equals("ciao")); + + // Iterate. + { + QScriptValueIterator it(scope); + QSet iteratedNames; + while (it.hasNext()) { + it.next(); + iteratedNames.insert(it.name()); + } + QCOMPARE(iteratedNames.size(), 2); + QVERIFY(iteratedNames.contains("foo")); + QVERIFY(iteratedNames.contains("bar")); + } + + // Push it on the scope chain of a new context. + QScriptContext *ctx = eng.pushContext(); + ctx->pushScope(scope); + QCOMPARE(ctx->scopeChain().size(), 3); // Global Object, native activation, custom scope + QVERIFY(ctx->activationObject().equals(scope)); + + // Read property from JS. + QVERIFY(eng.evaluate("foo").equals(scope.property("foo"))); + QVERIFY(eng.evaluate("bar").equals(scope.property("bar"))); + + // Write property from JS. + { + QScriptValue oldValue = eng.evaluate("foo"); + QVERIFY(oldValue.isNumber()); + QScriptValue newValue = oldValue.toNumber() * 2; + QVERIFY(eng.evaluate("foo = foo * 2; foo").equals(newValue)); + scope.setProperty("foo", oldValue); + QVERIFY(eng.evaluate("foo").equals(oldValue)); + } + + // Write to read-only property. + QVERIFY(eng.evaluate("bar = 456; bar").equals("ciao")); + + // Shadow property. + QVERIFY(eng.evaluate("Math").equals(eng.globalObject().property("Math"))); + scope.setProperty("Math", "fake Math"); + QVERIFY(eng.evaluate("Math").equals(scope.property("Math"))); + + // Variable declarations will create properties on the scope. + eng.evaluate("var baz = 456"); + QVERIFY(scope.property("baz").equals(456)); + + // Function declarations will create properties on the scope. + eng.evaluate("function fun() { return baz; }"); + QVERIFY(scope.property("fun").isFunction()); + QVERIFY(scope.property("fun").call().equals(scope.property("baz"))); + + // Demonstrate the limitation of a growable static scope: Once a function that + // uses the scope has been compiled, it won't pick up properties that are added + // to the scope later. + { + QScriptValue fun = eng.evaluate("(function() { return futureProperty; })"); + QVERIFY(fun.isFunction()); + QCOMPARE(fun.call().toString(), QString::fromLatin1("ReferenceError: Can't find variable: futureProperty")); + scope.setProperty("futureProperty", "added after the function was compiled"); + // If scope were dynamic, this would return the new property. + QCOMPARE(fun.call().toString(), QString::fromLatin1("ReferenceError: Can't find variable: futureProperty")); + } + + eng.popContext(); +} + QTEST_MAIN(tst_QScriptEngine) #include "tst_qscriptengine.moc" diff --git a/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp index 35e2f28..4610046 100644 --- a/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp +++ b/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp @@ -42,6 +42,8 @@ #include #include +#include + //TESTED_FILES= class tst_QScriptEngine : public QObject @@ -74,6 +76,8 @@ private slots: void nativeCall(); void translation_data(); void translation(); + void readScopeProperty_data(); + void readScopeProperty(); }; tst_QScriptEngine::tst_QScriptEngine() @@ -288,5 +292,53 @@ void tst_QScriptEngine::translation() } } +void tst_QScriptEngine::readScopeProperty_data() +{ + QTest::addColumn("staticScope"); + QTest::addColumn("nestedScope"); + QTest::newRow("single dynamic scope") << false << false; + QTest::newRow("single static scope") << true << false; + QTest::newRow("double dynamic scope") << false << true; + QTest::newRow("double static scope") << true << true; +} + +void tst_QScriptEngine::readScopeProperty() +{ + QFETCH(bool, staticScope); + QFETCH(bool, nestedScope); + + QScriptEngine engine; + QScriptContext *ctx = engine.pushContext(); + + QScriptValue scope; + if (staticScope) + scope = QScriptDeclarativeClass::newStaticScopeObject(&engine); + else + scope = engine.newObject(); + scope.setProperty("foo", 123); + ctx->pushScope(scope); + + if (nestedScope) { + QScriptValue scope2; + if (staticScope) + scope2 = QScriptDeclarativeClass::newStaticScopeObject(&engine); + else + scope2 = engine.newObject(); + scope2.setProperty("bar", 456); // ensure a miss in inner scope + ctx->pushScope(scope2); + } + + QScriptValue fun = engine.evaluate("(function() {\n" + " for (var i = 0; i < 10000; ++i) {\n" + " foo; foo; foo; foo; foo; foo; foo; foo;\n" + " }\n" + "})"); + engine.popContext(); + QVERIFY(fun.isFunction()); + QBENCHMARK { + fun.call(); + } +} + QTEST_MAIN(tst_QScriptEngine) #include "tst_qscriptengine.moc" -- cgit v0.12 From 3b7ae67fe2715838c32ff28694761e57e4f79537 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 25 Jun 2010 09:36:50 +0200 Subject: Fix compilation when configured with -no-xrender Reviewed-by: Eskil --- src/gui/kernel/qapplication_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 3664743..e4d9848 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -2155,7 +2155,7 @@ void qt_init(QApplicationPrivate *priv, int, X11->fc_scale = fc_scale; for (int s = 0; s < ScreenCount(X11->display); ++s) { int subpixel = FC_RGBA_UNKNOWN; -#if RENDER_MAJOR > 0 || RENDER_MINOR >= 6 +#if !defined(QT_NO_XRENDER) && (RENDER_MAJOR > 0 || RENDER_MINOR >= 6) if (X11->use_xrender) { int rsp = XRenderQuerySubpixelOrder(X11->display, s); switch (rsp) { -- cgit v0.12 From 06ea7cfc8f682904496889aedec03b1f00b0a8e7 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 25 Jun 2010 10:23:44 +0200 Subject: doc: Added more DITA output to the XML generator Output Q_PROPERTY as a cxxVariable. Task-number: QTBUG-11391 --- tools/qdoc3/cppcodeparser.cpp | 32 +++++++- tools/qdoc3/ditaxmlgenerator.cpp | 56 +++++++++++++- tools/qdoc3/ditaxmlgenerator.h | 1 + tools/qdoc3/node.cpp | 39 +++++++++- tools/qdoc3/node.h | 155 ++++++++++++++++++++++----------------- 5 files changed, 207 insertions(+), 76 deletions(-) diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index 13678af..ce7eba3 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -1850,16 +1850,40 @@ bool CppCodeParser::matchProperty(InnerNode *parent) else if (key == "WRITE") { tre->addPropertyFunction(property, value, PropertyNode::Setter); property->setWritable(true); - } else if (key == "STORED") + } + else if (key == "STORED") property->setStored(value.toLower() == "true"); - else if (key == "DESIGNABLE") - property->setDesignable(value.toLower() == "true"); + else if (key == "DESIGNABLE") { + QString v = value.toLower(); + if (v == "true") + property->setDesignable(true); + else if (v == "false") + property->setDesignable(false); + else { + property->setDesignable(false); + property->setRuntimeDesFunc(value); + } + } else if (key == "RESET") tre->addPropertyFunction(property, value, PropertyNode::Resetter); else if (key == "NOTIFY") { tre->addPropertyFunction(property, value, PropertyNode::Notifier); } - + else if (key == "SCRIPTABLE") { + QString v = value.toLower(); + if (v == "true") + property->setScriptable(true); + else if (v == "false") + property->setScriptable(false); + else { + property->setScriptable(false); + property->setRuntimeScrFunc(value); + } + } + else if (key == "COSTANT") + property->setConstant(); + else if (key == "FINAL") + property->setFinal(); } match(Tok_RightParen); return true; diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index be734ac..852d209 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -4914,9 +4914,9 @@ void DitaXmlGenerator::writeProperties(const Section& s, writer.writeAttribute("value",pn->accessString()); writer.writeEndElement(); // - if (!pn->dataType().isEmpty()) { + if (!pn->qualifiedDataType().isEmpty()) { writer.writeStartElement(CXXVARIABLEDECLAREDTYPE); - writer.writeCharacters(pn->dataType()); + writer.writeCharacters(pn->qualifiedDataType()); writer.writeEndElement(); // } QString fq = fullQualification(pn); @@ -4925,11 +4925,49 @@ void DitaXmlGenerator::writeProperties(const Section& s, writer.writeCharacters(fq); writer.writeEndElement(); // } + + writer.writeStartElement(CXXVARIABLEPROTOTYPE); + writer.writeCharacters("Q_PROPERTY("); + writer.writeCharacters(pn->qualifiedDataType()); + writer.writeCharacters(" "); + writer.writeCharacters(pn->name()); + writerFunctions("READ",pn->getters()); + writerFunctions("WRITE",pn->setters()); + writerFunctions("RESET",pn->resetters()); + writerFunctions("NOTIFY",pn->notifiers()); + if (pn->isDesignable() != pn->designableDefault()) { + writer.writeCharacters(" DESIGNABLE "); + if (!pn->runtimeDesignabilityFunction().isEmpty()) + writer.writeCharacters(pn->runtimeDesignabilityFunction()); + else + writer.writeCharacters(pn->isDesignable() ? "true" : "false"); + } + if (pn->isScriptable() != pn->scriptableDefault()) { + writer.writeCharacters(" SCRIPTABLE "); + if (!pn->runtimeScriptabilityFunction().isEmpty()) + writer.writeCharacters(pn->runtimeScriptabilityFunction()); + else + writer.writeCharacters(pn->isScriptable() ? "true" : "false"); + } + if (pn->isWritable() != pn->writableDefault()) { + writer.writeCharacters(" STORED "); + writer.writeCharacters(pn->isStored() ? "true" : "false"); + } + if (pn->isUser() != pn->userDefault()) { + writer.writeCharacters(" USER "); + writer.writeCharacters(pn->isUser() ? "true" : "false"); + } + if (pn->isConstant()) + writer.writeCharacters(" CONSTANT"); + if (pn->isFinal()) + writer.writeCharacters(" FINAL"); + writer.writeCharacters(")"); + writer.writeEndElement(); // + writer.writeStartElement(CXXVARIABLENAMELOOKUP); writer.writeCharacters(pn->parent()->name() + "::" + pn->name()); writer.writeEndElement(); // - if (pn->overriddenFrom() != 0) { PropertyNode* opn = (PropertyNode*)pn->overriddenFrom(); writer.writeStartElement(CXXVARIABLEREIMPLEMENTED); @@ -4954,4 +4992,16 @@ void DitaXmlGenerator::writeProperties(const Section& s, } } +void DitaXmlGenerator::writerFunctions(const QString& tag, const NodeList& nlist) +{ + NodeList::const_iterator n = nlist.begin(); + while (n != nlist.end()) { + writer.writeCharacters(" "); + writer.writeCharacters(tag); + writer.writeCharacters(" "); + writer.writeCharacters((*n)->name()); + ++n; + } +} + QT_END_NAMESPACE diff --git a/tools/qdoc3/ditaxmlgenerator.h b/tools/qdoc3/ditaxmlgenerator.h index 8c7e439..26788d7 100644 --- a/tools/qdoc3/ditaxmlgenerator.h +++ b/tools/qdoc3/ditaxmlgenerator.h @@ -133,6 +133,7 @@ class DitaXmlGenerator : public PageGenerator void writeProperties(const Section& s, const ClassNode* cn, CodeMarker* marker); + void writerFunctions(const QString& tag, const NodeList& nlist); private: enum SubTitleSize { SmallSubTitle, LargeSubTitle }; diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 26957ac..7596825 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -1287,21 +1287,39 @@ void FunctionNode::debug() const /*! \class PropertyNode + + This class describes one instance of using the Q_PROPERTY macro. */ /*! + The constructor sets the \a parent and the \a name, but + everything else is set to default values. */ PropertyNode::PropertyNode(InnerNode *parent, const QString& name) : LeafNode(Property, parent, name), sto(Trool_Default), des(Trool_Default), + scr(Trool_Default), + wri(Trool_Default), + usr(Trool_Default), + cst(false), + fnl(false), overrides(0) { + // nothing. } /*! + Sets this property's \e {overridden from} property to + \a baseProperty, which indicates that this property + overrides \a baseProperty. To begin with, all the values + in this property are set to the corresponding values in + \a baseProperty. + + We probably should ensure that the constant and final + attributes are not being overridden improperly. */ -void PropertyNode::setOverriddenFrom(const PropertyNode *baseProperty) +void PropertyNode::setOverriddenFrom(const PropertyNode* baseProperty) { for (int i = 0; i < NumFunctionRoles; ++i) { if (funcs[i].isEmpty()) @@ -1311,6 +1329,12 @@ void PropertyNode::setOverriddenFrom(const PropertyNode *baseProperty) sto = baseProperty->sto; if (des == Trool_Default) des = baseProperty->des; + if (scr == Trool_Default) + scr = baseProperty->scr; + if (wri == Trool_Default) + wri = baseProperty->wri; + if (usr == Trool_Default) + usr = baseProperty->usr; overrides = baseProperty; } @@ -1336,7 +1360,9 @@ QString PropertyNode::qualifiedDataType() const } } -/*! +/*! Converts the \a boolean value to an enum representation + of the boolean type, which includes an enum value for the + \e {default value} of the item, i.e. true, false, or default. */ PropertyNode::Trool PropertyNode::toTrool(bool boolean) { @@ -1344,6 +1370,15 @@ PropertyNode::Trool PropertyNode::toTrool(bool boolean) } /*! + Converts the enum \a troolean back to a boolean value. + If \a troolean is neither the true enum value nor the + false enum value, the boolean value returned is + \a defaultValue. + + Note that runtimeDesignabilityFunction() should be called + first. If that function returns the name of a function, it + means the function must be called at runtime to determine + whether the property is Designable. */ bool PropertyNode::fromTrool(Trool troolean, bool defaultValue) { diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index 37f2f26..b13e113 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -153,7 +153,7 @@ class Node void setStatus(Status status) { sta = status; } void setThreadSafeness(ThreadSafeness safeness) { saf = safeness; } void setSince(const QString &since) { sinc = since; } - void setRelates(InnerNode *pseudoParent); + void setRelates(InnerNode* pseudoParent); void setModuleName(const QString &module) { mod = module; } void setLink(LinkType linkType, const QString &link, const QString &desc); void setUrl(const QString &url); @@ -167,8 +167,8 @@ class Node virtual bool isQmlNode() const { return false; } Type type() const { return typ; } virtual SubType subType() const { return NoSubType; } - InnerNode *parent() const { return par; } - InnerNode *relates() const { return rel; } + InnerNode* parent() const { return par; } + InnerNode* relates() const { return rel; } const QString& name() const { return nam; } QMap > links() const { return linkMap; } QString moduleName() const; @@ -195,7 +195,7 @@ class Node QString ditaXmlHref(); protected: - Node(Type type, InnerNode *parent, const QString& name); + Node(Type type, InnerNode* parent, const QString& name); private: @@ -212,8 +212,8 @@ class Node PageType pageTyp : 4; Status sta : 3; #endif - InnerNode *par; - InnerNode *rel; + InnerNode* par; + InnerNode* rel; QString nam; Location loc; Doc d; @@ -228,35 +228,35 @@ class Node class FunctionNode; class EnumNode; -typedef QList NodeList; +typedef QList NodeList; class InnerNode : public Node { public: virtual ~InnerNode(); - Node *findNode(const QString& name); - Node *findNode(const QString& name, Type type); - FunctionNode *findFunctionNode(const QString& name); - FunctionNode *findFunctionNode(const FunctionNode *clone); + Node* findNode(const QString& name); + Node* findNode(const QString& name, Type type); + FunctionNode* findFunctionNode(const QString& name); + FunctionNode* findFunctionNode(const FunctionNode* clone); void addInclude(const QString &include); void setIncludes(const QStringList &includes); - void setOverload(const FunctionNode *func, bool overlode); + void setOverload(const FunctionNode* func, bool overlode); void normalizeOverloads(); void makeUndocumentedChildrenInternal(); void deleteChildren(); void removeFromRelated(); virtual bool isInnerNode() const; - const Node *findNode(const QString& name) const; - const Node *findNode(const QString& name, Type type) const; - const FunctionNode *findFunctionNode(const QString& name) const; - const FunctionNode *findFunctionNode(const FunctionNode *clone) const; - const EnumNode *findEnumNodeForValue(const QString &enumValue) const; + const Node* findNode(const QString& name) const; + const Node* findNode(const QString& name, Type type) const; + const FunctionNode* findFunctionNode(const QString& name) const; + const FunctionNode* findFunctionNode(const FunctionNode* clone) const; + const EnumNode* findEnumNodeForValue(const QString &enumValue) const; const NodeList & childNodes() const { return children; } const NodeList & relatedNodes() const { return related; } int count() const { return children.size(); } - int overloadNumber(const FunctionNode *func) const; + int overloadNumber(const FunctionNode* func) const; int numOverloads(const QString& funcName) const; NodeList overloads(const QString &funcName) const; const QStringList& includes() const { return inc; } @@ -269,23 +269,23 @@ class InnerNode : public Node virtual void setAbstract(bool ) { } protected: - InnerNode(Type type, InnerNode *parent, const QString& name); + InnerNode(Type type, InnerNode* parent, const QString& name); private: friend class Node; - static bool isSameSignature(const FunctionNode *f1, const FunctionNode *f2); - void addChild(Node *child); - void removeChild(Node *child); - void removeRelated(Node *pseudoChild); + static bool isSameSignature(const FunctionNode* f1, const FunctionNode* f2); + void addChild(Node* child); + void removeChild(Node* child); + void removeRelated(Node* pseudoChild); QStringList pageKeywds; QStringList inc; NodeList children; NodeList enumChildren; NodeList related; - QMap childMap; - QMap primaryFunctionMap; + QMap childMap; + QMap primaryFunctionMap; QMap secondaryFunctionMap; }; @@ -304,7 +304,7 @@ class LeafNode : public Node class NamespaceNode : public InnerNode { public: - NamespaceNode(InnerNode *parent, const QString& name); + NamespaceNode(InnerNode* parent, const QString& name); virtual ~NamespaceNode() { } }; @@ -329,11 +329,11 @@ struct RelatedClass class ClassNode : public InnerNode { public: - ClassNode(InnerNode *parent, const QString& name); + ClassNode(InnerNode* parent, const QString& name); virtual ~ClassNode() { } void addBaseClass(Access access, - ClassNode *node, + ClassNode* node, const QString &dataTypeWithTemplateArgs = ""); void fixBaseClasses(); @@ -363,12 +363,12 @@ class FakeNode : public InnerNode { public: - FakeNode(InnerNode *parent, const QString& name, SubType subType); + FakeNode(InnerNode* parent, const QString& name, SubType subType); virtual ~FakeNode() { } void setTitle(const QString &title) { tle = title; } void setSubTitle(const QString &subTitle) { stle = subTitle; } - void addGroupMember(Node *node) { gr.append(node); } + void addGroupMember(Node* node) { gr.append(node); } SubType subType() const { return sub; } QString title() const { return tle; } @@ -388,7 +388,7 @@ class FakeNode : public InnerNode class QmlClassNode : public FakeNode { public: - QmlClassNode(InnerNode *parent, + QmlClassNode(InnerNode* parent, const QString& name, const ClassNode* cn); virtual ~QmlClassNode(); @@ -411,7 +411,7 @@ class QmlClassNode : public FakeNode class QmlBasicTypeNode : public FakeNode { public: - QmlBasicTypeNode(InnerNode *parent, + QmlBasicTypeNode(InnerNode* parent, const QString& name); virtual ~QmlBasicTypeNode() { } virtual bool isQmlNode() const { return true; } @@ -498,41 +498,41 @@ class TypedefNode; class EnumNode : public LeafNode { public: - EnumNode(InnerNode *parent, const QString& name); + EnumNode(InnerNode* parent, const QString& name); virtual ~EnumNode() { } void addItem(const EnumItem& item); - void setFlagsType(TypedefNode *typedeff); + void setFlagsType(TypedefNode* typedeff); bool hasItem(const QString &name) const { return names.contains(name); } const QList& items() const { return itms; } Access itemAccess(const QString& name) const; - const TypedefNode *flagsType() const { return ft; } + const TypedefNode* flagsType() const { return ft; } QString itemValue(const QString &name) const; private: QList itms; QSet names; - const TypedefNode *ft; + const TypedefNode* ft; }; class TypedefNode : public LeafNode { public: - TypedefNode(InnerNode *parent, const QString& name); + TypedefNode(InnerNode* parent, const QString& name); virtual ~TypedefNode() { } - const EnumNode *associatedEnum() const { return ae; } + const EnumNode* associatedEnum() const { return ae; } private: - void setAssociatedEnum(const EnumNode *enume); + void setAssociatedEnum(const EnumNode* enume); friend class EnumNode; - const EnumNode *ae; + const EnumNode* ae; }; -inline void EnumNode::setFlagsType(TypedefNode *typedeff) +inline void EnumNode::setFlagsType(TypedefNode* typedeff) { ft = typedeff; typedeff->setAssociatedEnum(this); @@ -584,8 +584,8 @@ class FunctionNode : public LeafNode Native }; enum Virtualness { NonVirtual, ImpureVirtual, PureVirtual }; - FunctionNode(InnerNode *parent, const QString &name); - FunctionNode(Type type, InnerNode *parent, const QString &name, bool attached); + FunctionNode(InnerNode* parent, const QString &name); + FunctionNode(Type type, InnerNode* parent, const QString &name, bool attached); virtual ~FunctionNode() { } void setReturnType(const QString& returnType) { rt = returnType; } @@ -598,8 +598,8 @@ class FunctionNode : public LeafNode void setReimp(bool r); void addParameter(const Parameter& parameter); inline void setParameters(const QList& parameters); - void borrowParameterNames(const FunctionNode *source); - void setReimplementedFrom(FunctionNode *from); + void borrowParameterNames(const FunctionNode* source); + void setReimplementedFrom(FunctionNode* from); const QString& returnType() const { return rt; } Metaness metaness() const { return met; } @@ -616,9 +616,9 @@ class FunctionNode : public LeafNode int numOverloads() const; const QList& parameters() const { return params; } QStringList parameterNames() const; - const FunctionNode *reimplementedFrom() const { return rf; } - const QList &reimplementedBy() const { return rb; } - const PropertyNode *associatedProperty() const { return ap; } + const FunctionNode* reimplementedFrom() const { return rf; } + const QList &reimplementedBy() const { return rb; } + const PropertyNode* associatedProperty() const { return ap; } const QStringList& parentPath() const { return pp; } QStringList reconstructParams(bool values = false) const; @@ -632,7 +632,7 @@ class FunctionNode : public LeafNode void debug() const; private: - void setAssociatedProperty(PropertyNode *property); + void setAssociatedProperty(PropertyNode* property); friend class InnerNode; friend class PropertyNode; @@ -652,9 +652,9 @@ class FunctionNode : public LeafNode bool reimp: 1; bool att: 1; QList params; - const FunctionNode *rf; - const PropertyNode *ap; - QList rb; + const FunctionNode* rf; + const PropertyNode* ap; + QList rb; }; class PropertyNode : public LeafNode @@ -663,16 +663,22 @@ class PropertyNode : public LeafNode enum FunctionRole { Getter, Setter, Resetter, Notifier }; enum { NumFunctionRoles = Notifier + 1 }; - PropertyNode(InnerNode *parent, const QString& name); + PropertyNode(InnerNode* parent, const QString& name); virtual ~PropertyNode() { } void setDataType(const QString& dataType) { dt = dataType; } - void addFunction(FunctionNode *function, FunctionRole role); - void addSignal(FunctionNode *function, FunctionRole role); + 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 setScriptable(bool scriptable) { scr = toTrool(scriptable); } void setWritable(bool writable) { wri = toTrool(writable); } - void setOverriddenFrom(const PropertyNode *baseProperty); + void setUser(bool user) { usr = toTrool(user); } + void setOverriddenFrom(const PropertyNode* baseProperty); + void setRuntimeDesFunc(const QString& rdf) { runtimeDesFunc = rdf; } + void setRuntimeScrFunc(const QString& scrf) { runtimeScrFunc = scrf; } + void setConstant() { cst = true; } + void setFinal() { fnl = true; } const QString &dataType() const { return dt; } QString qualifiedDataType() const; @@ -684,8 +690,20 @@ class PropertyNode : public LeafNode NodeList notifiers() const { return functions(Notifier); } bool isStored() const { return fromTrool(sto, storedDefault()); } bool isDesignable() const { return fromTrool(des, designableDefault()); } + bool isScriptable() const { return fromTrool(scr, scriptableDefault()); } + const QString& runtimeDesignabilityFunction() const { return runtimeDesFunc; } + const QString& runtimeScriptabilityFunction() const { return runtimeScrFunc; } bool isWritable() const { return fromTrool(wri, writableDefault()); } - const PropertyNode *overriddenFrom() const { return overrides; } + bool isUser() const { return fromTrool(usr, userDefault()); } + bool isConstant() const { return cst; } + bool isFinal() const { return fnl; } + const PropertyNode* overriddenFrom() const { return overrides; } + + bool storedDefault() const { return true; } + bool userDefault() const { return false; } + bool designableDefault() const { return !setters().isEmpty(); } + bool scriptableDefault() const { return true; } + bool writableDefault() const { return !setters().isEmpty(); } private: enum Trool { Trool_True, Trool_False, Trool_Default }; @@ -693,16 +711,18 @@ class PropertyNode : public LeafNode static Trool toTrool(bool boolean); static bool fromTrool(Trool troolean, bool defaultValue); - bool storedDefault() const { return true; } - bool designableDefault() const { return !setters().isEmpty(); } - bool writableDefault() const { return !setters().isEmpty(); } - QString dt; + QString runtimeDesFunc; + QString runtimeScrFunc; NodeList funcs[NumFunctionRoles]; Trool sto; Trool des; + Trool scr; Trool wri; - const PropertyNode *overrides; + Trool usr; + bool cst; + bool fnl; + const PropertyNode* overrides; }; inline void FunctionNode::setParameters(const QList ¶meters) @@ -710,13 +730,13 @@ inline void FunctionNode::setParameters(const QList ¶meters) params = parameters; } -inline void PropertyNode::addFunction(FunctionNode *function, FunctionRole role) +inline void PropertyNode::addFunction(FunctionNode* function, FunctionRole role) { funcs[(int)role].append(function); function->setAssociatedProperty(this); } -inline void PropertyNode::addSignal(FunctionNode *function, FunctionRole role) +inline void PropertyNode::addSignal(FunctionNode* function, FunctionRole role) { funcs[(int)role].append(function); } @@ -732,7 +752,7 @@ inline NodeList PropertyNode::functions() const class VariableNode : public LeafNode { public: - VariableNode(InnerNode *parent, const QString &name); + VariableNode(InnerNode* parent, const QString &name); virtual ~VariableNode() { } void setLeftType(const QString &leftType) { lt = leftType; } @@ -750,15 +770,16 @@ class VariableNode : public LeafNode bool sta; }; -inline VariableNode::VariableNode(InnerNode *parent, const QString &name) +inline VariableNode::VariableNode(InnerNode* parent, const QString &name) : LeafNode(Variable, parent, name), sta(false) { + // nothing. } class TargetNode : public LeafNode { public: - TargetNode(InnerNode *parent, const QString& name); + TargetNode(InnerNode* parent, const QString& name); virtual ~TargetNode() { } virtual bool isInnerNode() const; -- cgit v0.12 From 79342a635d71d1612795ab878b145f6e95ab23d2 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 25 Jun 2010 10:32:47 +0200 Subject: Updated Harfbuzz from git+ssh://git.freedesktop.org/git/harfbuzz to 4b88f595ab62b7c5f703a286c4f5f13f8784a936 * Fix crash/regression in thai line word breaking when libthai is installed: Commit 4b88f595ab62b7c5f703a286c4f5f13f8784a936 upstream ensures the zero termination of the string passed to libthai. --- src/3rdparty/harfbuzz/src/harfbuzz-thai.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c index fc2bdbf..e153ba9 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c @@ -53,6 +53,8 @@ static void to_tis620(const HB_UChar16 *string, hb_uint32 len, const char *cstr) else result[i] = '?'; } + + result[len] = 0; } static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttributes *attributes) @@ -70,8 +72,8 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri if (!th_brk) return; - if (len > 128) - cstr = (char *)malloc(len*sizeof(char)); + if (len >= 128) + cstr = (char *)malloc(len*sizeof(char) + 1); to_tis620(string, len, cstr); @@ -96,7 +98,7 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri if (break_positions != brp) free(break_positions); - if (len > 128) + if (len >= 128) free(cstr); } -- cgit v0.12 From bae307e98aedb70d46ca0fd934d6fbca6044b151 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 25 Jun 2010 11:05:27 +0200 Subject: Fix linking on arm with def files Added two missing QIODevicePrivate exports used implicitly by QtNetwork Reviewed-by: Trust me --- src/s60installs/eabi/QtCoreu.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 48cad39..7b9e777 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3707,4 +3707,6 @@ EXPORTS _ZrsR11QDataStreamR12QEasingCurve @ 3706 NONAME _ZNK7QLocale13textDirectionEv @ 3707 NONAME _ZNK7QString13isRightToLeftEv @ 3708 NONAME + _ZN16QIODevicePrivate4peekEPcx @ 3709 NONAME + _ZN16QIODevicePrivate4peekEx @ 3710 NONAME -- cgit v0.12 From 65725d65882bd821c2a704307d201d246d8342b5 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Fri, 25 Jun 2010 11:14:22 +0200 Subject: Fix warnings in QSslSocketPrivate::systemCaCertificates() Reviewed-by: Markus Goetz --- src/network/ssl/qsslsocket_openssl.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 36a0cc7..9bd93a2 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -574,17 +574,17 @@ QList QSslSocketPrivate::systemCaCertificates() } } #elif defined(Q_OS_AIX) - systemCerts.append(QSslCertificate::fromPath("/var/ssl/certs/*.pem", QSsl::Pem, QRegExp::Wildcard)); + systemCerts.append(QSslCertificate::fromPath(QLatin1String("/var/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); #elif defined(Q_OS_SOLARIS) - systemCerts.append(QSslCertificate::fromPath("/usr/local/ssl/certs/*.pem", QSsl::Pem, QRegExp::Wildcard)); + systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/local/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); #elif defined(Q_OS_HPUX) - systemCerts.append(QSslCertificate::fromPath("/opt/openssl/certs/*.pem", QSsl::Pem, QRegExp::Wildcard)); + systemCerts.append(QSslCertificate::fromPath(QLatin1String("/opt/openssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); #elif defined(Q_OS_LINUX) - systemCerts.append(QSslCertificate::fromPath("/etc/ssl/certs/*.pem", QSsl::Pem, QRegExp::Wildcard)); // (K)ubuntu, OpenSUSE, Mandriva, ... - systemCerts.append(QSslCertificate::fromPath("/etc/pki/tls/certs/ca-bundle.crt", QSsl::Pem)); // Fedora - systemCerts.append(QSslCertificate::fromPath("/usr/lib/ssl/certs/*.pem", QSsl::Pem, QRegExp::Wildcard)); // Gentoo, Mandrake - systemCerts.append(QSslCertificate::fromPath("/usr/share/ssl/*.pem", QSsl::Pem, QRegExp::Wildcard)); // Centos, Redhat, SuSE - systemCerts.append(QSslCertificate::fromPath("/usr/local/ssl/*.pem", QSsl::Pem, QRegExp::Wildcard)); // Normal OpenSSL Tarball + systemCerts.append(QSslCertificate::fromPath(QLatin1String("/etc/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // (K)ubuntu, OpenSUSE, Mandriva, ... + systemCerts.append(QSslCertificate::fromPath(QLatin1String("/etc/pki/tls/certs/ca-bundle.crt"), QSsl::Pem)); // Fedora + systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/lib/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // Gentoo, Mandrake + systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/share/ssl/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // Centos, Redhat, SuSE + systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/local/ssl/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // Normal OpenSSL Tarball #endif return systemCerts; } -- cgit v0.12 From 1223f3f3d32bdc394a0fcd8d034fb3ad0afab0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 24 Jun 2010 15:15:56 +0200 Subject: Fixed autotest failure in QPainter::setOpacity when NEON is used. Be more lenient in the comparison, rounding errors might lead to slightly different values. Reviewed-by: Trond --- tests/auto/qpainter/tst_qpainter.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 701dc2e..27ee6e7 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -2648,12 +2648,16 @@ void tst_QPainter::setOpacity() p.drawImage(imageRect, src, imageRect); p.end(); - QImage expected(imageSize, destFormat); - p.begin(&expected); - p.fillRect(imageRect, QColor(127, 127, 127)); - p.end(); - - QCOMPARE(dest, expected); + QImage actual = dest.convertToFormat(QImage::Format_RGB32); + + for (int y = 0; y < actual.height(); ++y) { + QRgb *p = (QRgb *)actual.scanLine(y); + for (int x = 0; x < actual.width(); ++x) { + QVERIFY(qAbs(qRed(p[x]) - 127) <= 0xf); + QVERIFY(qAbs(qGreen(p[x]) - 127) <= 0xf); + QVERIFY(qAbs(qBlue(p[x]) - 127) <= 0xf); + } + } } void tst_QPainter::drawhelper_blend_untransformed_data() -- cgit v0.12 From 6887d006ecf2b4a4250659c45a2d9ba002dbcb80 Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 25 Jun 2010 11:38:56 +0200 Subject: Update EABI and WINSCW DEF files for Symbian Reviewed-by: TrustMe --- src/s60installs/bwins/QtCoreu.def | 2 ++ src/s60installs/bwins/QtDeclarativeu.def | 4 ++++ src/s60installs/bwins/QtGuiu.def | 4 ++++ src/s60installs/eabi/QtDeclarativeu.def | 5 +++++ src/s60installs/eabi/QtGuiu.def | 3 +++ 5 files changed, 18 insertions(+) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 45caeb0..101c6a8 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4480,4 +4480,6 @@ EXPORTS ?trUtf8@QEventDispatcherSymbian@@SA?AVQString@@PBD0H@Z @ 4479 NONAME ; class QString QEventDispatcherSymbian::trUtf8(char const *, char const *, int) ?staticMetaObject@QEventDispatcherSymbian@@2UQMetaObject@@B @ 4480 NONAME ; struct QMetaObject const QEventDispatcherSymbian::staticMetaObject ?textDirection@QLocale@@QBE?AW4LayoutDirection@Qt@@XZ @ 4481 NONAME ; enum Qt::LayoutDirection QLocale::textDirection(void) const + ?peek@QIODevicePrivate@@UAE_JPAD_J@Z @ 4482 NONAME ; long long QIODevicePrivate::peek(char *, long long) + ?peek@QIODevicePrivate@@UAE?AVQByteArray@@_J@Z @ 4483 NONAME ; class QByteArray QIODevicePrivate::peek(long long) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index 0aac72b..ddc8cf4 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -4097,4 +4097,8 @@ EXPORTS ?setHeader@QDeclarativeGridView@@QAEXPAVQDeclarativeComponent@@@Z @ 4096 NONAME ; void QDeclarativeGridView::setHeader(class QDeclarativeComponent *) ?header@QDeclarativeGridView@@QBEPAVQDeclarativeComponent@@XZ @ 4097 NONAME ; class QDeclarativeComponent * QDeclarativeGridView::header(void) const ?footerChanged@QDeclarativeGridView@@IAEXXZ @ 4098 NONAME ; void QDeclarativeGridView::footerChanged(void) + ?registerAutoParentFunction@QDeclarativePrivate@@YAHP6A?AW4AutoParentResult@1@PAVQObject@@0@Z@Z @ 4099 NONAME ; int QDeclarativePrivate::registerAutoParentFunction(enum QDeclarativePrivate::AutoParentResult (*)(class QObject *, class QObject *)) + ?parentFunctions@QDeclarativeMetaType@@SA?AV?$QList@P6A?AW4AutoParentResult@QDeclarativePrivate@@PAVQObject@@0@Z@@XZ @ 4100 NONAME ; class QList QDeclarativeMetaType::parentFunctions(void) + ?inputMethodEvent@QDeclarativeTextInput@@MAEXPAVQInputMethodEvent@@@Z @ 4101 NONAME ; void QDeclarativeTextInput::inputMethodEvent(class QInputMethodEvent *) + ?doUpdate@QDeclarativeBorderImage@@AAEXXZ @ 4102 NONAME ; void QDeclarativeBorderImage::doUpdate(void) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index d439927..6e20131 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -12820,4 +12820,8 @@ EXPORTS ?textOption@QStaticText@@QBE?AVQTextOption@@XZ @ 12819 NONAME ; class QTextOption QStaticText::textOption(void) const ?isRightToLeft@QTextEngine@@QBE_NXZ @ 12820 NONAME ; bool QTextEngine::isRightToLeft(void) const ?textDirection@QTextBlock@@QBE?AW4LayoutDirection@Qt@@XZ @ 12821 NONAME ; enum Qt::LayoutDirection QTextBlock::textDirection(void) const + ?convertInPlace@QImageData@@QAE_NW4Format@QImage@@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 12822 NONAME ; bool QImageData::convertInPlace(enum QImage::Format, class QFlags) + ?createPixmapForImage@QRasterPixmapData@@IAEXAAVQImage@@V?$QFlags@W4ImageConversionFlag@Qt@@@@_N@Z @ 12823 NONAME ; void QRasterPixmapData::createPixmapForImage(class QImage &, class QFlags, bool) + ??0Tab@QTextOption@@QAE@MW4TabType@1@VQChar@@@Z @ 12824 NONAME ; QTextOption::Tab::Tab(float, enum QTextOption::TabType, class QChar) + ?fromData@QRasterPixmapData@@UAE_NPBEIPBDV?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 12825 NONAME ; bool QRasterPixmapData::fromData(unsigned char const *, unsigned int, char const *, class QFlags) diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index f997454..96e74a6 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -3681,4 +3681,9 @@ EXPORTS _ZNK17QDeclarativeState7isNamedEv @ 3680 NONAME _ZNK20QDeclarativeGridView6footerEv @ 3681 NONAME _ZNK20QDeclarativeGridView6headerEv @ 3682 NONAME + _ZN19QDeclarativePrivate26registerAutoParentFunctionEPFNS_16AutoParentResultEP7QObjectS2_E @ 3683 NONAME + _ZN20QDeclarativeMetaType15parentFunctionsEv @ 3684 NONAME + _ZN21QDeclarativeTextInput16inputMethodEventEP17QInputMethodEvent @ 3685 NONAME + _ZN23QDeclarativeBorderImage8doUpdateEv @ 3686 NONAME + _ZThn8_N21QDeclarativeTextInput16inputMethodEventEP17QInputMethodEvent @ 3687 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index b59ddee..e7d865b 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12017,4 +12017,7 @@ EXPORTS _ZNK11QStaticText10textOptionEv @ 12016 NONAME _ZNK11QTextEngine13isRightToLeftEv @ 12017 NONAME _ZNK14QWidgetPrivate22childAtRecursiveHelperERK6QPointbb @ 12018 NONAME + _ZN10QImageData14convertInPlaceEN6QImage6FormatE6QFlagsIN2Qt19ImageConversionFlagEE @ 12019 NONAME + _ZN17QRasterPixmapData20createPixmapForImageER6QImage6QFlagsIN2Qt19ImageConversionFlagEEb @ 12020 NONAME + _ZN17QRasterPixmapData8fromDataEPKhjPKc6QFlagsIN2Qt19ImageConversionFlagEE @ 12021 NONAME -- cgit v0.12 From a144416f28ff256eed9913edc8453acb00760876 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 25 Jun 2010 11:21:21 +0200 Subject: QSemaphore::tryAquire(timeout) -- never times out on an active semaphore If a thread trying to acquire multiple resources is continuously preempted by threads acquiring smaller amounts, the larger consumer would end up waiting forever (instead of for the given timeout). Fix this by keeping track of elapsed time between wakeups using QElapsedTimer. Task-number: QTBUG-11500 Reviewed-by: thiago --- src/corelib/thread/qsemaphore.cpp | 7 ++++- tests/auto/qsemaphore/tst_qsemaphore.cpp | 49 ++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 9dc828d..8e8a88a 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -44,6 +44,8 @@ #ifndef QT_NO_THREAD #include "qmutex.h" #include "qwaitcondition.h" +#include "qelapsedtimer.h" +#include "qdatetime.h" QT_BEGIN_NAMESPACE @@ -218,8 +220,11 @@ bool QSemaphore::tryAcquire(int n, int timeout) while (n > d->avail) d->cond.wait(locker.mutex()); } else { + QElapsedTimer timer; + timer.start(); while (n > d->avail) { - if (!d->cond.wait(locker.mutex(), timeout)) + if (timer.hasExpired(timeout) + || !d->cond.wait(locker.mutex(), timeout - timer.elapsed())) return false; } } diff --git a/tests/auto/qsemaphore/tst_qsemaphore.cpp b/tests/auto/qsemaphore/tst_qsemaphore.cpp index ace33dc..7cede30 100644 --- a/tests/auto/qsemaphore/tst_qsemaphore.cpp +++ b/tests/auto/qsemaphore/tst_qsemaphore.cpp @@ -63,6 +63,7 @@ private slots: void tryAcquire(); void tryAcquireWithTimeout_data(); void tryAcquireWithTimeout(); + void tryAcquireWithTimeoutStarvation(); void release(); void available(); void producerConsumer(); @@ -232,8 +233,8 @@ void tst_QSemaphore::tryAcquireWithTimeout_data() { QTest::addColumn("timeout"); - QTest::newRow("") << 1000; - QTest::newRow("") << 10000; + QTest::newRow("1s") << 1000; + QTest::newRow("10s") << 10000; } void tst_QSemaphore::tryAcquireWithTimeout() @@ -316,6 +317,50 @@ void tst_QSemaphore::tryAcquireWithTimeout() QCOMPARE(semaphore.available(), 0); } +void tst_QSemaphore::tryAcquireWithTimeoutStarvation() +{ + class Thread : public QThread + { + public: + QSemaphore startup; + QSemaphore *semaphore; + int amountToConsume, timeout; + + void run() + { + startup.release(); + forever { + if (!semaphore->tryAcquire(amountToConsume, timeout)) + break; + semaphore->release(amountToConsume); + } + } + }; + + QSemaphore semaphore; + semaphore.release(1); + + Thread consumer; + consumer.semaphore = &semaphore; + consumer.amountToConsume = 1; + consumer.timeout = 1000; + + // start the thread and wait for it to start consuming + consumer.start(); + consumer.startup.acquire(); + + // try to consume more than the thread we started is, and provide a longer + // timeout... we should timeout, not wait indefinitely + QVERIFY(!semaphore.tryAcquire(consumer.amountToConsume * 2, consumer.timeout * 2)); + + // the consumer should still be running + QVERIFY(consumer.isRunning() && !consumer.isFinished()); + + // acquire, and wait for smallConsumer to timeout + semaphore.acquire(); + QVERIFY(consumer.wait()); +} + void tst_QSemaphore::release() { DEPENDS_ON("acquire"); } -- cgit v0.12 From 451a017e4d819a53d22b5dd5b562f99bda7ac087 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 25 Jun 2010 13:29:45 +0200 Subject: doc: Added more DITA output to the XML generator Output the \variable stuff as a cxxVariable. Task-number: QTBUG-11391 --- tools/qdoc3/codechunk.h | 2 +- tools/qdoc3/ditaxmlgenerator.cpp | 72 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/tools/qdoc3/codechunk.h b/tools/qdoc3/codechunk.h index e78873c..a0c554e 100644 --- a/tools/qdoc3/codechunk.h +++ b/tools/qdoc3/codechunk.h @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE /* The CodeChunk class represents a tiny piece of C++ code. - The class provides convertion between a list of lexemes and a string. It adds + The class provides conversion between a list of lexemes and a string. It adds spaces at the right place for consistent style. The tiny pieces of code it represents are data types, enum values, and default parameter values. diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index 852d209..0135983 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -4573,7 +4573,8 @@ void DitaXmlGenerator::writeLocation(const Node* n) s2 = CXXTYPEDEFDECLARATIONFILE; s3 = CXXTYPEDEFDECLARATIONFILELINE; } - else if (n->type() == Node::Property) { + else if ((n->type() == Node::Property) || + (n->type() == Node::Variable)) { s1 = CXXVARIABLEAPIITEMLOCATION; s2 = CXXVARIABLEDECLARATIONFILE; s3 = CXXVARIABLEDECLARATIONFILELINE; @@ -4716,6 +4717,8 @@ void DitaXmlGenerator::writeParameters(const FunctionNode* fn, CodeMarker* marke writer.writeStartElement(CXXFUNCTIONPARAMETER); writer.writeStartElement(CXXFUNCTIONPARAMETERDECLAREDTYPE); writer.writeCharacters((*p).leftType()); + if (!(*p).rightType().isEmpty()) + writer.writeCharacters((*p).rightType()); writer.writeEndElement(); // writer.writeStartElement(CXXFUNCTIONPARAMETERDECLARATIONNAME); writer.writeCharacters((*p).name()); @@ -4888,12 +4891,6 @@ void DitaXmlGenerator::writeTypedefs(const Section& s, } } -void DitaXmlGenerator::writeDataMembers(const Section& s, - const ClassNode* cn, - CodeMarker* marker) -{ -} - void DitaXmlGenerator::writeProperties(const Section& s, const ClassNode* cn, CodeMarker* marker) @@ -4992,6 +4989,67 @@ void DitaXmlGenerator::writeProperties(const Section& s, } } +void DitaXmlGenerator::writeDataMembers(const Section& s, + const ClassNode* cn, + CodeMarker* marker) +{ + NodeList::ConstIterator m = s.members.begin(); + while (m != s.members.end()) { + if ((*m)->type() == Node::Variable) { + const VariableNode* vn = static_cast(*m); + writer.writeStartElement(CXXVARIABLE); + writer.writeAttribute("id",vn->guid()); + writer.writeStartElement(APINAME); + writer.writeCharacters(vn->name()); + writer.writeEndElement(); // + generateBrief(vn,marker); + writer.writeStartElement(CXXVARIABLEDETAIL); + writer.writeStartElement(CXXVARIABLEDEFINITION); + writer.writeStartElement(CXXVARIABLEACCESSSPECIFIER); + writer.writeAttribute("value",vn->accessString()); + writer.writeEndElement(); // + + writer.writeStartElement(CXXVARIABLEDECLAREDTYPE); + writer.writeCharacters(vn->leftType()); + if (!vn->rightType().isEmpty()) + writer.writeCharacters(vn->rightType()); + writer.writeEndElement(); // + + QString fq = fullQualification(vn); + if (!fq.isEmpty()) { + writer.writeStartElement(CXXVARIABLESCOPEDNAME); + writer.writeCharacters(fq); + writer.writeEndElement(); // + } + + writer.writeStartElement(CXXVARIABLEPROTOTYPE); + writer.writeCharacters(vn->leftType() + " "); + //writer.writeCharacters(vn->parent()->name() + "::" + vn->name()); + writer.writeCharacters(vn->name()); + if (!vn->rightType().isEmpty()) + writer.writeCharacters(vn->rightType()); + writer.writeEndElement(); // + + writer.writeStartElement(CXXVARIABLENAMELOOKUP); + writer.writeCharacters(vn->parent()->name() + "::" + vn->name()); + writer.writeEndElement(); // + + writeLocation(vn); + writer.writeEndElement(); // + writer.writeStartElement(APIDESC); + + if (!vn->doc().isEmpty()) { + generateBody(vn, marker); + } + + writer.writeEndElement(); // + writer.writeEndElement(); // + writer.writeEndElement(); // + } + ++m; + } +} + void DitaXmlGenerator::writerFunctions(const QString& tag, const NodeList& nlist) { NodeList::const_iterator n = nlist.begin(); -- cgit v0.12 From 287f6e933add5dc822c484170c5fece25c7ac846 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 25 Jun 2010 14:08:21 +0200 Subject: Doc: fixing search bug --- tools/qdoc3/htmlgenerator.cpp | 12 +++++++++++- tools/qdoc3/test/qt-html-templates.qdocconf | 6 ++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 339c390..9e16676 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1890,7 +1890,17 @@ void HtmlGenerator::generateFooter(const Node *node) } else { - out() << " \n"; + out() << " \n";\n"; + out() << " \n"; out() << "\n"; } out() << "\n"; diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 1fb000b..b82e337 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -11,7 +11,7 @@ HTML.postheader = "
\n" \ " Qt Reference Documentation\n" \ "
\n" \ "
\n" \ - " \n" \ + " \n" \ "
\n" \ "
\n" \ "
\n" \ @@ -160,7 +160,9 @@ HTML.footer = " \n" \ "
\n" \ "
X
\n" \ "
\n" \ - "

\n" \ + "

Thank you for giving your feedback.

Make sure it is related the page. For more general bugs and \n" \ + " requests, please use the Qt Bug Tracker

\n" \ + "

\n" \ "

\n" \ "
\n" \ "
\n" \ -- cgit v0.12 From ff7b6c0da57c37f39b72b9823c5b4d78c4e95cb7 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 25 Jun 2010 15:43:56 +0200 Subject: Change the files to camelcase as avkon now does that In older avkon solutions all headers were lowercase in newer they are CamelCase... Reviewed-by: Axis --- mkspecs/common/symbian/header-wrappers/AknLayoutFont.h | 2 ++ .../header-wrappers/AknsBasicBackgroundControlContext.h | 1 + mkspecs/common/symbian/header-wrappers/AknsConstants.h | 1 + mkspecs/common/symbian/header-wrappers/AknsDrawUtils.h | 1 + mkspecs/common/symbian/header-wrappers/AknsItemID.h | 1 + mkspecs/common/symbian/header-wrappers/AknsSkinInstance.h | 1 + mkspecs/common/symbian/header-wrappers/AknsUtils.h | 1 + src/gui/styles/qs60style_s60.cpp | 14 +++++++------- 8 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 mkspecs/common/symbian/header-wrappers/AknLayoutFont.h create mode 100644 mkspecs/common/symbian/header-wrappers/AknsBasicBackgroundControlContext.h create mode 100644 mkspecs/common/symbian/header-wrappers/AknsConstants.h create mode 100644 mkspecs/common/symbian/header-wrappers/AknsDrawUtils.h create mode 100644 mkspecs/common/symbian/header-wrappers/AknsItemID.h create mode 100644 mkspecs/common/symbian/header-wrappers/AknsSkinInstance.h create mode 100644 mkspecs/common/symbian/header-wrappers/AknsUtils.h diff --git a/mkspecs/common/symbian/header-wrappers/AknLayoutFont.h b/mkspecs/common/symbian/header-wrappers/AknLayoutFont.h new file mode 100644 index 0000000..b5954e1 --- /dev/null +++ b/mkspecs/common/symbian/header-wrappers/AknLayoutFont.h @@ -0,0 +1,2 @@ +#include + diff --git a/mkspecs/common/symbian/header-wrappers/AknsBasicBackgroundControlContext.h b/mkspecs/common/symbian/header-wrappers/AknsBasicBackgroundControlContext.h new file mode 100644 index 0000000..d121122 --- /dev/null +++ b/mkspecs/common/symbian/header-wrappers/AknsBasicBackgroundControlContext.h @@ -0,0 +1 @@ +#include diff --git a/mkspecs/common/symbian/header-wrappers/AknsConstants.h b/mkspecs/common/symbian/header-wrappers/AknsConstants.h new file mode 100644 index 0000000..c262866 --- /dev/null +++ b/mkspecs/common/symbian/header-wrappers/AknsConstants.h @@ -0,0 +1 @@ +#include diff --git a/mkspecs/common/symbian/header-wrappers/AknsDrawUtils.h b/mkspecs/common/symbian/header-wrappers/AknsDrawUtils.h new file mode 100644 index 0000000..7d71624 --- /dev/null +++ b/mkspecs/common/symbian/header-wrappers/AknsDrawUtils.h @@ -0,0 +1 @@ +#include diff --git a/mkspecs/common/symbian/header-wrappers/AknsItemID.h b/mkspecs/common/symbian/header-wrappers/AknsItemID.h new file mode 100644 index 0000000..fe3b80e --- /dev/null +++ b/mkspecs/common/symbian/header-wrappers/AknsItemID.h @@ -0,0 +1 @@ +#include diff --git a/mkspecs/common/symbian/header-wrappers/AknsSkinInstance.h b/mkspecs/common/symbian/header-wrappers/AknsSkinInstance.h new file mode 100644 index 0000000..4a9dcd8 --- /dev/null +++ b/mkspecs/common/symbian/header-wrappers/AknsSkinInstance.h @@ -0,0 +1 @@ +#include diff --git a/mkspecs/common/symbian/header-wrappers/AknsUtils.h b/mkspecs/common/symbian/header-wrappers/AknsUtils.h new file mode 100644 index 0000000..1b9bece --- /dev/null +++ b/mkspecs/common/symbian/header-wrappers/AknsUtils.h @@ -0,0 +1 @@ +#include diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 4bb2ea8..2527662 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -50,17 +50,17 @@ #include "qapplication.h" #include -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include -#include +#include #include #include #include -- cgit v0.12 From 15866a4436814da5da9348a8c930ee1d826ecb9a Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 25 Jun 2010 15:44:04 +0200 Subject: Make symbian/unix shadow builds work again. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 5d97405..7f6d43b 100755 --- a/configure +++ b/configure @@ -2340,7 +2340,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then chmod 755 "$outpath/bin/syncqt" fi - for i in createpackage patch_capabilities; do + for i in elf2e32_qtwrapper createpackage patch_capabilities; do rm -f "$outpath/bin/$i" if [ -x "$relpath/bin/$i" ]; then mkdir -p "$outpath/bin" -- cgit v0.12 From 075648e46650797f2b520f98513a7aed9f0ffec7 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 25 Jun 2010 15:47:58 +0200 Subject: Warn if surface creation fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Output the same warning that qegl.cpp does also in the X11 implementation. Reviewed-by: Trond Kjernåsen --- src/gui/egl/qegl_x11.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index 969acc4..fea6e8d 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -415,7 +415,10 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig config, const QEg // At this point, the widget's window should be created and have the correct visual. Now we // just need to create the EGL surface for it: - return eglCreateWindowSurface(QEgl::display(), config, (EGLNativeWindowType)widget->winId(), 0); + EGLSurface surf = eglCreateWindowSurface(QEgl::display(), config, (EGLNativeWindowType)widget->winId(), 0); + if (surf == EGL_NO_SURFACE) + qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); + return surf; } if (x11PixmapData) { -- cgit v0.12 From 860094d4e2614c0926f2af0e3538412ece31f726 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 25 Jun 2010 16:05:25 +0200 Subject: Avoid memory allocation when converting from Gbk to unicode. This change is the equivalent of 19e1b32bdeeeb5c7865038cab97b40dbac0e6c42 and 987458462994497f764baf253baca0faabdb63cc but for the Gbk case. It improve performance by avoiding the constructor of QChar and by allocating the memory once instead of doing it for each character. This also fix QTBUG-11704. Reviewed-by: Andreas Kling --- src/plugins/codecs/cn/qgb18030codec.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/codecs/cn/qgb18030codec.cpp b/src/plugins/codecs/cn/qgb18030codec.cpp index 3f2eec7..e10c8b1 100644 --- a/src/plugins/codecs/cn/qgb18030codec.cpp +++ b/src/plugins/codecs/cn/qgb18030codec.cpp @@ -319,7 +319,7 @@ QString QGbkCodec::convertToUnicode(const char* chars, int len, ConverterState * { uchar buf[2]; int nbuf = 0; - QChar replacement = QChar::ReplacementCharacter; + ushort replacement = QChar::ReplacementCharacter; if (state) { if (state->flags & ConvertInvalidToNull) replacement = QChar::Null; @@ -330,6 +330,9 @@ QString QGbkCodec::convertToUnicode(const char* chars, int len, ConverterState * int invalid = 0; QString result; + result.resize(len); + int unicodeLen = 0; + ushort *const resultData = reinterpret_cast(result.data()); //qDebug("QGbkDecoder::toUnicode(const char* chars = \"%s\", int len = %d)", chars, len); for (int i=0; i(u)); + ++unicodeLen; } else { - result += replacement; + resultData[unicodeLen] = replacement; + ++unicodeLen; ++invalid; } nbuf = 0; } else { // Error - result += replacement; + resultData[unicodeLen] = replacement; + ++unicodeLen; ++invalid; nbuf = 0; } break; } } + result.resize(unicodeLen); if (state) { state->remainingChars = nbuf; -- cgit v0.12 From a179ae5dd94d0c51ebbf7d5c5b8eef5b3099c163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 25 Jun 2010 14:11:44 +0200 Subject: Fixed autotest failure in QPathClipper on N900. We need to use double precision for the angle computations, as they are crucial to build correct winged edge structures. Reviewed-by: Trond --- src/gui/painting/qpathclipper.cpp | 48 +++++++++++++-------------------------- src/gui/painting/qpathclipper_p.h | 4 ++-- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 78553c9..a17b7c1 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -86,9 +86,11 @@ static qreal dot(const QPointF &a, const QPointF &b) return a.x() * b.x() + a.y() * b.y(); } -static QPointF normalize(const QPointF &p) +static void normalize(double &x, double &y) { - return p / qSqrt(p.x() * p.x() + p.y() * p.y()); + double reciprocal = 1 / qSqrt(x * x + y * y); + x *= reciprocal; + y *= reciprocal; } struct QIntersection @@ -1017,8 +1019,8 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const const QPathEdge *ap = edge(a); const QPathEdge *bp = edge(b); - qreal a_angle = ap->angle; - qreal b_angle = bp->angle; + double a_angle = ap->angle; + double b_angle = bp->angle; if (vertex == ap->second) a_angle = ap->invAngle; @@ -1026,7 +1028,7 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const if (vertex == bp->second) b_angle = bp->invAngle; - qreal result = b_angle - a_angle; + double result = b_angle - a_angle; if (result >= 128.) return result - 128.; @@ -1036,26 +1038,6 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const return result; } -static inline QPointF tangentAt(const QWingedEdge &list, int vi, int ei) -{ - const QPathEdge *ep = list.edge(ei); - Q_ASSERT(ep); - - qreal sign; - - if (ep->first == vi) { - sign = 1; - } else { - sign = -1; - } - - const QPointF a = *list.vertex(ep->first); - const QPointF b = *list.vertex(ep->second); - QPointF normal = b - a; - - return normalize(sign * normal); -} - static inline QPointF midPoint(const QWingedEdge &list, int ei) { const QPathEdge *ep = list.edge(ei); @@ -1191,7 +1173,7 @@ static int commonEdge(const QWingedEdge &list, int a, int b) return -1; } -static qreal computeAngle(const QPointF &v) +static double computeAngle(const QPointF &v) { #if 1 if (v.x() == 0) { @@ -1200,15 +1182,17 @@ static qreal computeAngle(const QPointF &v) return v.x() <= 0 ? 32. : 96.; } - QPointF nv = normalize(v); - if (nv.y() < 0) { - if (nv.x() < 0) { // 0 - 32 - return -32. * nv.x(); + double vx = v.x(); + double vy = v.y(); + normalize(vx, vy); + if (vy < 0) { + if (vx < 0) { // 0 - 32 + return -32. * vx; } else { // 96 - 128 - return 128. - 32. * nv.x(); + return 128. - 32. * vx; } } else { // 32 - 96 - return 64. + 32 * nv.x(); + return 64. + 32. * vx; } #else // doesn't seem to be robust enough diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h index fab618d..bdad4e1 100644 --- a/src/gui/painting/qpathclipper_p.h +++ b/src/gui/painting/qpathclipper_p.h @@ -148,8 +148,8 @@ public: int first; int second; - qreal angle; - qreal invAngle; + double angle; + double invAngle; int next(Traversal traversal, Direction direction) const; -- cgit v0.12 From 0fa3175421a3329fe4cb3fb9f79f30807105b02f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 25 Jun 2010 14:51:12 +0200 Subject: Fix conversion between JavaScript Date and QDateTime Use JavaScriptCore's conversion functions rather than our own (incomplete) implementation. Specifically, this means daylight saving time is finally handled correctly on Windows. Task-number: QTBUG-9770 Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 47 +++++ src/script/api/qscriptengine_p.h | 10 +- src/script/script.pri | 1 - src/script/utils/qscriptdate.cpp | 365 --------------------------------------- src/script/utils/qscriptdate_p.h | 52 ------ src/script/utils/utils.pri | 5 - 6 files changed, 53 insertions(+), 427 deletions(-) delete mode 100644 src/script/utils/qscriptdate.cpp delete mode 100644 src/script/utils/qscriptdate_p.h delete mode 100644 src/script/utils/utils.pri diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 655026c..7bccffe 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -438,6 +438,53 @@ qsreal ToNumber(const QString &value) #endif +static const qsreal MsPerSecond = 1000.0; + +static inline int MsFromTime(qsreal t) +{ + int r = int(::fmod(t, MsPerSecond)); + return (r >= 0) ? r : r + int(MsPerSecond); +} + +/*! + \internal + Converts a JS date value (milliseconds) to a QDateTime (local time). +*/ +QDateTime MsToDateTime(JSC::ExecState *exec, qsreal t) +{ + if (qIsNaN(t)) + return QDateTime(); + JSC::GregorianDateTime tm; + JSC::msToGregorianDateTime(exec, t, /*output UTC=*/true, tm); + int ms = MsFromTime(t); + QDateTime convertedUTC = QDateTime(QDate(tm.year + 1900, tm.month + 1, tm.monthDay), + QTime(tm.hour, tm.minute, tm.second, ms), Qt::UTC); + return convertedUTC.toLocalTime(); +} + +/*! + \internal + Converts a QDateTime to a JS date value (milliseconds). +*/ +qsreal DateTimeToMs(JSC::ExecState *exec, const QDateTime &dt) +{ + if (!dt.isValid()) + return qSNaN(); + QDateTime utc = dt.toUTC(); + QDate date = utc.date(); + QTime time = utc.time(); + JSC::GregorianDateTime tm; + tm.year = date.year() - 1900; + tm.month = date.month() - 1; + tm.monthDay = date.day(); + tm.weekDay = date.dayOfWeek(); + tm.yearDay = date.dayOfYear(); + tm.hour = time.hour(); + tm.minute = time.minute(); + tm.second = time.second(); + return JSC::gregorianDateTimeToMS(exec, tm, time.msec(), /*inputIsUTC=*/true); +} + void GlobalClientData::mark(JSC::MarkStack& markStack) { engine->mark(markStack); diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 1b35704..c71465d 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -50,7 +50,6 @@ #include "bridge/qscriptobject_p.h" #include "bridge/qscriptqobject_p.h" #include "bridge/qscriptvariant_p.h" -#include "utils/qscriptdate_p.h" #include "DateConstructor.h" #include "DateInstance.h" @@ -119,6 +118,9 @@ namespace QScript inline QString ToString(qsreal); #endif + QDateTime MsToDateTime(JSC::ExecState *, qsreal); + qsreal DateTimeToMs(JSC::ExecState *, const QDateTime &); + //some conversion helper functions inline QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec); bool isFunction(JSC::JSValue value); @@ -861,7 +863,7 @@ inline JSC::JSValue QScriptEnginePrivate::newDate(JSC::ExecState *exec, qsreal v inline JSC::JSValue QScriptEnginePrivate::newDate(JSC::ExecState *exec, const QDateTime &value) { - return newDate(exec, QScript::FromDateTime(value)); + return newDate(exec, QScript::DateTimeToMs(exec, value)); } inline JSC::JSValue QScriptEnginePrivate::newObject() @@ -994,12 +996,12 @@ inline JSC::UString QScriptEnginePrivate::toString(JSC::ExecState *exec, JSC::JS return str; } -inline QDateTime QScriptEnginePrivate::toDateTime(JSC::ExecState *, JSC::JSValue value) +inline QDateTime QScriptEnginePrivate::toDateTime(JSC::ExecState *exec, JSC::JSValue value) { if (!isDate(value)) return QDateTime(); qsreal t = static_cast(JSC::asObject(value))->internalNumber(); - return QScript::ToDateTime(t, Qt::LocalTime); + return QScript::MsToDateTime(exec, t); } inline QObject *QScriptEnginePrivate::toQObject(JSC::ExecState *exec, JSC::JSValue value) diff --git a/src/script/script.pri b/src/script/script.pri index 2ee1a82..9cd71d3 100644 --- a/src/script/script.pri +++ b/src/script/script.pri @@ -1,4 +1,3 @@ include($$PWD/api/api.pri) include($$PWD/bridge/bridge.pri) include($$PWD/parser/parser.pri) -include($$PWD/utils/utils.pri) diff --git a/src/script/utils/qscriptdate.cpp b/src/script/utils/qscriptdate.cpp deleted file mode 100644 index 5980256..0000000 --- a/src/script/utils/qscriptdate.cpp +++ /dev/null @@ -1,365 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtScript module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ -** GNU Lesser General Public License Usage -** 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qscriptdate_p.h" - -#include -#include - -#include - -#ifndef Q_WS_WIN -# include -# include -#else -# include -#endif - -QT_BEGIN_NAMESPACE - -namespace QScript { - -qsreal ToInteger(qsreal n); - -static const qsreal HoursPerDay = 24.0; -static const qsreal MinutesPerHour = 60.0; -static const qsreal SecondsPerMinute = 60.0; -static const qsreal msPerSecond = 1000.0; -static const qsreal msPerMinute = 60000.0; -static const qsreal msPerHour = 3600000.0; -static const qsreal msPerDay = 86400000.0; - -static qsreal LocalTZA = 0.0; // initialized at startup - -static inline qsreal TimeWithinDay(qsreal t) -{ - qsreal r = ::fmod(t, msPerDay); - return (r >= 0) ? r : r + msPerDay; -} - -static inline int HourFromTime(qsreal t) -{ - int r = int(::fmod(::floor(t / msPerHour), HoursPerDay)); - return (r >= 0) ? r : r + int(HoursPerDay); -} - -static inline int MinFromTime(qsreal t) -{ - int r = int(::fmod(::floor(t / msPerMinute), MinutesPerHour)); - return (r >= 0) ? r : r + int(MinutesPerHour); -} - -static inline int SecFromTime(qsreal t) -{ - int r = int(::fmod(::floor(t / msPerSecond), SecondsPerMinute)); - return (r >= 0) ? r : r + int(SecondsPerMinute); -} - -static inline int msFromTime(qsreal t) -{ - int r = int(::fmod(t, msPerSecond)); - return (r >= 0) ? r : r + int(msPerSecond); -} - -static inline qsreal Day(qsreal t) -{ - return ::floor(t / msPerDay); -} - -static inline qsreal DaysInYear(qsreal y) -{ - if (::fmod(y, 4)) - return 365; - - else if (::fmod(y, 100)) - return 366; - - else if (::fmod(y, 400)) - return 365; - - return 366; -} - -static inline qsreal DayFromYear(qsreal y) -{ - return 365 * (y - 1970) - + ::floor((y - 1969) / 4) - - ::floor((y - 1901) / 100) - + ::floor((y - 1601) / 400); -} - -static inline qsreal TimeFromYear(qsreal y) -{ - return msPerDay * DayFromYear(y); -} - -static inline qsreal YearFromTime(qsreal t) -{ - int y = 1970; - y += (int) ::floor(t / (msPerDay * 365.2425)); - - qsreal t2 = TimeFromYear(y); - return (t2 > t) ? y - 1 : ((t2 + msPerDay * DaysInYear(y)) <= t) ? y + 1 : y; -} - -static inline bool InLeapYear(qsreal t) -{ - qsreal x = DaysInYear(YearFromTime(t)); - if (x == 365) - return 0; - - Q_ASSERT (x == 366); - return 1; -} - -static inline qsreal DayWithinYear(qsreal t) -{ - return Day(t) - DayFromYear(YearFromTime(t)); -} - -static inline qsreal MonthFromTime(qsreal t) -{ - qsreal d = DayWithinYear(t); - qsreal l = InLeapYear(t); - - if (d < 31.0) - return 0; - - else if (d < 59.0 + l) - return 1; - - else if (d < 90.0 + l) - return 2; - - else if (d < 120.0 + l) - return 3; - - else if (d < 151.0 + l) - return 4; - - else if (d < 181.0 + l) - return 5; - - else if (d < 212.0 + l) - return 6; - - else if (d < 243.0 + l) - return 7; - - else if (d < 273.0 + l) - return 8; - - else if (d < 304.0 + l) - return 9; - - else if (d < 334.0 + l) - return 10; - - else if (d < 365.0 + l) - return 11; - - return qSNaN(); // ### assert? -} - -static inline qsreal DateFromTime(qsreal t) -{ - int m = (int) ToInteger(MonthFromTime(t)); - qsreal d = DayWithinYear(t); - qsreal l = InLeapYear(t); - - switch (m) { - case 0: return d + 1.0; - case 1: return d - 30.0; - case 2: return d - 58.0 - l; - case 3: return d - 89.0 - l; - case 4: return d - 119.0 - l; - case 5: return d - 150.0 - l; - case 6: return d - 180.0 - l; - case 7: return d - 211.0 - l; - case 8: return d - 242.0 - l; - case 9: return d - 272.0 - l; - case 10: return d - 303.0 - l; - case 11: return d - 333.0 - l; - } - - return qSNaN(); // ### assert -} - -static inline qsreal WeekDay(qsreal t) -{ - qsreal r = ::fmod (Day(t) + 4.0, 7.0); - return (r >= 0) ? r : r + 7.0; -} - - -static inline qsreal MakeTime(qsreal hour, qsreal min, qsreal sec, qsreal ms) -{ - return ((hour * MinutesPerHour + min) * SecondsPerMinute + sec) * msPerSecond + ms; -} - -static inline qsreal DayFromMonth(qsreal month, qsreal leap) -{ - switch ((int) month) { - case 0: return 0; - case 1: return 31.0; - case 2: return 59.0 + leap; - case 3: return 90.0 + leap; - case 4: return 120.0 + leap; - case 5: return 151.0 + leap; - case 6: return 181.0 + leap; - case 7: return 212.0 + leap; - case 8: return 243.0 + leap; - case 9: return 273.0 + leap; - case 10: return 304.0 + leap; - case 11: return 334.0 + leap; - } - - return qSNaN(); // ### assert? -} - -static qsreal MakeDay(qsreal year, qsreal month, qsreal day) -{ - year += ::floor(month / 12.0); - - month = ::fmod(month, 12.0); - if (month < 0) - month += 12.0; - - qsreal t = TimeFromYear(year); - qsreal leap = InLeapYear(t); - - day += ::floor(t / msPerDay); - day += DayFromMonth(month, leap); - - return day - 1; -} - -static inline qsreal MakeDate(qsreal day, qsreal time) -{ - return day * msPerDay + time; -} - -static inline qsreal DaylightSavingTA(double t) -{ -#ifndef Q_WS_WIN - long int tt = (long int)(t / msPerSecond); - struct tm *tmtm = localtime((const time_t*)&tt); - if (! tmtm) - return 0; - return (tmtm->tm_isdst > 0) ? msPerHour : 0; -#else - Q_UNUSED(t); - /// ### implement me - return 0; -#endif -} - -static inline qsreal LocalTime(qsreal t) -{ - return t + LocalTZA + DaylightSavingTA(t); -} - -static inline qsreal UTC(qsreal t) -{ - return t - LocalTZA - DaylightSavingTA(t - LocalTZA); -} - -static inline qsreal TimeClip(qsreal t) -{ - if (! qIsFinite(t) || fabs(t) > 8.64e15) - return qSNaN(); - return ToInteger(t); -} - -static qsreal getLocalTZA() -{ -#ifndef Q_WS_WIN - struct tm* t; - time_t curr; - time(&curr); - t = localtime(&curr); - time_t locl = mktime(t); - t = gmtime(&curr); - time_t globl = mktime(t); - return double(locl - globl) * 1000.0; -#else - TIME_ZONE_INFORMATION tzInfo; - GetTimeZoneInformation(&tzInfo); - return -tzInfo.Bias * 60.0 * 1000.0; -#endif -} - -/*! - \internal - - Converts the QDateTime \a dt to an ECMA Date value (in UTC form). -*/ -qsreal FromDateTime(const QDateTime &dt) -{ - if (!dt.isValid()) - return qSNaN(); - if (!LocalTZA) // ### move - LocalTZA = getLocalTZA(); - QDate date = dt.date(); - QTime taim = dt.time(); - int year = date.year(); - int month = date.month() - 1; - int day = date.day(); - int hours = taim.hour(); - int mins = taim.minute(); - int secs = taim.second(); - int ms = taim.msec(); - double t = MakeDate(MakeDay(year, month, day), - MakeTime(hours, mins, secs, ms)); - if (dt.timeSpec() == Qt::LocalTime) - t = UTC(t); - return TimeClip(t); -} - -/*! - \internal - - Converts the ECMA Date value \tt (in UTC form) to QDateTime - according to \a spec. -*/ -QDateTime ToDateTime(qsreal t, Qt::TimeSpec spec) -{ - if (qIsNaN(t)) - return QDateTime(); - if (!LocalTZA) // ### move - LocalTZA = getLocalTZA(); - if (spec == Qt::LocalTime) - t = LocalTime(t); - int year = int(YearFromTime(t)); - int month = int(MonthFromTime(t) + 1); - int day = int(DateFromTime(t)); - int hours = HourFromTime(t); - int mins = MinFromTime(t); - int secs = SecFromTime(t); - int ms = msFromTime(t); - return QDateTime(QDate(year, month, day), QTime(hours, mins, secs, ms), spec); -} - -} // namespace QScript - -QT_END_NAMESPACE diff --git a/src/script/utils/qscriptdate_p.h b/src/script/utils/qscriptdate_p.h deleted file mode 100644 index b9c9fd4..0000000 --- a/src/script/utils/qscriptdate_p.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtScript module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ -** GNU Lesser General Public License Usage -** 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSCRIPTDATE_P_H -#define QSCRIPTDATE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -typedef double qsreal; - -namespace QScript -{ - qsreal FromDateTime(const QDateTime &dt); - QDateTime ToDateTime(qsreal t, Qt::TimeSpec spec); -} - -QT_END_NAMESPACE - -#endif diff --git a/src/script/utils/utils.pri b/src/script/utils/utils.pri deleted file mode 100644 index d8302d5..0000000 --- a/src/script/utils/utils.pri +++ /dev/null @@ -1,5 +0,0 @@ -SOURCES += \ - $$PWD/qscriptdate.cpp - -HEADERS += \ - $$PWD/qscriptdate_p.h -- cgit v0.12 From 02e44e7d93dd5336ab9415af98f2021e542eff31 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Fri, 25 Jun 2010 16:22:50 +0200 Subject: Export the QGLPixmapData so that we can override it in a custom graphics system. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 2422 Reviewed-by: Samuel Rødal --- src/opengl/qpixmapdata_gl_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index c239bcb..736a28e 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -96,7 +96,7 @@ private: }; -class QGLPixmapData : public QPixmapData +class Q_OPENGL_EXPORT QGLPixmapData : public QPixmapData { public: QGLPixmapData(PixelType type); -- cgit v0.12 From 535adbb4954caff9d88dc57bdb57bd09b872ddf1 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Fri, 25 Jun 2010 16:22:51 +0200 Subject: Export QGLWindowSurface too. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 2422 Reviewed-by: Samuel Rødal --- src/opengl/qwindowsurface_gl_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 8ea714c..624236c 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -77,7 +77,7 @@ public: QGLWindowSurfacePrivate* d; }; -class QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice +class Q_OPENGL_EXPORT QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice { Q_OBJECT public: -- cgit v0.12 From c5aa53243bca8261d55d81cfeb525739a68b7703 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Fri, 25 Jun 2010 16:22:52 +0200 Subject: Need to access extensionFuncs in subclasses too. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 2422 Reviewed-by: Samuel Rødal --- src/opengl/qgl.cpp | 7 +++++++ src/opengl/qgl_p.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index b4c85ac..71db7a8 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2220,6 +2220,13 @@ static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum textu } } +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +QGLExtensionFuncs& QGLContextPrivate::extensionFuncs(const QGLContext *) +{ + return qt_extensionFuncs; +} +#endif + QImage QGLContextPrivate::convertToGLFormat(const QImage &image, bool force_premul, GLenum texture_format) { diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 1727a41..c7fd111 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -415,7 +415,7 @@ public: #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) static QGLExtensionFuncs qt_extensionFuncs; - static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } + static QGLExtensionFuncs& extensionFuncs(const QGLContext *); #endif static void setCurrentContext(QGLContext *context); -- cgit v0.12 From ea2ec1a4621bd80b3279ddc67e52cd16084a409b Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 25 Jun 2010 16:23:41 +0200 Subject: Add qDebug() operator for QGLFormat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Very handy to trace GL issues on a device with broken gdb Reviewed-by: Trond Kjernåsen --- src/opengl/qgl.cpp | 26 ++++++++++++++++++++++++++ src/opengl/qgl.h | 7 +++++++ 2 files changed, 33 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index b4c85ac..9effb34 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1521,6 +1521,32 @@ bool operator==(const QGLFormat& a, const QGLFormat& b) && a.d->profile == b.d->profile); } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QGLFormat &f) +{ + const QGLFormatPrivate * const d = f.d; + + dbg.nospace() << "QGLFormat(" + << "options " << d->opts + << ", plane " << d->pln + << ", depthBufferSize " << d->depthSize + << ", accumBufferSize " << d->accumSize + << ", stencilBufferSize " << d->stencilSize + << ", redBufferSize " << d->redSize + << ", greenBufferSize " << d->greenSize + << ", blueBufferSize " << d->blueSize + << ", alphaBufferSize " << d->alphaSize + << ", samples " << d->numSamples + << ", swapInterval " << d->swapInterval + << ", majorVersion " << d->majorVersion + << ", minorVersion " << d->minorVersion + << ", profile " << d->profile + << ')'; + + return dbg.space(); +} +#endif + /*! Returns false if all the options of the two QGLFormat objects diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index f0b36f7..f85cad5 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -281,6 +281,9 @@ private: friend Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&); friend Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&); +#ifndef QT_NO_DEBUG_STREAM + friend Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QGLFormat &); +#endif }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFormat::OpenGLVersionFlags) @@ -288,6 +291,10 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFormat::OpenGLVersionFlags) Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&); Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&); +#ifndef QT_NO_DEBUG_STREAM +Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QGLFormat &); +#endif + class Q_OPENGL_EXPORT QGLContext { Q_DECLARE_PRIVATE(QGLContext) -- cgit v0.12 From cc75093e3b300a37d05a81921d7811caabbfb449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 25 Jun 2010 17:21:26 +0200 Subject: EGL plane levels are the same as all other GL backends. Qt has never used level 1 for the main plane, it's always been 0 and will always be 0. Reviewed-by: Harald Fernengel --- src/opengl/qgl_egl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 0a19531..58d3b0a 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -138,7 +138,7 @@ void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) format.setDepthBufferSize(depthSize); format.setStencilBufferSize(stencilSize); format.setSamples(sampleCount); - format.setPlane(level + 1); // EGL calls level 0 "normal" whereas Qt calls 1 "normal" + format.setPlane(level); format.setDirectRendering(true); // All EGL contexts are direct-rendered format.setRgba(true); // EGL doesn't support colour index rendering format.setStereo(false); // EGL doesn't support stereo buffers -- cgit v0.12 From 8c39d25f58dbf5b401e102d73eb2371c68be141e Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Sat, 26 Jun 2010 21:25:15 +0200 Subject: Corrected filename case for wincrypt.h The case doesn't matter when building on Windows, but does when cross-compiling on Unix. Merge-request: 709 Reviewed-by: Andreas Kling --- src/network/ssl/qsslsocket_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index 42ae98f..d3c3858 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE typedef OSStatus (*PtrSecTrustSettingsCopyCertificates)(int, CFArrayRef*); typedef OSStatus (*PtrSecTrustCopyAnchorCertificates)(CFArrayRef*); #elif defined(Q_OS_WIN) -#include +#include #ifndef HCRYPTPROV_LEGACY #define HCRYPTPROV_LEGACY HCRYPTPROV #endif -- cgit v0.12 From 1a72f98a15ef78004894dc6636b8a5d969d66fde Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Sun, 27 Jun 2010 09:28:54 +1000 Subject: Fixed copy-paste error in htmlgenerator.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: htmlgenerator.cpp:1893: error: stray ‘\’ in program --- tools/qdoc3/htmlgenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 9e16676..b93db4f 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1890,7 +1890,7 @@ void HtmlGenerator::generateFooter(const Node *node) } else { - out() << " \n";\n"; + out() << " \n"; out() << "