diff options
author | axis <qt-info@nokia.com> | 2009-10-29 08:20:38 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-10-29 08:20:38 (GMT) |
commit | eed04255446df8a749390e14cef7672c26329f6e (patch) | |
tree | 1b6cbd53bb0f90f27db3d4e36370bca024e4abad | |
parent | f360555f3c7ded3c729ce972fbd65f035876b1b4 (diff) | |
parent | f425c08d4f2e7f061a0ee8e4a1eee2b17fa64962 (diff) | |
download | Qt-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
41 files changed, 926 insertions, 626 deletions
@@ -2140,7 +2140,7 @@ if [ "$OPT_SHADOW" = "maybe" ]; then fi fi if [ "$OPT_SHADOW" = "yes" ]; then - if [ -f "$relpath/.qmake.cache" -o -f "$relpath/src/corelib/global/qconfig.h" ]; then + if [ -f "$relpath/.qmake.cache" -o -f "$relpath/src/corelib/global/qconfig.h" -o -f "$relpath/src/corelib/global/qconfig.cpp" ]; then echo >&2 "You cannot make a shadow build from a source tree containing a previous build." echo >&2 "Cannot proceed." exit 1 diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index d040d3d..6c53242 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -2341,6 +2341,11 @@ For example: of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \section1 QMAKE_LFLAGS_RPATH + + Library paths in this definition are added to the executable at link + time so that the added paths will be preferentially searched at runtime. + \section1 QMAKE_LFLAGS_QT_DLL This variable contains link flags when building programs that @@ -2667,6 +2672,16 @@ For example: \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 45 + \section1 QMAKE_RPATH + + Is equivalent to \l QMAKE_LFLAGS_RPATH. + + \section1 QMAKE_RPATHDIR + + A list of library directory paths, these paths are added to the + executable at link time so that the paths will be preferentially + searched at runtime. + \section1 QMAKE_RUN_CC This variable specifies the individual rule needed to build an object. diff --git a/doc/src/frameworks-technologies/eventsandfilters.qdoc b/doc/src/frameworks-technologies/eventsandfilters.qdoc index c769884..52d596a 100644 --- a/doc/src/frameworks-technologies/eventsandfilters.qdoc +++ b/doc/src/frameworks-technologies/eventsandfilters.qdoc @@ -215,7 +215,7 @@ \l{QCoreApplication::}{postEvent()} posts the event on a queue for later dispatch. The next time Qt's main event loop runs, it dispatches all posted events, with some optimization. For example, if there are - several resize events, they are are compressed into one. The same + several resize events, they are compressed into one. The same applies to paint events: QWidget::update() calls \l{QCoreApplication::}{postEvent()}, which eliminates flickering and increases speed by avoiding multiple repaints. diff --git a/mkspecs/unsupported/qnx-g++/qplatformdefs.h b/mkspecs/unsupported/qnx-g++/qplatformdefs.h index f309f81..1bf9ffcb 100644 --- a/mkspecs/unsupported/qnx-g++/qplatformdefs.h +++ b/mkspecs/unsupported/qnx-g++/qplatformdefs.h @@ -167,6 +167,6 @@ inline float strtof(const char *b, char **e) return float(strtod(b, e)); } -#define QT_QWS_TEMP_DIR qgetenv("TMP"); +#define QT_QWS_TEMP_DIR QString::fromLatin1(qgetenv("TMP")) #endif // QPLATFORMDEFS_H diff --git a/mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf b/mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf index 3f24cd9..fffb80f 100644 --- a/mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf +++ b/mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf @@ -56,10 +56,10 @@ QMAKE_PCH_OUTPUT_EXT = .gch QMAKE_LFLAGS_BSYMBOLIC_FUNC = -Wl,-Bsymbolic-functions QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list, -include(../../common/unix.conf) +include(../../../common/unix.conf) QMAKE_CFLAGS_THREAD = -D_REENTRANT -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CLFAGS_THREAD +QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD QMAKE_INCDIR = QMAKE_LIBDIR = 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 diff --git a/tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp index 002aeb7..dedc0cb 100644 --- a/tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp +++ b/tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp @@ -379,7 +379,7 @@ void tst_QDataWidgetMapper::comboBox() model->setData(model->index(0, 1), QString("read write item z"), Qt::EditRole); QCOMPARE(readOnlyBox.currentIndex(), 2); - QEXPECT_FAIL("", "See tasks 125493 and 147153", Abort); + QEXPECT_FAIL("", "See task 125493 and QTBUG-428", Abort); QCOMPARE(readWriteBox.currentText(), QString("read write item z")); } diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index dc08d0e..9b5e114 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -3735,7 +3735,7 @@ void tst_QGraphicsView::task259503_scrollingArtifacts() { // qDebug() << event->region(); // qDebug() << updateRegion; - QEXPECT_FAIL("", "The event region doesn't include the original item position region. See task #259503.", Continue); + QEXPECT_FAIL("", "The event region doesn't include the original item position region. See QTBUG-4416", Continue); QCOMPARE(event->region(), updateRegion); } } diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 25ee00f..804534f 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -44,6 +44,7 @@ #include <qscriptengine.h> #include <qscriptengineagent.h> +#include <qscriptprogram.h> #include <qscriptvalueiterator.h> #include <qgraphicsitem.h> #include <qstandarditemmodel.h> @@ -52,6 +53,7 @@ Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QObjectList) +Q_DECLARE_METATYPE(QScriptProgram) //TESTED_CLASS= //TESTED_FILES= @@ -151,6 +153,7 @@ private slots: void installTranslatorFunctions(); void functionScopes(); void nativeFunctionScopes(); + void evaluateProgram(); void qRegExpInport_data(); void qRegExpInport(); @@ -4289,6 +4292,152 @@ void tst_QScriptEngine::nativeFunctionScopes() } } +static QScriptValue createProgram(QScriptContext *ctx, QScriptEngine *eng) +{ + QString code = ctx->argument(0).toString(); + QScriptProgram result(code); + return qScriptValueFromValue(eng, result); +} + +void tst_QScriptEngine::evaluateProgram() +{ + QScriptEngine eng; + + { + QString code("1 + 2"); + QString fileName("hello.js"); + int lineNumber(123); + QScriptProgram program(code, fileName, lineNumber); + QVERIFY(!program.isNull()); + QCOMPARE(program.sourceCode(), code); + QCOMPARE(program.fileName(), fileName); + QCOMPARE(program.firstLineNumber(), lineNumber); + + QScriptValue expected = eng.evaluate(code); + for (int x = 0; x < 10; ++x) { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.equals(expected)); + } + + // operator= + QScriptProgram sameProgram = program; + QVERIFY(sameProgram == program); + QVERIFY(eng.evaluate(sameProgram).equals(expected)); + + // copy constructor + QScriptProgram sameProgram2(program); + QVERIFY(sameProgram2 == program); + QVERIFY(eng.evaluate(sameProgram2).equals(expected)); + + QScriptProgram differentProgram("2 + 3"); + QVERIFY(differentProgram != program); + QVERIFY(!eng.evaluate(differentProgram).equals(expected)); + } + + // Program that accesses variable in the scope + { + QScriptProgram program("a"); + QVERIFY(!program.isNull()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: a")); + } + + QScriptValue obj = eng.newObject(); + obj.setProperty("a", 123); + QScriptContext *ctx = eng.currentContext(); + ctx->pushScope(obj); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.equals(obj.property("a"))); + } + + obj.setProperty("a", QScriptValue()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + } + + QScriptValue obj2 = eng.newObject(); + obj2.setProperty("a", 456); + ctx->pushScope(obj2); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.equals(obj2.property("a"))); + } + + ctx->popScope(); + } + + // Program that creates closure + { + QScriptProgram program("(function() { var count = 0; return function() { return count++; }; })"); + QVERIFY(!program.isNull()); + QScriptValue createCounter = eng.evaluate(program); + QVERIFY(createCounter.isFunction()); + QScriptValue counter = createCounter.call(); + QVERIFY(counter.isFunction()); + { + QScriptValue ret = counter.call(); + QVERIFY(ret.isNumber()); + } + QScriptValue counter2 = createCounter.call(); + QVERIFY(counter2.isFunction()); + QVERIFY(!counter2.equals(counter)); + { + QScriptValue ret = counter2.call(); + QVERIFY(ret.isNumber()); + } + } + + // Program created in a function call, then executed later + { + QScriptValue fun = eng.newFunction(createProgram); + QScriptProgram program = qscriptvalue_cast<QScriptProgram>( + fun.call(QScriptValue(), QScriptValueList() << "a + 1")); + QVERIFY(!program.isNull()); + eng.globalObject().setProperty("a", QScriptValue()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: a")); + } + eng.globalObject().setProperty("a", 122); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 123); + } + } + + // Same program run in different engines + { + QString code("1 + 2"); + QScriptProgram program(code); + QVERIFY(!program.isNull()); + double expected = eng.evaluate(program).toNumber(); + for (int x = 0; x < 2; ++x) { + QScriptEngine eng2; + for (int y = 0; y < 2; ++y) { + double ret = eng2.evaluate(program).toNumber(); + QCOMPARE(ret, expected); + } + } + } + + // No program + { + QScriptProgram program; + QVERIFY(program.isNull()); + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isValid()); + } +} + static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; } void tst_QScriptEngine::qRegExpInport_data() diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 82c8ccd..032c34b 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -44,6 +44,7 @@ #include <QtScript/qscriptengineagent.h> #include <QtScript/qscriptengine.h> +#include <QtScript/qscriptprogram.h> #include <qscriptvalueiterator.h> //TESTED_CLASS= @@ -110,6 +111,9 @@ private slots: void extension(); void isEvaluatingInExtension(); void hasUncaughtException(); + void evaluateProgram(); + void evaluateProgram_SyntaxError(); + void evaluateNullProgram(); private: double m_testProperty; @@ -2219,6 +2223,88 @@ void tst_QScriptEngineAgent::hasUncaughtException() QVERIFY2(spy->isPass(), "At least one of a functionExit event should set hasUncaughtException flag."); } +void tst_QScriptEngineAgent::evaluateProgram() +{ + QScriptEngine eng; + QScriptProgram program("1 + 2", "foo.js", 123); + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); + qint64 scriptId = -1; + for (int x = 0; x < 10; ++x) { + spy->clear(); + (void)eng.evaluate(program); + QCOMPARE(spy->count(), (x == 0) ? 4 : 3); + + if (x == 0) { + // script is only loaded on first execution + QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); + scriptId = spy->at(0).scriptId; + QVERIFY(scriptId != -1); + QCOMPARE(spy->at(0).script, program.sourceCode()); + QCOMPARE(spy->at(0).fileName, program.fileName()); + QCOMPARE(spy->at(0).lineNumber, program.firstLineNumber()); + spy->removeFirst(); + } + + QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); // evaluate() + QCOMPARE(spy->at(0).scriptId, scriptId); + + QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); + QCOMPARE(spy->at(1).scriptId, scriptId); + QCOMPARE(spy->at(1).lineNumber, program.firstLineNumber()); + + QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionExit); // evaluate() + QCOMPARE(spy->at(2).scriptId, scriptId); + QVERIFY(spy->at(2).value.isNumber()); + QCOMPARE(spy->at(2).value.toNumber(), qsreal(3)); + } +} + +void tst_QScriptEngineAgent::evaluateProgram_SyntaxError() +{ + QScriptEngine eng; + QScriptProgram program("this is not valid syntax", "foo.js", 123); + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); + qint64 scriptId = -1; + for (int x = 0; x < 10; ++x) { + spy->clear(); + (void)eng.evaluate(program); + QCOMPARE(spy->count(), (x == 0) ? 8 : 7); + + if (x == 0) { + // script is only loaded on first execution + QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); + scriptId = spy->at(0).scriptId; + QVERIFY(scriptId != -1); + QCOMPARE(spy->at(0).script, program.sourceCode()); + QCOMPARE(spy->at(0).fileName, program.fileName()); + QCOMPARE(spy->at(0).lineNumber, program.firstLineNumber()); + spy->removeFirst(); + } + + QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); // evaluate() + QCOMPARE(spy->at(0).scriptId, scriptId); + + QCOMPARE(spy->at(1).type, ScriptEngineEvent::ContextPush); // SyntaxError constructor + QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionEntry); // SyntaxError constructor + QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); // SyntaxError constructor + QCOMPARE(spy->at(4).type, ScriptEngineEvent::ContextPop); // SyntaxError constructor + + QCOMPARE(spy->at(5).type, ScriptEngineEvent::ExceptionThrow); + QVERIFY(spy->at(5).value.isError()); + QCOMPARE(spy->at(5).value.toString(), QString::fromLatin1("SyntaxError: Parse error")); + + QCOMPARE(spy->at(6).type, ScriptEngineEvent::FunctionExit); // evaluate() + QCOMPARE(spy->at(6).scriptId, scriptId); + } +} + +void tst_QScriptEngineAgent::evaluateNullProgram() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); + (void)eng.evaluate(QScriptProgram()); + QCOMPARE(spy->count(), 0); +} QTEST_MAIN(tst_QScriptEngineAgent) #include "tst_qscriptengineagent.moc" diff --git a/tests/auto/qsound/tst_qsound.cpp b/tests/auto/qsound/tst_qsound.cpp index fdbf6a2..56a330b 100644 --- a/tests/auto/qsound/tst_qsound.cpp +++ b/tests/auto/qsound/tst_qsound.cpp @@ -66,7 +66,7 @@ void tst_QSound::checkFinished() QTest::qWait(5000); #if defined(Q_WS_QWS) - QEXPECT_FAIL("", "QSound buggy on embedded (task 122221)", Abort); + QEXPECT_FAIL("", "QSound buggy on embedded (task QTBUG-157)", Abort); #endif QVERIFY(sound.isFinished() ); } diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 050d1c5..5630370 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -2982,7 +2982,7 @@ void tst_QWidget::stackUnder() qApp->processEvents(); #endif #ifndef Q_WS_MAC - QEXPECT_FAIL(0, "Task 153869", Continue); + QEXPECT_FAIL(0, "See QTBUG-493", Continue); #endif QCOMPARE(child->numPaintEvents, 0); } else { diff --git a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp index 4f011c4..8d5f6e6 100644 --- a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp +++ b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp @@ -60,6 +60,8 @@ private slots: void constructor(); void evaluate_data(); void evaluate(); + void evaluateProgram_data(); + void evaluateProgram(); void connectAndDisconnect(); void newObject(); void newQObject(); @@ -153,6 +155,22 @@ void tst_QScriptEngine::connectAndDisconnect() } } +void tst_QScriptEngine::evaluateProgram_data() +{ + evaluate_data(); +} + +void tst_QScriptEngine::evaluateProgram() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptProgram program(code); + + QBENCHMARK { + (void)engine.evaluate(program); + } +} + void tst_QScriptEngine::newObject() { QScriptEngine engine; @@ -241,6 +259,5 @@ void tst_QScriptEngine::nativeCall() } } - QTEST_MAIN(tst_QScriptEngine) #include "tst_qscriptengine.moc" diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 7a616e3..6374912 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1899,25 +1899,25 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions) case Tok_Comment: if (!tor) goto case_default; - if (yyWord.startsWith(QLatin1Char(':'))) { - yyWord.remove(0, 1); + if (yyWord.at(0) == QLatin1Char(':') && yyWord.at(1).isSpace()) { + yyWord.remove(0, 2); extracomment += yyWord; extracomment.detach(); - } else if (yyWord.startsWith(QLatin1Char('='))) { - yyWord.remove(0, 1); + } else if (yyWord.at(0) == QLatin1Char('=') && yyWord.at(1).isSpace()) { + yyWord.remove(0, 2); msgid = yyWord.simplified(); msgid.detach(); - } else if (yyWord.startsWith(QLatin1Char('~'))) { - yyWord.remove(0, 1); + } else if (yyWord.at(0) == QLatin1Char('~') && yyWord.at(1).isSpace()) { + yyWord.remove(0, 2); text = yyWord.trimmed(); int k = text.indexOf(QLatin1Char(' ')); if (k > -1) extra.insert(text.left(k), text.mid(k + 1).trimmed()); text.clear(); - } else if (yyWord.startsWith(QLatin1Char('%'))) { - sourcetext.reserve(sourcetext.length() + yyWord.length()); + } else if (yyWord.at(0) == QLatin1Char('%') && yyWord.at(1).isSpace()) { + sourcetext.reserve(sourcetext.length() + yyWord.length() - 2); ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length(); - int p = 1, c; + int p = 2, c; forever { if (p >= yyWord.length()) break; diff --git a/tools/qdoc3/test/qt-inc.qdocconf b/tools/qdoc3/test/qt-inc.qdocconf deleted file mode 100644 index 2ff5682..0000000 --- a/tools/qdoc3/test/qt-inc.qdocconf +++ /dev/null @@ -1,149 +0,0 @@ -include(compat.qdocconf) -include(macros.qdocconf) - -project = Qt -description = Qt Reference Documentation -url = http://qt.nokia.com/doc/4.6 - -edition.Desktop = QtCore QtGui QtNetwork QtOpenGL QtSql QtSvg QtXml QtScript \ - QtDesigner QtAssistant Qt3Support QAxContainer \ - QAxServer QtUiTools QtTest QtDBus -edition.DesktopLight = QtCore QtGui Qt3SupportLight QtTest - -language = Cpp - -norecursion = true -sources.fileextensions = "*.cpp *.qdoc" -sourcedirs = $QDOC_CURRENT_DIR -headerdirs = $QDOC_CURRENT_DIR -exampledirs = $QTDIR/doc/src \ - $QTDIR/examples \ - $QTDIR \ - $QTDIR/qmake/examples \ - $QTDIR/src/3rdparty/webkit/WebKit/qt/docs -imagedirs = $QTDIR/doc/src/images \ - $QTDIR/examples -outputdir = $QTDIR/doc/html -indexdir = $QTDIR/doc/indexes -indexes = $QDOC_INPUT_INDEXES -outputindex = $QDOC_OUTPUT_INDEX -base = file:$QTDIR/doc/html -versionsym = QT_VERSION_STR -defines = Q_QDOC \ - QT_.*_SUPPORT \ - QT_.*_LIB \ - QT_COMPAT \ - QT_KEYPAD_NAVIGATION \ - QT3_SUPPORT \ - Q_WS_.* \ - Q_OS_.* \ - Q_BYTE_ORDER \ - __cplusplus - -codeindent = 1 -extraimages.HTML = qt-logo \ - trolltech-logo - -Cpp.ignoretokens = QAXFACTORY_EXPORT \ - QDESIGNER_COMPONENTS_LIBRARY \ - QDESIGNER_EXTENSION_LIBRARY \ - QDESIGNER_SDK_LIBRARY \ - QDESIGNER_SHARED_LIBRARY \ - QDESIGNER_UILIB_LIBRARY \ - QM_EXPORT_CANVAS \ - QM_EXPORT_DNS \ - QM_EXPORT_DOM \ - QM_EXPORT_FTP \ - QM_EXPORT_HTTP \ - QM_EXPORT_ICONVIEW \ - QM_EXPORT_NETWORK \ - QM_EXPORT_OPENGL \ - QM_EXPORT_SQL \ - QM_EXPORT_TABLE \ - QM_EXPORT_WORKSPACE \ - QM_EXPORT_XML \ - QT_ASCII_CAST_WARN \ - QT_BEGIN_HEADER \ - QT_DESIGNER_STATIC \ - QT_END_HEADER \ - QT_WIDGET_PLUGIN_EXPORT \ - Q_COMPAT_EXPORT \ - Q_CORE_EXPORT \ - Q_EXPLICIT \ - Q_EXPORT \ - Q_EXPORT_CODECS_CN \ - Q_EXPORT_CODECS_JP \ - Q_EXPORT_CODECS_KR \ - Q_EXPORT_PLUGIN \ - Q_GFX_INLINE \ - Q_GUI_EXPORT \ - Q_GUI_EXPORT_INLINE \ - Q_GUI_EXPORT_STYLE_CDE \ - Q_GUI_EXPORT_STYLE_COMPACT \ - Q_GUI_EXPORT_STYLE_MAC \ - Q_GUI_EXPORT_STYLE_MOTIF \ - Q_GUI_EXPORT_STYLE_MOTIFPLUS \ - Q_GUI_EXPORT_STYLE_PLATINUM \ - Q_GUI_EXPORT_STYLE_POCKETPC \ - Q_GUI_EXPORT_STYLE_SGI \ - Q_GUI_EXPORT_STYLE_WINDOWS \ - Q_GUI_EXPORT_STYLE_WINDOWSXP \ - Q_INLINE_TEMPLATE \ - Q_NETWORK_EXPORT \ - Q_OPENGL_EXPORT \ - Q_OUTOFLINE_TEMPLATE \ - Q_SQL_EXPORT \ - Q_SVG_EXPORT \ - Q_SCRIPT_EXPORT \ - Q_TESTLIB_EXPORT \ - Q_TYPENAME \ - Q_XML_EXPORT \ - QDBUS_EXPORT \ - Q_GADGET \ - QWEBKIT_EXPORT -Cpp.ignoredirectives = Q_DECLARE_HANDLE \ - Q_DECLARE_INTERFACE \ - Q_DECLARE_METATYPE \ - Q_DECLARE_OPERATORS_FOR_FLAGS \ - Q_DECLARE_PRIVATE \ - Q_DECLARE_PUBLIC \ - Q_DECLARE_SHARED \ - Q_DECLARE_TR_FUNCTIONS \ - Q_DECLARE_TYPEINFO \ - Q_DISABLE_COPY \ - Q_DUMMY_COMPARISON_OPERATOR \ - Q_ENUMS \ - Q_FLAGS \ - Q_INTERFACES \ - Q_OS_SYMBIAN \ - __attribute__ - -HTML.stylesheets = $QTDIR/util/qdoc3/test/classic.css -HTML.postheader = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n" \ - "<tr>\n" \ - "<td align=\"left\" valign=\"top\" width=\"32\">" \ - "<a href=\"http://qt.nokia.com/\"><img src=\"images/qt-logo.png\" align=\"left\" width=\"32\" height=\"32\" border=\"0\" /></a>" \ - "</td>\n" \ - "<td width=\"1\"> </td>" \ - "<td class=\"postheader\" valign=\"center\">" \ - "<a href=\"index.html\">" \ - "<font color=\"#004faf\">Home</font></a> ·" \ - " <a href=\"classes.html\">" \ - "<font color=\"#004faf\">All Classes</font></a> ·" \ - " <a href=\"mainclasses.html\">" \ - "<font color=\"#004faf\">Main Classes</font></a> ·" \ - " <a href=\"groups.html\">" \ - "<font color=\"#004faf\">Grouped Classes</font></a> ·" \ - " <a href=\"modules.html\">" \ - "<font color=\"#004faf\">Modules</font></a> ·" \ - " <a href=\"functions.html\">" \ - "<font color=\"#004faf\">Functions</font></a>" \ - "</td>\n" \ - "<td align=\"right\" valign=\"top\" width=\"230\"><a href=\"http://qt.nokia.com\"><img src=\"images/trolltech-logo.png\" align=\"right\" width=\"203\" height=\"32\" border=\"0\" /></a></td></tr></table>" - -HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \ - "<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \ - "<td width=\"30%\" align=\"left\">Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ - "<td width=\"40%\" align=\"center\"><a href=\"trademarks.html\">Trademarks</a></td>\n" \ - "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt \\version</div></td>\n" \ - "</tr></table></div></address>" diff --git a/tools/qvfb/config.ui b/tools/qvfb/config.ui index ad9c39e..b74bef7 100644 --- a/tools/qvfb/config.ui +++ b/tools/qvfb/config.ui @@ -47,7 +47,7 @@ <x>0</x> <y>0</y> <width>600</width> - <height>665</height> + <height>690</height> </rect> </property> <property name="windowTitle"> @@ -118,6 +118,13 @@ </widget> </item> <item> + <widget class="QRadioButton" name="size_800_480"> + <property name="text"> + <string>800x480</string> + </property> + </widget> + </item> + <item> <widget class="QRadioButton" name="size_800_600"> <property name="text"> <string>800x600</string> diff --git a/tools/qvfb/qvfb.cpp b/tools/qvfb/qvfb.cpp index 59e8dae..09692b7 100644 --- a/tools/qvfb/qvfb.cpp +++ b/tools/qvfb/qvfb.cpp @@ -669,6 +669,8 @@ void QVFb::configure() w=320; h=240; } else if ( config->size_640_480->isChecked() ) { w=640; h=480; + } else if ( config->size_800_480->isChecked() ) { + w=800; h=480; } else if ( config->size_800_600->isChecked() ) { w=800; h=600; } else if ( config->size_1024_768->isChecked() ) { @@ -748,6 +750,7 @@ void QVFb::chooseSize(const QSize& sz) config->size_240_320->setChecked(sz == QSize(240,320)); config->size_320_240->setChecked(sz == QSize(320,240)); config->size_640_480->setChecked(sz == QSize(640,480)); + config->size_800_480->setChecked(sz == QSize(800,480)); config->size_800_600->setChecked(sz == QSize(800,600)); config->size_1024_768->setChecked(sz == QSize(1024,768)); } |