summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/embedded/qscreenqnx_qws.cpp2
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp2
-rw-r--r--src/script/api/qscriptengine.cpp16
-rw-r--r--tests/auto/qftp/tst_qftp.cpp26
-rw-r--r--tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp2
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp2
-rw-r--r--tests/auto/qscriptengine/qscriptengine.pro1
-rw-r--r--tests/auto/qscriptengine/qscriptengine.qrc5
-rw-r--r--tests/auto/qscriptengine/translatable.js7
-rw-r--r--tests/auto/qscriptengine/translations/translatable_la.qmbin0 -> 241 bytes
-rw-r--r--tests/auto/qscriptengine/translations/translatable_la.ts34
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp40
-rw-r--r--tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp2
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp2
14 files changed, 133 insertions, 8 deletions
diff --git a/src/gui/embedded/qscreenqnx_qws.cpp b/src/gui/embedded/qscreenqnx_qws.cpp
index 705db7e..a0a697f 100644
--- a/src/gui/embedded/qscreenqnx_qws.cpp
+++ b/src/gui/embedded/qscreenqnx_qws.cpp
@@ -205,7 +205,7 @@ static bool createMemSurface(QQnxScreenContext * const d, int w, int h)
int ret = gf_surface_create(&d->memSurface, d->device, w, h,
GF_FORMAT_ARGB8888, 0,
GF_SURFACE_CREATE_CPU_FAST_ACCESS | GF_SURFACE_CREATE_CPU_LINEAR_ACCESSIBLE
- | GF_SURFACE_PHYS_CONTIG);
+ | GF_SURFACE_PHYS_CONTIG | GF_SURFACE_CREATE_SHAREABLE);
if (ret != GF_ERR_OK) {
qWarning("QQnxScreen: gf_surface_create(%dx%d) failed with error code %d",
w, h, ret);
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index bc7684a..83b7d4c 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -690,6 +690,8 @@ void QHttpNetworkConnectionChannel::detectPipeliningSupport()
&& (serverHeaderField = reply->headerField("Server"), !serverHeaderField.contains("Microsoft-IIS/4."))
&& (!serverHeaderField.contains("Microsoft-IIS/5."))
&& (!serverHeaderField.contains("Netscape-Enterprise/3."))
+ // this is adpoted from the knowledge of the Nokia 7.x browser team (DEF143319)
+ && (!serverHeaderField.contains("WebLogic"))
) {
pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningProbablySupported;
} else {
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 2422108..ccd3e56 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -41,6 +41,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qmetaobject.h>
+#include "CodeBlock.h"
#include "Error.h"
#include "JSArray.h"
#include "JSLock.h"
@@ -699,9 +700,18 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (n) must be a number");
#ifndef QT_NO_QOBJECT
QString context;
- QScriptContext *ctx = QScriptEnginePrivate::contextForFrame(exec);
- if (ctx && ctx->parentContext())
- context = QFileInfo(QScriptContextInfo(ctx->parentContext()).fileName()).baseName();
+ // The first non-empty source URL in the call stack determines the translation context.
+ {
+ JSC::ExecState *frame = exec->removeHostCallFrameFlag();
+ while (frame) {
+ if (frame->codeBlock() && frame->codeBlock()->source()
+ && !frame->codeBlock()->source()->url().isEmpty()) {
+ context = QFileInfo(frame->codeBlock()->source()->url()).baseName();
+ break;
+ }
+ frame = frame->callerFrame()->removeHostCallFrameFlag();
+ }
+ }
#endif
QString text(args.at(0).toString(exec));
#ifndef QT_NO_QOBJECT
diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp
index 638c810..2a42d6d 100644
--- a/tests/auto/qftp/tst_qftp.cpp
+++ b/tests/auto/qftp/tst_qftp.cpp
@@ -123,6 +123,8 @@ private slots:
void doneSignal();
void queueMoreCommandsInDoneSlot();
+ void qtbug7359Crash();
+
protected slots:
void stateChanged( int );
void listInfo( const QUrlInfo & );
@@ -2052,6 +2054,30 @@ void tst_QFtp::cdUpSlot(bool error)
}
}
+void tst_QFtp::qtbug7359Crash()
+{
+ QFtp ftp;
+ ftp.connectToHost("127.0.0.1");
+
+ QTime t;
+ int elapsed;
+
+ t.start();
+ while ((elapsed = t.elapsed()) < 200)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 200 - elapsed);
+
+ ftp.close();
+ t.restart();
+ while ((elapsed = t.elapsed()) < 1000)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 1000 - elapsed);
+
+ ftp.connectToHost("127.0.0.1");
+
+ t.restart();
+ while ((elapsed = t.elapsed()) < 2000)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 2000 - elapsed);
+}
+
QTEST_MAIN(tst_QFtp)
#include "tst_qftp.moc"
diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
index 3a3ea79..f86ba63 100644
--- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
+++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
@@ -641,7 +641,7 @@ void tst_QHttpSocketEngine::downloadBigFile()
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
- QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0);
+ QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("Host: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
QVERIFY(tmpSocket->write("\r\n") > 0);
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 890983e..038610d 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -4013,7 +4013,7 @@ public slots:
}
}
void startOne() {
- QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif";
+ QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/fluke.gif";
QNetworkRequest request(url);
QNetworkReply *reply = manager.get(request);
reply->setParent(this);
diff --git a/tests/auto/qscriptengine/qscriptengine.pro b/tests/auto/qscriptengine/qscriptengine.pro
index dd058a4..7d0f5d0 100644
--- a/tests/auto/qscriptengine/qscriptengine.pro
+++ b/tests/auto/qscriptengine/qscriptengine.pro
@@ -1,6 +1,7 @@
load(qttest_p4)
QT = core gui script
SOURCES += tst_qscriptengine.cpp
+RESOURCES += qscriptengine.qrc
wince* {
DEFINES += SRCDIR=\\\"./\\\"
diff --git a/tests/auto/qscriptengine/qscriptengine.qrc b/tests/auto/qscriptengine/qscriptengine.qrc
new file mode 100644
index 0000000..b87f985
--- /dev/null
+++ b/tests/auto/qscriptengine/qscriptengine.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>translations/translatable_la.qm</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/qscriptengine/translatable.js b/tests/auto/qscriptengine/translatable.js
new file mode 100644
index 0000000..0c948e7
--- /dev/null
+++ b/tests/auto/qscriptengine/translatable.js
@@ -0,0 +1,7 @@
+qsTr("One");
+qsTranslate("FooContext", "Two");
+
+var greeting_strings = [
+ QT_TR_NOOP("Hello"),
+ QT_TRANSLATE_NOOP("FooContext", "Goodbye")
+];
diff --git a/tests/auto/qscriptengine/translations/translatable_la.qm b/tests/auto/qscriptengine/translations/translatable_la.qm
new file mode 100644
index 0000000..03fcc52
--- /dev/null
+++ b/tests/auto/qscriptengine/translations/translatable_la.qm
Binary files differ
diff --git a/tests/auto/qscriptengine/translations/translatable_la.ts b/tests/auto/qscriptengine/translations/translatable_la.ts
new file mode 100644
index 0000000..3f631de
--- /dev/null
+++ b/tests/auto/qscriptengine/translations/translatable_la.ts
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="nb_NO">
+<context>
+ <name>FooContext</name>
+ <message>
+ <location filename="translatable.js" line="2"/>
+ <source>Two</source>
+ <translation>To</translation>
+ </message>
+ <message>
+ <location filename="translatable.js" line="6"/>
+ <source>Goodbye</source>
+ <translation>Farvel</translation>
+ </message>
+</context>
+<context>
+ <name>translatable</name>
+ <message>
+ <location filename="translatable.js" line="1"/>
+ <source>One</source>
+ <translation>En</translation>
+ </message>
+ <message>
+ <location filename="translatable.js" line="5"/>
+ <source>Hello</source>
+ <translation>Hallo</translation>
+ </message>
+ <message>
+ <source>Goodbye</source>
+ <translation type="obsolete">Farvel</translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index f556fa1..aa5c85d 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -154,6 +154,7 @@ private slots:
void incDecNonObjectProperty();
void installTranslatorFunctions_data();
void installTranslatorFunctions();
+ void translateScript();
void functionScopes();
void nativeFunctionScopes();
void evaluateProgram();
@@ -4314,6 +4315,45 @@ void tst_QScriptEngine::installTranslatorFunctions()
}
}
+void tst_QScriptEngine::translateScript()
+{
+ QScriptEngine engine;
+
+ QTranslator translator;
+ translator.load(":/translations/translatable_la");
+ QCoreApplication::instance()->installTranslator(&translator);
+ engine.installTranslatorFunctions();
+
+ QString fileName = QString::fromLatin1("translatable.js");
+ // Top-level
+ QCOMPARE(engine.evaluate("qsTr('One')", fileName).toString(), QString::fromLatin1("En"));
+ QCOMPARE(engine.evaluate("qsTr('Hello')", fileName).toString(), QString::fromLatin1("Hallo"));
+ // From function
+ QCOMPARE(engine.evaluate("(function() { return qsTr('One'); })()", fileName).toString(), QString::fromLatin1("En"));
+ QCOMPARE(engine.evaluate("(function() { return qsTr('Hello'); })()", fileName).toString(), QString::fromLatin1("Hallo"));
+ // From eval
+ QCOMPARE(engine.evaluate("eval('qsTr(\\'One\\')')", fileName).toString(), QString::fromLatin1("En"));
+ QCOMPARE(engine.evaluate("eval('qsTr(\\'Hello\\')')", fileName).toString(), QString::fromLatin1("Hallo"));
+
+ QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Two')", fileName).toString(), QString::fromLatin1("To"));
+ QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Farvel"));
+ // From eval
+ QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')", fileName).toString(), QString::fromLatin1("To"));
+ QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')", fileName).toString(), QString::fromLatin1("Farvel"));
+
+ // Don't exist in translation
+ QCOMPARE(engine.evaluate("qsTr('Three')", fileName).toString(), QString::fromLatin1("Three"));
+ QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'So long')", fileName).toString(), QString::fromLatin1("So long"));
+ QCOMPARE(engine.evaluate("qsTranslate('BarContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Goodbye"));
+
+ // From C++
+ // There is no context, but it shouldn't crash
+ QCOMPARE(engine.globalObject().property("qsTr").call(
+ QScriptValue(), QScriptValueList() << "One").toString(), QString::fromLatin1("One"));
+
+ QCoreApplication::instance()->removeTranslator(&translator);
+}
+
void tst_QScriptEngine::functionScopes()
{
QScriptEngine eng;
diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
index a679765..8f0cbc3 100644
--- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
+++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
@@ -780,7 +780,7 @@ void tst_QSocks5SocketEngine::downloadBigFile()
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
- QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0);
+ QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
QVERIFY(tmpSocket->write("\r\n") > 0);
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index ef7ff83..c6e4758 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -1116,7 +1116,7 @@ void tst_QTcpSocket::downloadBigFile()
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
- QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0);
+ QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
QVERIFY(tmpSocket->write("\r\n") > 0);