summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-10-29 08:20:38 (GMT)
committeraxis <qt-info@nokia.com>2009-10-29 08:20:38 (GMT)
commiteed04255446df8a749390e14cef7672c26329f6e (patch)
tree1b6cbd53bb0f90f27db3d4e36370bca024e4abad /src
parentf360555f3c7ded3c729ce972fbd65f035876b1b4 (diff)
parentf425c08d4f2e7f061a0ee8e4a1eee2b17fa64962 (diff)
downloadQt-eed04255446df8a749390e14cef7672c26329f6e.zip
Qt-eed04255446df8a749390e14cef7672c26329f6e.tar.gz
Qt-eed04255446df8a749390e14cef7672c26329f6e.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp23
-rw-r--r--src/corelib/statemachine/qstate.cpp23
-rw-r--r--src/corelib/statemachine/qstate_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicstransform.cpp3
-rw-r--r--src/gui/kernel/qdesktopwidget.cpp5
-rw-r--r--src/gui/styles/gtksymbols.cpp3
-rw-r--r--src/gui/styles/gtksymbols_p.h2
-rw-r--r--src/gui/styles/qgtkstyle.cpp36
-rw-r--r--src/network/socket/qnativesocketengine.cpp52
-rw-r--r--src/network/ssl/qsslerror.cpp57
-rw-r--r--src/opengl/gl2paintengineex/qtriangulatingstroker.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qtriangulatingstroker_p.h2
-rw-r--r--src/opengl/qglshaderprogram.cpp213
-rw-r--r--src/opengl/qglshaderprogram.h9
-rw-r--r--src/openvg/qwindowsurface_vg.cpp4
-rw-r--r--src/openvg/qwindowsurface_vgegl.cpp59
-rw-r--r--src/openvg/qwindowsurface_vgegl_p.h19
-rw-r--r--src/script/api/api.pri3
-rw-r--r--src/script/api/qscriptengine.cpp151
-rw-r--r--src/script/api/qscriptengine.h3
-rw-r--r--src/script/api/qscriptengine_p.h5
-rw-r--r--src/script/api/qscriptprogram.cpp225
-rw-r--r--src/script/api/qscriptprogram.h86
-rw-r--r--src/script/api/qscriptprogram_p.h95
25 files changed, 629 insertions, 457 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index 80c9d72..100f272 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -586,7 +586,6 @@ private slots:
void javaScriptWindowObjectClearedOnEvaluate();
void setHtml();
void setHtmlWithResource();
- void setHtmlWithBaseURL();
void ipv6HostEncoding();
void metaData();
void popupFocus();
@@ -2372,28 +2371,6 @@ void tst_QWebFrame::setHtmlWithResource()
QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red"));
}
-void tst_QWebFrame::setHtmlWithBaseURL()
-{
- QString html("<html><body><p>hello world</p><img src='resources/image2.png'/></body></html>");
-
- QWebPage page;
- QWebFrame* frame = page.mainFrame();
-
- // in few seconds, the image should be completey loaded
- QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
-
- frame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath()));
- QTest::qWait(200);
- QCOMPARE(spy.count(), 1);
-
- QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1);
- QCOMPARE(frame->evaluateJavaScript("document.images[0].width").toInt(), 128);
- QCOMPARE(frame->evaluateJavaScript("document.images[0].height").toInt(), 128);
-
- // no history item has to be added.
- QCOMPARE(m_view->page()->history()->count(), 0);
-}
-
class TestNetworkManager : public QNetworkAccessManager
{
public:
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index a6e4a57..9abf20b 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -124,7 +124,8 @@ QT_BEGIN_NAMESPACE
*/
QStatePrivate::QStatePrivate()
- : errorState(0), initialState(0), childMode(QState::ExclusiveStates)
+ : errorState(0), initialState(0), childMode(QState::ExclusiveStates),
+ transitionsListNeedsRefresh(true)
{
}
@@ -205,14 +206,17 @@ QList<QHistoryState*> QStatePrivate::historyStates() const
QList<QAbstractTransition*> QStatePrivate::transitions() const
{
- QList<QAbstractTransition*> result;
- QList<QObject*>::const_iterator it;
- for (it = children.constBegin(); it != children.constEnd(); ++it) {
- QAbstractTransition *t = qobject_cast<QAbstractTransition*>(*it);
- if (t)
- result.append(t);
+ if (transitionsListNeedsRefresh) {
+ transitionsList.clear();
+ QList<QObject*>::const_iterator it;
+ for (it = children.constBegin(); it != children.constEnd(); ++it) {
+ QAbstractTransition *t = qobject_cast<QAbstractTransition*>(*it);
+ if (t)
+ transitionsList.append(t);
+ }
+ transitionsListNeedsRefresh = false;
}
- return result;
+ return transitionsList;
}
#ifndef QT_NO_PROPERTIES
@@ -468,6 +472,9 @@ void QState::setChildMode(ChildMode mode)
*/
bool QState::event(QEvent *e)
{
+ Q_D(QState);
+ if ((e->type() == QEvent::ChildAdded) || (e->type() == QEvent::ChildRemoved))
+ d->transitionsListNeedsRefresh = true;
return QAbstractState::event(e);
}
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 20cda29..3b5f416 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -99,6 +99,8 @@ public:
QAbstractState *errorState;
QAbstractState *initialState;
QState::ChildMode childMode;
+ mutable bool transitionsListNeedsRefresh;
+ mutable QList<QAbstractTransition*> transitionsList;
QList<QPropertyAssignment> propertyAssignments;
};
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index edd2d7c..2685b86 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1228,7 +1228,7 @@ void QGraphicsItemCache::purge()
}
/*!
- Constructs a QGraphicsItem, passing \a item to QGraphicsItem's constructor.
+ Constructs a QGraphicsItem with the given \a parent item.
It does not modify the parent object returned by QObject::parent().
If \a parent is 0, you can add the item to a scene by calling
diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp
index 93dc196..e2a3f08 100644
--- a/src/gui/graphicsview/qgraphicstransform.cpp
+++ b/src/gui/graphicsview/qgraphicstransform.cpp
@@ -69,6 +69,9 @@
objects are applied to a QGraphicsItem, all of the transformations
are computed in true 3D space, with the projection back to 2D
only occurring after the last QGraphicsTransform is applied.
+ The exception to this is QGraphicsRotation, which projects back to
+ 2D after each rotation to preserve the perspective effect around
+ the X and Y axes.
If you want to create your own configurable transformation, you can create
a subclass of QGraphicsTransform (or any or the existing subclasses), and
diff --git a/src/gui/kernel/qdesktopwidget.cpp b/src/gui/kernel/qdesktopwidget.cpp
index b1e1008..c6d5000 100644
--- a/src/gui/kernel/qdesktopwidget.cpp
+++ b/src/gui/kernel/qdesktopwidget.cpp
@@ -40,12 +40,11 @@
****************************************************************************/
#include "qglobal.h"
-
-QT_BEGIN_NAMESPACE
-
#include "qdesktopwidget.h"
#include "qwidget_p.h"
+QT_BEGIN_NAMESPACE
+
const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const
{
QRect rect = QWidgetPrivate::screenGeometry(widget);
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index 6ec5796..32fde62 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -98,6 +98,7 @@ Ptr_gtk_check_menu_item_new QGtk::gtk_check_menu_item_new = 0;
Ptr_gtk_menu_bar_new QGtk::gtk_menu_bar_new = 0;
Ptr_gtk_menu_new QGtk::gtk_menu_new = 0;
Ptr_gtk_button_new QGtk::gtk_button_new = 0;
+Ptr_gtk_tool_button_new QGtk::gtk_tool_button_new = 0;
Ptr_gtk_hbutton_box_new QGtk::gtk_hbutton_box_new = 0;
Ptr_gtk_check_button_new QGtk::gtk_check_button_new = 0;
Ptr_gtk_radio_button_new QGtk::gtk_radio_button_new = 0;
@@ -266,6 +267,7 @@ static void resolveGtk()
QGtk::gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new");
QGtk::gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert");
QGtk::gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new");
+ QGtk::gtk_tool_button_new = (Ptr_gtk_tool_button_new)libgtk.resolve("gtk_tool_button_new");
QGtk::gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new");
QGtk::gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new");
QGtk::gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new");
@@ -717,6 +719,7 @@ void QGtk::initGtkWidgets()
GtkWidget *gtkButton = QGtk::gtk_button_new();
add_widget(gtkButton);
g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), NULL);
+ add_widget(QGtk::gtk_tool_button_new(NULL, NULL));
add_widget(QGtk::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE));
add_widget(QGtk::gtk_hbutton_box_new());
add_widget(QGtk::gtk_check_button_new());
diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h
index 313d948..2cf21ce 100644
--- a/src/gui/styles/gtksymbols_p.h
+++ b/src/gui/styles/gtksymbols_p.h
@@ -96,6 +96,7 @@ typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void);
typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int);
typedef GtkWidget* (*Ptr_gtk_button_new)(void);
+typedef GtkWidget* (*Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *);
typedef GtkWidget* (*Ptr_gtk_hbutton_box_new)(void);
typedef GtkWidget* (*Ptr_gtk_check_button_new)(void);
typedef GtkWidget* (*Ptr_gtk_radio_button_new)(GSList *);
@@ -261,6 +262,7 @@ public:
static Ptr_gtk_menu_new gtk_menu_new;
static Ptr_gtk_expander_new gtk_expander_new;
static Ptr_gtk_button_new gtk_button_new;
+ static Ptr_gtk_tool_button_new gtk_tool_button_new;
static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new;
static Ptr_gtk_check_button_new gtk_check_button_new;
static Ptr_gtk_radio_button_new gtk_radio_button_new;
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 414580e..d315c98 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -1035,15 +1035,24 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
}
break;
- case PE_PanelButtonCommand: {
+ case PE_PanelButtonCommand:
+ case PE_PanelButtonTool: {
bool isDefault = false;
+ bool isTool = (element == PE_PanelButtonTool);
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option))
isDefault = btn->features & QStyleOptionButton::DefaultButton;
+ // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on
+ if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise))
+ break;
+ // don't draw a frame for dock widget buttons, unless we are hovering
+ if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver))
+ break;
+
GtkStateType state = gtkPainter.gtkState(option);
if (option->state & State_On || option->state & State_Sunken)
state = GTK_STATE_ACTIVE;
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = QGtk::gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton"));
gint focusWidth, focusPad;
gboolean interiorFocus = false;
QGtk::gtk_widget_style_get (gtkButton,
@@ -1555,7 +1564,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QStyleOptionToolButton label = *toolbutton;
label.state = bflags;
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkToolButton.GtkButton"));
QPalette pal = toolbutton->palette;
if (option->state & State_Enabled &&
option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) {
@@ -1931,13 +1940,26 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (!QGtk::gtk_check_version(2, 10, 0))
QGtk::gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL);
- if (trough_side_details && horizontal) { //### Vertical sliders look broken with this for some reason
+ if (!trough_side_details) {
+ gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,
+ GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
+ } else {
+ QRect upperGroove = grooveRect;
QRect lowerGroove = grooveRect;
- lowerGroove.setRight(handle.center().x());
+
+ if (horizontal) {
+ upperGroove.setLeft(handle.center().x());
+ lowerGroove.setRight(handle.center().x());
+ } else {
+ upperGroove.setBottom(handle.center().y());
+ lowerGroove.setTop(handle.center().y());
+ }
+
+ gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state,
+ GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state,
GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
}
-
}
if (option->subControls & SC_SliderTickmarks) {
@@ -3116,7 +3138,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_ToolButton:
if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkToolButton.GtkButton"));
newSize = size + QSize(2 * gtkButton->style->xthickness, 1 + 2 * gtkButton->style->ythickness);
if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
QSize minSize(0, 25);
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index e7f8401..8de821b 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -194,82 +194,82 @@ void QNativeSocketEnginePrivate::setError(QAbstractSocket::SocketError error, Er
switch (errorString) {
case NonBlockingInitFailedErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Unable to initialize non-blocking socket"));
+ socketErrorString = QNativeSocketEngine::tr("Unable to initialize non-blocking socket");
break;
case BroadcastingInitFailedErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Unable to initialize broadcast socket"));
+ socketErrorString = QNativeSocketEngine::tr("Unable to initialize broadcast socket");
break;
case NoIpV6ErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Attempt to use IPv6 socket on a platform with no IPv6 support"));
+ socketErrorString = QNativeSocketEngine::tr("Attempt to use IPv6 socket on a platform with no IPv6 support");
break;
case RemoteHostClosedErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "The remote host closed the connection"));
+ socketErrorString = QNativeSocketEngine::tr("The remote host closed the connection");
break;
case TimeOutErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Network operation timed out"));
+ socketErrorString = QNativeSocketEngine::tr("Network operation timed out");
break;
case ResourceErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Out of resources"));
+ socketErrorString = QNativeSocketEngine::tr("Out of resources");
break;
case OperationUnsupportedErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Unsupported socket operation"));
+ socketErrorString = QNativeSocketEngine::tr("Unsupported socket operation");
break;
case ProtocolUnsupportedErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Protocol type not supported"));
+ socketErrorString = QNativeSocketEngine::tr("Protocol type not supported");
break;
case InvalidSocketErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Invalid socket descriptor"));
+ socketErrorString = QNativeSocketEngine::tr("Invalid socket descriptor");
break;
case HostUnreachableErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Host unreachable"));
+ socketErrorString = QNativeSocketEngine::tr("Host unreachable");
break;
case NetworkUnreachableErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Network unreachable"));
+ socketErrorString = QNativeSocketEngine::tr("Network unreachable");
break;
case AccessErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Permission denied"));
+ socketErrorString = QNativeSocketEngine::tr("Permission denied");
break;
case ConnectionTimeOutErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Connection timed out"));
+ socketErrorString = QNativeSocketEngine::tr("Connection timed out");
break;
case ConnectionRefusedErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Connection refused"));
+ socketErrorString = QNativeSocketEngine::tr("Connection refused");
break;
case AddressInuseErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "The bound address is already in use"));
+ socketErrorString = QNativeSocketEngine::tr("The bound address is already in use");
break;
case AddressNotAvailableErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "The address is not available"));
+ socketErrorString = QNativeSocketEngine::tr("The address is not available");
break;
case AddressProtectedErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "The address is protected"));
+ socketErrorString = QNativeSocketEngine::tr("The address is protected");
break;
case DatagramTooLargeErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Datagram was too large to send"));
+ socketErrorString = QNativeSocketEngine::tr("Datagram was too large to send");
break;
case SendDatagramErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Unable to send a message"));
+ socketErrorString = QNativeSocketEngine::tr("Unable to send a message");
break;
case ReceiveDatagramErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Unable to receive a message"));
+ socketErrorString = QNativeSocketEngine::tr("Unable to receive a message");
break;
case WriteErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Unable to write"));
+ socketErrorString = QNativeSocketEngine::tr("Unable to write");
break;
case ReadErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Network error"));
+ socketErrorString = QNativeSocketEngine::tr("Network error");
break;
case PortInuseErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Another socket is already listening on the same port"));
+ socketErrorString = QNativeSocketEngine::tr("Another socket is already listening on the same port");
break;
case NotSocketErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Operation on non-socket"));
+ socketErrorString = QNativeSocketEngine::tr("Operation on non-socket");
break;
case InvalidProxyTypeString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "The proxy type is invalid for this operation"));
+ socketErrorString = QNativeSocketEngine::tr("The proxy type is invalid for this operation");
break;
case UnknownSocketErrorString:
- socketErrorString = QLatin1String(QT_TRANSLATE_NOOP("QNativeSocketEngine", "Unknown error"));
+ socketErrorString = QNativeSocketEngine::tr("Unknown error");
break;
}
}
diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp
index 62fcd4c..4bb58b1 100644
--- a/src/network/ssl/qsslerror.cpp
+++ b/src/network/ssl/qsslerror.cpp
@@ -91,6 +91,7 @@
*/
#include "qsslerror.h"
+#include "qsslsocket.h"
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
@@ -209,81 +210,79 @@ QString QSslError::errorString() const
QString errStr;
switch (d->error) {
case NoError:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "No error"));
+ errStr = QSslSocket::tr("No error");
break;
case UnableToGetIssuerCertificate:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The issuer certificate could not be found"));
+ errStr = QSslSocket::tr("The issuer certificate could not be found");
break;
case UnableToDecryptCertificateSignature:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate signature could not be decrypted"));
+ errStr = QSslSocket::tr("The certificate signature could not be decrypted");
break;
case UnableToDecodeIssuerPublicKey:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The public key in the certificate could not be read"));
+ errStr = QSslSocket::tr("The public key in the certificate could not be read");
break;
case CertificateSignatureFailed:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The signature of the certificate is invalid"));
+ errStr = QSslSocket::tr("The signature of the certificate is invalid");
break;
case CertificateNotYetValid:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate is not yet valid"));
+ errStr = QSslSocket::tr("The certificate is not yet valid");
break;
case CertificateExpired:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate has expired"));
+ errStr = QSslSocket::tr("The certificate has expired");
break;
case InvalidNotBeforeField:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate's notBefore field contains an invalid time"));
+ errStr = QSslSocket::tr("The certificate's notBefore field contains an invalid time");
break;
case InvalidNotAfterField:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate's notAfter field contains an invalid time"));
+ errStr = QSslSocket::tr("The certificate's notAfter field contains an invalid time");
break;
case SelfSignedCertificate:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate is self-signed, and untrusted"));
+ errStr = QSslSocket::tr("The certificate is self-signed, and untrusted");
break;
case SelfSignedCertificateInChain:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The root certificate of the certificate chain is self-signed, and untrusted"));
+ errStr = QSslSocket::tr("The root certificate of the certificate chain is self-signed, and untrusted");
break;
case UnableToGetLocalIssuerCertificate:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The issuer certificate of a locally looked up certificate could not be found"));
+ errStr = QSslSocket::tr("The issuer certificate of a locally looked up certificate could not be found");
break;
case UnableToVerifyFirstCertificate:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "No certificates could be verified"));
+ errStr = QSslSocket::tr("No certificates could be verified");
break;
case InvalidCaCertificate:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "One of the CA certificates is invalid"));
+ errStr = QSslSocket::tr("One of the CA certificates is invalid");
break;
case PathLengthExceeded:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The basicConstraints pathlength parameter has been exceeded"));
+ errStr = QSslSocket::tr("The basicConstraints pathlength parameter has been exceeded");
break;
case InvalidPurpose:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The supplied certificate is unsuited for this purpose"));
+ errStr = QSslSocket::tr("The supplied certificate is unsuited for this purpose");
break;
case CertificateUntrusted:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The root CA certificate is not trusted for this purpose"));
+ errStr = QSslSocket::tr("The root CA certificate is not trusted for this purpose");
break;
case CertificateRejected:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The root CA certificate is marked to reject the specified purpose"));
+ errStr = QSslSocket::tr("The root CA certificate is marked to reject the specified purpose");
break;
case SubjectIssuerMismatch: // hostname mismatch
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError,
- "The current candidate issuer certificate was rejected because its"
- " subject name did not match the issuer name of the current certificate"));
+ errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because its"
+ " subject name did not match the issuer name of the current certificate");
break;
case AuthorityIssuerSerialNumberMismatch:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The current candidate issuer certificate was rejected because"
- " its issuer name and serial number was present and did not match the"
- " authority key identifier of the current certificate"));
+ errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because"
+ " its issuer name and serial number was present and did not match the"
+ " authority key identifier of the current certificate");
break;
case NoPeerCertificate:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The peer did not present any certificate"));
+ errStr = QSslSocket::tr("The peer did not present any certificate");
break;
case HostNameMismatch:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError,
- "The host name did not match any of the valid hosts"
- " for this certificate"));
+ errStr = QSslSocket::tr("The host name did not match any of the valid hosts"
+ " for this certificate");
break;
case NoSslSupport:
break;
default:
- errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "Unknown error"));
+ errStr = QSslSocket::tr("Unknown error");
break;
}
diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
index a3c8266..ec05020 100644
--- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
+++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
@@ -42,6 +42,7 @@
#include "qtriangulatingstroker_p.h"
#include <qmath.h>
+QT_BEGIN_NAMESPACE
#define CURVE_FLATNESS Q_PI / 8
@@ -338,3 +339,6 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen)
m_dash_stroker.end();
}
+
+QT_END_NAMESPACE
+
diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h
index b7354db..483cea9 100644
--- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h
+++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h
@@ -48,6 +48,7 @@
#include <private/qnumeric_p.h>
#include <private/qmath_p.h>
+QT_BEGIN_NAMESPACE
class QTriangulatingStroker
{
@@ -295,5 +296,6 @@ void QTriangulatingStroker::join(const qreal *pts)
emitLineSegment(m_cx, m_cy, m_nvx, m_nvy);
}
+QT_END_NAMESPACE
#endif
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index d028522..90b496e 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -612,95 +612,6 @@ bool QGLShader::compileFile(const QString& fileName)
}
/*!
- Sets the binary code for this shader to the \a length bytes from
- the array \a binary. The \a format specifies how the binary data
- should be interpreted by the OpenGL engine. Returns true if the
- binary was set on the shader; false otherwise.
-
- This function cannot be used with PartialVertexShader or
- PartialFragmentShader.
-
- If this function succeeds, then the shader will be considered compiled.
-
- \sa shaderBinaryFormats()
-*/
-bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length)
-{
- Q_D(QGLShader);
-#if !defined(QT_OPENGL_ES_2)
- if (!glShaderBinary)
- return false;
-#endif
- GLuint shader = d->shaderGuard.id();
- if (d->isPartial || !shader)
- return false;
- glGetError(); // Clear error state.
- glShaderBinary(1, &shader, format, binary, length);
- d->compiled = (glGetError() == GL_NO_ERROR);
- return d->compiled;
-}
-
-/*!
- Sets the binary code for this shader to the \a length bytes from
- the array \a binary. The \a format specifies how the binary data
- should be interpreted by the OpenGL engine. Returns true if the
- binary was set on the shader; false otherwise.
-
- The \a otherShader will also have binary code set on it. This is
- for the case where \a binary contains both vertex and fragment
- shader code.
-
- This function cannot be used with PartialVertexShader or
- PartialFragmentShader.
-
- If this function succeeds, then the shader will be considered compiled.
-
- \sa shaderBinaryFormats()
-*/
-bool QGLShader::setShaderBinary
- (QGLShader& otherShader, GLenum format, const void *binary, int length)
-{
- Q_D(QGLShader);
-#if !defined(QT_OPENGL_ES_2)
- if (!glShaderBinary)
- return false;
-#endif
- if (d->isPartial || !d->shaderGuard.id())
- return false;
- if (otherShader.d_func()->isPartial || !otherShader.d_func()->shaderGuard.id())
- return false;
- glGetError(); // Clear error state.
- GLuint shaders[2];
- shaders[0] = d->shaderGuard.id();
- shaders[1] = otherShader.d_func()->shaderGuard.id();
- glShaderBinary(2, shaders, format, binary, length);
- d->compiled = (glGetError() == GL_NO_ERROR);
- otherShader.d_func()->compiled = d->compiled;
- return d->compiled;
-}
-
-/*!
- Returns a list of all binary formats that are supported by
- setShaderBinary() on this system.
-
- \sa setShaderBinary()
-*/
-QList<GLenum> QGLShader::shaderBinaryFormats()
-{
- GLint num;
- QList<GLenum> list;
- glGetError(); // Clear error state.
- glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &num);
- if (glGetError() != GL_NO_ERROR || num <= 0)
- return list;
- QVarLengthArray<GLint> formats(num);
- glGetIntegerv(GL_SHADER_BINARY_FORMATS, formats.data());
- for (GLint i = 0; i < num; ++i)
- list += (GLenum)(formats[i]);
- return list;
-}
-
-/*!
Returns the source code for this shader.
\sa compile()
@@ -1068,130 +979,6 @@ void QGLShaderProgram::removeAllShaders()
d->removingShaders = false;
}
-#if defined(QT_OPENGL_ES_2)
-
-#ifndef GL_PROGRAM_BINARY_LENGTH_OES
-#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
-#endif
-#ifndef GL_NUM_PROGRAM_BINARY_FORMATS_OES
-#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
-#endif
-#ifndef GL_PROGRAM_BINARY_FORMATS_OES
-#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
-#endif
-
-#endif
-
-/*!
- Returns the program binary associated with this shader program.
- The numeric identifier of the program binary format is returned
- in \a format. The \c OES_get_program_binary extension will need
- to be supported by the system for binary retrieval to succeed.
-
- Returns an empty QByteArray if the program binary cannot be
- retrieved on this system, or the shader program has not yet
- been linked.
-
- The returned binary can be supplied to setProgramBinary() on the
- same machine at some future point to reload the program. It contains
- the compiled code of all of the shaders that were attached to the
- program at the time programBinary() is called.
-
- \sa setProgramBinary(), programBinaryFormats()
-*/
-QByteArray QGLShaderProgram::programBinary(int *format) const
-{
-#if defined(QT_OPENGL_ES_2)
- Q_D(const QGLShaderProgram);
- if (!isLinked())
- return QByteArray();
-
- // Get the length of the binary data, bailing out if there is none.
- GLint length = 0;
- GLuint program = d->programGuard.id();
- glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH_OES, &length);
- if (length <= 0)
- return QByteArray();
-
- // Retrieve the binary data.
- QByteArray binary(length, 0);
- GLenum binaryFormat;
- glGetProgramBinaryOES(program, length, 0, &binaryFormat, binary.data());
- if (format)
- *format = (int)binaryFormat;
- return binary;
-#else
- Q_UNUSED(format);
- return QByteArray();
-#endif
-}
-
-/*!
- Sets the \a binary for this shader program according to \a format.
- Returns true if the binary was set, or false if the binary format
- is not supported or this system does not support program binaries.
- The program will be linked if the load succeeds.
-
- \sa programBinary(), programBinaryFormats(), isLinked()
-*/
-bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary)
-{
-#if defined(QT_OPENGL_ES_2)
- // Load the binary and check that it was linked correctly.
- Q_D(QGLShaderProgram);
- GLuint program = d->programGuard.id();
- if (!program)
- return false;
- glProgramBinaryOES(program, (GLenum)format,
- binary.constData(), binary.size());
- GLint value = 0;
- glGetProgramiv(program, GL_LINK_STATUS, &value);
- d->linked = (value != 0);
- value = 0;
- glGetProgramiv(program, GL_INFO_LOG_LENGTH, &value);
- d->log = QString();
- if (value > 1) {
- char *logbuf = new char [value];
- GLint len;
- glGetProgramInfoLog(program, value, &len, logbuf);
- d->log = QString::fromLatin1(logbuf);
- QString name = objectName();
- if (name.isEmpty())
- qWarning() << "QGLShader::setProgramBinary:" << d->log;
- else
- qWarning() << "QGLShader::setProgramBinary[" << name << "]:" << d->log;
- delete [] logbuf;
- }
- return d->linked;
-#else
- Q_UNUSED(format);
- Q_UNUSED(binary);
- return false;
-#endif
-}
-
-/*!
- Returns the list of program binary formats that are accepted by
- this system for use with setProgramBinary().
-
- \sa programBinary(), setProgramBinary()
-*/
-QList<int> QGLShaderProgram::programBinaryFormats()
-{
-#if defined(QT_OPENGL_ES_2)
- GLint count = 0;
- glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS_OES, &count);
- if (count <= 0)
- return QList<int>();
- QVector<int> list;
- list.resize(count);
- glGetIntegerv(GL_PROGRAM_BINARY_FORMATS_OES, list.data());
- return list.toList();
-#else
- return QList<int>();
-#endif
-}
-
/*!
Links together the shaders that were added to this program with
addShader(). Returns true if the link was successful or
diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h
index d8b9a0c..708cf09 100644
--- a/src/opengl/qglshaderprogram.h
+++ b/src/opengl/qglshaderprogram.h
@@ -88,11 +88,6 @@ public:
bool compile(const QString& source);
bool compileFile(const QString& fileName);
- bool setShaderBinary(GLenum format, const void *binary, int length);
- bool setShaderBinary(QGLShader& otherShader, GLenum format, const void *binary, int length);
-
- static QList<GLenum> shaderBinaryFormats();
-
QByteArray sourceCode() const;
bool isCompiled() const;
@@ -133,10 +128,6 @@ public:
void removeAllShaders();
- QByteArray programBinary(int *format) const;
- bool setProgramBinary(int format, const QByteArray& binary);
- static QList<int> programBinaryFormats();
-
virtual bool link();
bool isLinked() const;
QString log() const;
diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp
index 661e06a..f8486a6 100644
--- a/src/openvg/qwindowsurface_vg.cpp
+++ b/src/openvg/qwindowsurface_vg.cpp
@@ -54,8 +54,8 @@ QT_BEGIN_NAMESPACE
QVGWindowSurface::QVGWindowSurface(QWidget *window)
: QWindowSurface(window)
{
- d_ptr = QVGEGLWindowSurfacePrivate::create
- (QVGEGLWindowSurfacePrivate::WindowSurface, this);
+ // Create the default type of EGL window surface for windows.
+ d_ptr = new QVGEGLWindowSurfaceDirect(this);
}
QVGWindowSurface::QVGWindowSurface
diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp
index d622c1f..103f84d 100644
--- a/src/openvg/qwindowsurface_vgegl.cpp
+++ b/src/openvg/qwindowsurface_vgegl.cpp
@@ -101,18 +101,6 @@ QImage::Format qt_vg_config_to_image_format(QEglContext *context)
return argbFormat; // XXX
}
-static void copySubImage(QImage *image, VGImage vgImage, const QRect& rect)
-{
- vgGetImageSubData
- (vgImage,
- image->bits() + rect.bottom() * image->bytesPerLine() +
- rect.x() * (image->depth() / 8),
- -(image->bytesPerLine()),
- qt_vg_image_to_vg_format(image->format()),
- rect.x(), (image->height() - 1) - rect.bottom(),
- rect.width(), rect.height());
-}
-
#if !defined(QVG_NO_SINGLE_CONTEXT)
class QVGSharedContext
@@ -336,20 +324,6 @@ QVGEGLWindowSurfacePrivate::~QVGEGLWindowSurfacePrivate()
destroyPaintEngine();
}
-QVGEGLWindowSurfacePrivate *QVGEGLWindowSurfacePrivate::create
- (SurfaceType type, QWindowSurface *win)
-{
-#if defined(QVG_VGIMAGE_BACKBUFFERS)
- if (type == VGImageSurface)
- return new QVGEGLWindowSurfaceVGImage(win);
- else if (type == QImageSurface)
- return new QVGEGLWindowSurfaceQImage(win);
-#endif
- if (type == WindowSurface)
- return new QVGEGLWindowSurfaceDirect(win);
- return 0;
-}
-
QVGPaintEngine *QVGEGLWindowSurfacePrivate::paintEngine()
{
if (!engine)
@@ -514,39 +488,6 @@ EGLSurface QVGEGLWindowSurfaceVGImage::mainSurface() const
return qt_vg_shared_surface();
}
-QVGEGLWindowSurfaceQImage::QVGEGLWindowSurfaceQImage(QWindowSurface *win)
- : QVGEGLWindowSurfaceVGImage(win)
-{
-}
-
-QVGEGLWindowSurfaceQImage::~QVGEGLWindowSurfaceQImage()
-{
-}
-
-void QVGEGLWindowSurfaceQImage::endPaint
- (QWidget *widget, const QRegion& region, QImage *image)
-{
- QEglContext *context = ensureContext(widget);
- if (context) {
- if (backBufferSurface != EGL_NO_SURFACE) {
- if (isPaintingActive)
- vgFlush();
- context->makeCurrent(mainSurface());
- QRegion rgn = region.intersected
- (QRect(0, 0, image->width(), image->height()));
- if (rgn.numRects() == 1) {
- copySubImage(image, backBuffer, rgn.boundingRect());
- } else {
- QVector<QRect> rects = rgn.rects();
- for (int index = 0; index < rects.size(); ++index)
- copySubImage(image, backBuffer, rects[index]);
- }
- context->lazyDoneCurrent();
- }
- isPaintingActive = false;
- }
-}
-
#endif // QVG_VGIMAGE_BACKBUFFERS
QVGEGLWindowSurfaceDirect::QVGEGLWindowSurfaceDirect(QWindowSurface *win)
diff --git a/src/openvg/qwindowsurface_vgegl_p.h b/src/openvg/qwindowsurface_vgegl_p.h
index fa36b94..7fa60ea 100644
--- a/src/openvg/qwindowsurface_vgegl_p.h
+++ b/src/openvg/qwindowsurface_vgegl_p.h
@@ -70,16 +70,6 @@ public:
QVGEGLWindowSurfacePrivate(QWindowSurface *win);
virtual ~QVGEGLWindowSurfacePrivate();
- enum SurfaceType
- {
- WindowSurface,
- VGImageSurface,
- QImageSurface
- };
-
- static QVGEGLWindowSurfacePrivate *create
- (SurfaceType type, QWindowSurface *win);
-
QVGPaintEngine *paintEngine();
virtual QEglContext *ensureContext(QWidget *widget) = 0;
virtual void beginPaint(QWidget *widget) = 0;
@@ -126,15 +116,6 @@ protected:
EGLSurface mainSurface() const;
};
-class Q_OPENVG_EXPORT QVGEGLWindowSurfaceQImage : public QVGEGLWindowSurfaceVGImage
-{
-public:
- QVGEGLWindowSurfaceQImage(QWindowSurface *win);
- virtual ~QVGEGLWindowSurfaceQImage();
-
- void endPaint(QWidget *widget, const QRegion& region, QImage *image);
-};
-
#endif // EGL_OPENVG_IMAGE
class Q_OPENVG_EXPORT QVGEGLWindowSurfaceDirect : public QVGEGLWindowSurfacePrivate
diff --git a/src/script/api/api.pri b/src/script/api/api.pri
index 17ec9b6..aebadd5 100644
--- a/src/script/api/api.pri
+++ b/src/script/api/api.pri
@@ -6,6 +6,7 @@ SOURCES += \
$$PWD/qscriptengine.cpp \
$$PWD/qscriptengineagent.cpp \
$$PWD/qscriptextensionplugin.cpp \
+ $$PWD/qscriptprogram.cpp \
$$PWD/qscriptstring.cpp \
$$PWD/qscriptvalue.cpp \
$$PWD/qscriptvalueiterator.cpp \
@@ -23,6 +24,8 @@ HEADERS += \
$$PWD/qscriptengineagent_p.h \
$$PWD/qscriptextensioninterface.h \
$$PWD/qscriptextensionplugin.h \
+ $$PWD/qscriptprogram.h \
+ $$PWD/qscriptprogram_p.h \
$$PWD/qscriptstring.h \
$$PWD/qscriptstring_p.h \
$$PWD/qscriptvalue.h \
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 9288723..2b60a46 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -51,6 +51,8 @@
#include "qscriptvalue_p.h"
#include "qscriptvalueiterator.h"
#include "qscriptclass.h"
+#include "qscriptprogram.h"
+#include "qscriptprogram_p.h"
#include "qdebug.h"
#include <QtCore/qstringlist.h>
@@ -1155,6 +1157,73 @@ void QScriptEnginePrivate::agentDeleted(QScriptEngineAgent *agent)
}
}
+JSC::JSValue QScriptEnginePrivate::evaluateHelper(JSC::ExecState *exec, intptr_t sourceId,
+ JSC::EvalExecutable *executable,
+ bool &compile)
+{
+ Q_Q(QScriptEngine);
+ JSC::JSLock lock(false); // ### hmmm
+ QBoolBlocker inEvalBlocker(inEval, true);
+ q->currentContext()->activationObject(); //force the creation of a context for native function;
+
+ JSC::Debugger* debugger = originalGlobalObject()->debugger();
+ if (debugger)
+ debugger->evaluateStart(sourceId);
+
+ q->clearExceptions();
+ JSC::DynamicGlobalObjectScope dynamicGlobalObjectScope(exec, exec->scopeChain()->globalObject());
+
+ if (compile) {
+ JSC::JSObject* error = executable->compile(exec, exec->scopeChain());
+ if (error) {
+ compile = false;
+ exec->setException(error);
+
+ if (debugger) {
+ debugger->exceptionThrow(JSC::DebuggerCallFrame(exec, error), sourceId, false);
+ debugger->evaluateStop(error, sourceId);
+ }
+
+ return error;
+ }
+ }
+
+ JSC::JSValue thisValue = thisForContext(exec);
+ JSC::JSObject* thisObject = (!thisValue || thisValue.isUndefinedOrNull())
+ ? exec->dynamicGlobalObject() : thisValue.toObject(exec);
+ JSC::JSValue exceptionValue;
+ timeoutChecker()->setShouldAbort(false);
+ if (processEventsInterval > 0)
+ timeoutChecker()->reset();
+
+ JSC::JSValue result = exec->interpreter()->execute(executable, exec, thisObject, exec->scopeChain(), &exceptionValue);
+
+ if (timeoutChecker()->shouldAbort()) {
+ if (abortResult.isError())
+ exec->setException(scriptValueToJSCValue(abortResult));
+
+ if (debugger)
+ debugger->evaluateStop(scriptValueToJSCValue(abortResult), sourceId);
+
+ return scriptValueToJSCValue(abortResult);
+ }
+
+ if (exceptionValue) {
+ exec->setException(exceptionValue);
+
+ if (debugger)
+ debugger->evaluateStop(exceptionValue, sourceId);
+
+ return exceptionValue;
+ }
+
+ if (debugger)
+ debugger->evaluateStop(result, sourceId);
+
+ Q_ASSERT(!exec->hadException());
+ return result;
+}
+
#ifndef QT_NO_QOBJECT
JSC::JSValue QScriptEnginePrivate::newQObject(
@@ -2115,75 +2184,41 @@ QScriptSyntaxCheckResult QScriptEnginePrivate::checkSyntax(const QString &progra
QScriptValue QScriptEngine::evaluate(const QString &program, const QString &fileName, int lineNumber)
{
Q_D(QScriptEngine);
-
- JSC::JSLock lock(false); // ### hmmm
- QBoolBlocker inEval(d->inEval, true);
- currentContext()->activationObject(); //force the creation of a context for native function;
-
- JSC::Debugger* debugger = d->originalGlobalObject()->debugger();
-
- JSC::UString jscProgram = program;
- JSC::UString jscFileName = fileName;
- JSC::ExecState* exec = d->currentFrame;
WTF::PassRefPtr<QScript::UStringSourceProviderWithFeedback> provider
- = QScript::UStringSourceProviderWithFeedback::create(jscProgram, jscFileName, lineNumber, d);
+ = QScript::UStringSourceProviderWithFeedback::create(program, fileName, lineNumber, d);
intptr_t sourceId = provider->asID();
JSC::SourceCode source(provider, lineNumber); //after construction of SourceCode provider variable will be null.
- if (debugger)
- debugger->evaluateStart(sourceId);
-
- clearExceptions();
- JSC::DynamicGlobalObjectScope dynamicGlobalObjectScope(exec, exec->scopeChain()->globalObject());
-
+ JSC::ExecState* exec = d->currentFrame;
JSC::EvalExecutable executable(exec, source);
- JSC::JSObject* error = executable.compile(exec, exec->scopeChain());
- if (error) {
- exec->setException(error);
-
- if (debugger) {
- debugger->exceptionThrow(JSC::DebuggerCallFrame(exec, error), sourceId, false);
- debugger->evaluateStop(error, sourceId);
- }
-
- return d->scriptValueFromJSCValue(error);
- }
-
- JSC::JSValue thisValue = d->thisForContext(exec);
- JSC::JSObject* thisObject = (!thisValue || thisValue.isUndefinedOrNull()) ? exec->dynamicGlobalObject() : thisValue.toObject(exec);
- JSC::JSValue exceptionValue;
- d->timeoutChecker()->setShouldAbort(false);
- if (d->processEventsInterval > 0)
- d->timeoutChecker()->reset();
- JSC::JSValue result = exec->interpreter()->execute(&executable, exec, thisObject, exec->scopeChain(), &exceptionValue);
-
- if (d->timeoutChecker()->shouldAbort()) {
- if (d->abortResult.isError())
- exec->setException(d->scriptValueToJSCValue(d->abortResult));
-
- if (debugger)
- debugger->evaluateStop(d->scriptValueToJSCValue(d->abortResult), sourceId);
-
- return d->abortResult;
- }
-
- if (exceptionValue) {
- exec->setException(exceptionValue);
-
- if (debugger)
- debugger->evaluateStop(exceptionValue, sourceId);
+ bool compile = true;
+ return d->scriptValueFromJSCValue(d->evaluateHelper(exec, sourceId, &executable, compile));
+}
- return d->scriptValueFromJSCValue(exceptionValue);
- }
+/*!
+ \internal
+ \since 4.6
- if (debugger)
- debugger->evaluateStop(result, sourceId);
+ Evaluates the given \a program and returns the result of the
+ evaluation.
+*/
+QScriptValue QScriptEngine::evaluate(const QScriptProgram &program)
+{
+ Q_D(QScriptEngine);
+ QScriptProgramPrivate *program_d = QScriptProgramPrivate::get(program);
+ if (!program_d)
+ return QScriptValue();
- Q_ASSERT(!exec->hadException());
+ JSC::ExecState* exec = d->currentFrame;
+ JSC::EvalExecutable *executable = program_d->executable(exec, d);
+ bool compile = !program_d->isCompiled;
+ JSC::JSValue result = d->evaluateHelper(exec, program_d->sourceId,
+ executable, compile);
+ if (compile)
+ program_d->isCompiled = true;
return d->scriptValueFromJSCValue(result);
}
-
/*!
Returns the current context.
diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h
index 701f9c6..3f438da 100644
--- a/src/script/api/qscriptengine.h
+++ b/src/script/api/qscriptengine.h
@@ -67,6 +67,7 @@ class QDateTime;
class QScriptClass;
class QScriptEngineAgent;
class QScriptEnginePrivate;
+class QScriptProgram;
#ifndef QT_NO_QOBJECT
@@ -166,6 +167,8 @@ public:
QScriptValue evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
+ QScriptValue evaluate(const QScriptProgram &program);
+
bool isEvaluating() const;
void abortEvaluation(const QScriptValue &result = QScriptValue());
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index ec7c144..d12b0f4 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -70,6 +70,7 @@
namespace JSC
{
+ class EvalExecutable;
class ExecState;
typedef ExecState CallFrame;
class JSCell;
@@ -211,6 +212,10 @@ public:
const QByteArray &targetType,
void **result);
+ JSC::JSValue evaluateHelper(JSC::ExecState *exec, intptr_t sourceId,
+ JSC::EvalExecutable *executable,
+ bool &compile);
+
QScript::QObjectData *qobjectData(QObject *object);
void disposeQObject(QObject *object);
void emitSignalHandlerException();
diff --git a/src/script/api/qscriptprogram.cpp b/src/script/api/qscriptprogram.cpp
new file mode 100644
index 0000000..c30f381
--- /dev/null
+++ b/src/script/api/qscriptprogram.cpp
@@ -0,0 +1,225 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtScript module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the 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 "config.h"
+#include "qscriptprogram.h"
+#include "qscriptprogram_p.h"
+#include "qscriptengine.h"
+#include "qscriptengine_p.h"
+
+#include "Executable.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+
+ \since 4.6
+ \class QScriptProgram
+
+ \brief The QScriptProgram class encapsulates a Qt Script program.
+
+ \ingroup script
+
+ QScriptProgram retains the compiled representation of the script if
+ possible. Thus, QScriptProgram can be used to evaluate the same
+ script multiple times more efficiently.
+
+ \code
+ QScriptEngine engine;
+ QScriptProgram program("1 + 2");
+ QScriptValue result = engine.evaluate(program);
+ \endcode
+*/
+
+QScriptProgramPrivate::QScriptProgramPrivate(const QString &src,
+ const QString &fn,
+ int ln)
+ : sourceCode(src), fileName(fn), firstLineNumber(ln),
+ engine(0), _executable(0), sourceId(-1), isCompiled(false)
+{
+ ref = 0;
+}
+
+QScriptProgramPrivate::~QScriptProgramPrivate()
+{
+ delete _executable;
+}
+
+QScriptProgramPrivate *QScriptProgramPrivate::get(const QScriptProgram &q)
+{
+ return const_cast<QScriptProgramPrivate*>(q.d_func());
+}
+
+JSC::EvalExecutable *QScriptProgramPrivate::executable(JSC::ExecState *exec,
+ QScriptEnginePrivate *eng)
+{
+ if (_executable) {
+ if (eng == engine)
+ return _executable;
+ delete _executable;
+ }
+ WTF::PassRefPtr<QScript::UStringSourceProviderWithFeedback> provider
+ = QScript::UStringSourceProviderWithFeedback::create(sourceCode, fileName, firstLineNumber, eng);
+ sourceId = provider->asID();
+ JSC::SourceCode source(provider, firstLineNumber); //after construction of SourceCode provider variable will be null.
+ _executable = new JSC::EvalExecutable(exec, source);
+ engine = eng;
+ isCompiled = false;
+ return _executable;
+}
+
+/*!
+ Constructs a null QScriptProgram.
+*/
+QScriptProgram::QScriptProgram()
+ : d_ptr(0)
+{
+}
+
+/*!
+ Constructs a new QScriptProgram with the given \a sourceCode, \a
+ fileName and \a firstLineNumber.
+*/
+QScriptProgram::QScriptProgram(const QString &sourceCode,
+ const QString fileName,
+ int firstLineNumber)
+ : d_ptr(new QScriptProgramPrivate(sourceCode, fileName, firstLineNumber))
+{
+}
+
+/*!
+ Constructs a new QScriptProgram that is a copy of \a other.
+*/
+QScriptProgram::QScriptProgram(const QScriptProgram &other)
+ : d_ptr(other.d_ptr)
+{
+}
+
+/*!
+ Destroys this QScriptProgram.
+*/
+QScriptProgram::~QScriptProgram()
+{
+ Q_D(QScriptProgram);
+ // if (d->engine && (d->ref == 1))
+ // d->engine->unregisterScriptProgram(d);
+}
+
+/*!
+ Assigns the \a other value to this QScriptProgram.
+*/
+QScriptProgram &QScriptProgram::operator=(const QScriptProgram &other)
+{
+ // if (d_func() && d_func()->engine && (d_func()->ref == 1))
+ // d_func()->engine->unregisterScriptProgram(d_func());
+ // }
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns true if this QScriptProgram is null; otherwise
+ returns false.
+*/
+bool QScriptProgram::isNull() const
+{
+ Q_D(const QScriptProgram);
+ return (d == 0);
+}
+
+/*!
+ Returns the source code of this program.
+*/
+QString QScriptProgram::sourceCode() const
+{
+ Q_D(const QScriptProgram);
+ if (!d)
+ return QString();
+ return d->sourceCode;
+}
+
+/*!
+ Returns the filename associated with this program.
+*/
+QString QScriptProgram::fileName() const
+{
+ Q_D(const QScriptProgram);
+ if (!d)
+ return QString();
+ return d->fileName;
+}
+
+/*!
+ Returns the line number associated with this program.
+*/
+int QScriptProgram::firstLineNumber() const
+{
+ Q_D(const QScriptProgram);
+ if (!d)
+ return -1;
+ return d->firstLineNumber;
+}
+
+/*!
+ Returns true if this QScriptProgram is equal to \a other;
+ otherwise returns false.
+*/
+bool QScriptProgram::operator==(const QScriptProgram &other) const
+{
+ Q_D(const QScriptProgram);
+ if (d == other.d_func())
+ return true;
+ return (sourceCode() == other.sourceCode())
+ && (fileName() == other.fileName())
+ && (firstLineNumber() == other.firstLineNumber());
+}
+
+/*!
+ Returns true if this QScriptProgram is not equal to \a other;
+ otherwise returns false.
+*/
+bool QScriptProgram::operator!=(const QScriptProgram &other) const
+{
+ return !operator==(other);
+}
+
+QT_END_NAMESPACE
diff --git a/src/script/api/qscriptprogram.h b/src/script/api/qscriptprogram.h
new file mode 100644
index 0000000..de891cd
--- /dev/null
+++ b/src/script/api/qscriptprogram.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtScript module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the 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 QSCRIPTPROGRAM_H
+#define QSCRIPTPROGRAM_H
+
+#include <QtCore/qsharedpointer.h>
+
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Script)
+
+class QScriptProgramPrivate;
+class Q_SCRIPT_EXPORT QScriptProgram
+{
+public:
+ QScriptProgram();
+ QScriptProgram(const QString &sourceCode,
+ const QString fileName = QString(),
+ int firstLineNumber = 1);
+ QScriptProgram(const QScriptProgram &other);
+ ~QScriptProgram();
+
+ QScriptProgram &operator=(const QScriptProgram &other);
+
+ bool isNull() const;
+
+ QString sourceCode() const;
+ QString fileName() const;
+ int firstLineNumber() const;
+
+ bool operator==(const QScriptProgram &other) const;
+ bool operator!=(const QScriptProgram &other) const;
+
+private:
+ QExplicitlySharedDataPointer<QScriptProgramPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QScriptProgram)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSCRIPTPROGRAM_H
diff --git a/src/script/api/qscriptprogram_p.h b/src/script/api/qscriptprogram_p.h
new file mode 100644
index 0000000..5175079
--- /dev/null
+++ b/src/script/api/qscriptprogram_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtScript module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the 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 QSCRIPTPROGRAM_P_H
+#define QSCRIPTPROGRAM_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 <QtCore/qobjectdefs.h>
+
+namespace JSC
+{
+ class EvalExecutable;
+ class ExecState;
+}
+
+QT_BEGIN_NAMESPACE
+
+class QScriptEnginePrivate;
+
+class QScriptProgramPrivate
+{
+public:
+ QScriptProgramPrivate(const QString &sourceCode,
+ const QString &fileName,
+ int firstLineNumber);
+ ~QScriptProgramPrivate();
+
+ static QScriptProgramPrivate *get(const QScriptProgram &q);
+
+ JSC::EvalExecutable *executable(JSC::ExecState *exec,
+ QScriptEnginePrivate *engine);
+
+ QBasicAtomicInt ref;
+
+ QString sourceCode;
+ QString fileName;
+ int firstLineNumber;
+
+ QScriptEnginePrivate *engine;
+ JSC::EvalExecutable *_executable;
+ intptr_t sourceId;
+ bool isCompiled;
+};
+
+QT_END_NAMESPACE
+
+#endif