summaryrefslogtreecommitdiff
path: root/src/script/api/qscriptengine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix recursive calling of QScriptProgramv5.3.0-rc1v5.3.0-beta1v5.3.0release5.3.0Lars Knoll2014-03-111-1/+1
| | | | | | | | | | | | The first time a QScriptProgram is evaluated, it gets compiled and then executed. If the execution would somehow trigger another evaluation of the script program, it would run into the compile stage again (even though it already was compiled), and then trigger and assertion in debug mode (or leak memory in release builds). Task-number: QTBUG-37317 Change-Id: I83e7efd5f238d021e200258826e2e4a9520c3a7d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Doc: Adding "\inmodule QtScript" to Qt Script classes.Jerome Pasion2013-10-081-0/+2
| | | | | | | | -reduces QDoc warnings -lists the classes in the C++ pages Change-Id: I97db6b8bec4d44d1ee37ed2925ef7309cd0d420f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Remove QtAlgorithms usage from QtScript.Friedemann Kleint2013-09-261-2/+3
| | | | | | | | | QtAlgorithms is getting deprecated, see http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: If4dc8f69fd75315390a4850be732715064f5fdd8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Doc: Fix module name formatSze Howe Koh2013-01-261-26/+26
| | | | | | | | | | | Follow the conventions at http://qt-project.org/wiki/Spelling_Module_Names_in_Qt_Documentation QtScript -> Qt Script QtScriptTools -> Qt Script Tools Change-Id: Icf6b2ea3829247475f8902334b615f9a9206cc51 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-101-1/+1
| | | | | | Change-Id: Ic4a2739c8caf2eac95e4a72d8d38cfb912d5fe2b Reviewed-by: Akseli Salovaara <akseli.salovaara@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-241-2/+2
| | | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: Id0b72b8c895b0eab04a740bf83859c9b646dd911 Reviewed-by: Janne Anttila <janne.anttila@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Capture full backtrace when a native function calls back into JSKent Hansen2012-08-221-2/+10
| | | | | | | | | | | | | | | | | | | | | | Commit df0ec196031d33850324dc5eeed2d71f61413885 assumed that JSC's Interpreter::throwException function is called exactly once when an exception occurs. That's wrong. If there is a native call inbetween two JS calls on the stack, the call stack will be unwound to the point of the native call frame, and throwException will return. After the native (C) call frame has been unwound, throwException will be called again to unwind remaining JS call frames, and so on. This was causing QtScript to discard the backtrace belonging to the inner-most JS frames; the backtrace would be regenerated from a partially unwound state. Fix this by ignoring subsequent calls to the uncaughtException() callback once a backtrace has been captured; the backtrace is already cleared before each evaluation is started. Task-number: QTBUG-26889 Change-Id: I03e1d60fbac5e592cff1dd5ef70f397cf94454ae Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
* Remove the use of the QWidgetStar metatypeid.Stephen Kelly2012-08-151-9/+5
| | | | | | | | | | It is to be removed, and is obsoleted by QMetaType::PointerToQObject. By using QMetaType::PointerToQObject, we also gain the feature that all pointers to types derived from QObject return true for QScriptValue::isQObject(). Change-Id: I18392b5b6cde3a45d060c37612d987a5cf8e8f18 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Make QScriptEngine::uncaughtExceptionBacktrace() work againKent Hansen2012-08-151-14/+52
| | | | | | | | | | | This function has been broken since Qt 4.6 (when the JavaScriptCore- based back-end was introduced). Fix it by introducing a callback in JSC that allows us to capture the stack when an uncaught exception occurs. Task-number: QTBUG-6139 Change-Id: I4a829323c9fb0c8b2f16a2e5d6f0aeb13cc32561 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Add default conversion for types long and ulongKent Hansen2012-08-141-0/+22
| | | | | | | | | | | | | | Such conversion is not guaranteed to be lossless on all platforms, but it's still reasonable to support these types by default. JSC::JSValue already had constructors for them. The type matching / overload resolution in the QObject binding already handled long and ulong, but the value conversion itself was missing, for some reason. Task-number: QTBUG-2124 Change-Id: I14ff29a8e949403234b7659c0aca8b48bcdbda0e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix GC issues related to QObject connections and ownershipKent Hansen2012-08-091-8/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue 1: Even if a sender object was only weakly referenced, the connection's slot function would still get marked. If the slot was a closure, its scope could hold a reference to the sender object, so by marking the closure, the sender would get marked, too - even if there were no other references to the closure outside of the QObject connection structure. This would cause the sender object to stay alive, rather than being garbage-collected (i.e., it leaked). Issue 2: It's possible that a closure used as a slot in a connection for one QObject holds the only reference to another QObject that has connections of its own. In that case, if the first object is explicitly referenced, the second object (and its connections) should get marked. But depending on the order in which the connections were marked, the second object might get treated incorrectly. This commit solves both issues by introducing an iterative scheme for marking connections. The first pass marks only connections whose sender object is referenced elsewhere in the JS environment. The second pass marks connections whose sender object is referenced by slots of the connections marked in the first pass. And so on, until no more connections should be marked. At that point, any remaining unmarked connections are effectively dead (belonging to QObjects that can be reclaimed by the GC). Task-number: QTBUG-26590 Change-Id: I50aa66f7fe407a6827b6f2a12e027275a2fb4655 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
* QScriptEngine::pushContext(): Don't inherit parent context's scopeKent Hansen2012-08-081-7/+2
| | | | | | | | | | | | | | This was a regression introduced in Qt 4.6 (JavaScriptCore-based backend). pushContext() should always create a context with a "clean" scope (only the Global Object and the context's own activation object should be in the scope chain). The scope chain API is internal, but the wrong behavior could still be observed e.g. through QScriptEngine::evaluate(). Task-number: QTBUG-18188 Change-Id: I138dabc665d7275fb85d3b5e1b473d56096a989e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Ensure QObject wrappers are garbage-collected if appropriateKent Hansen2012-07-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Address the "###" comment. When QScriptEngine::newQObject() is called with the option PreferExistingWrapperObject, the resulting wrapper object is cached by the engine, in case it will be needed later (e.g., by a subsequent newQObject() call for the same QObject, with the same wrap options). But if a QObject wrapper object is only referenced by the QtScript internals (i.e., not reachable from the JSC stack/heap, or kept in a QScriptValue), the wrapper should not be kept alive if the ownership is ScriptOwnership, or if the ownership is AutoOwnership and the C++ object has no parent. If the wrapper is marked in that case, it won't get collected, and hence the C++ object will be kept alive, too. In practice, QtScript appears to leak memory (the objects will only be destroyed when the engine is destroyed). Our copy of JSC doesn't have a concept of weak references; the ClientData callback in the JSC markRoots() function (which causes QScriptEnginePrivate::mark() to be called) was moved to the end. This enables the wrapper and connection marking logic to determine whether a wrapper can be safely discarded (if it hasn't been marked by JSC by this point, it must be a weak reference). Task-number: QTBUG-21993 Change-Id: I61f6aafc91f080b80d3f5859148e645b80d9b653 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Doc: Modularize QtScript documentation.Casper van Donderen2012-06-051-28/+28
| | | | | Change-Id: I042d9bafe4f48a8cd23306f0864b6872776d0153 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Deprecate the Encoding argument of qsTranslateLars Knoll2012-05-211-19/+19
| | | | | | | | | | This is the same as change 4822a821facbbf834c6aab5a8a7da2b3e43f09f7 in qtdeclarative. We always assume the js source code is Utf8 encoded, as also on the C++ side. Change-Id: I4f49484241718dfc4a2bb39a674b54df46aa8c8d Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Simplify QVariant::convert and QVariant::canConvert calls.Jędrzej Nowacki2012-05-211-2/+2
| | | | | | | QVariant::Type casts are not necessary in Qt5. Change-Id: I43833e869379db8937839612dfb6162f878870cb Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Fix some deprecation warnings in QtScript.Friedemann Kleint2012-04-301-1/+3
| | | | | Change-Id: I98d4826fcc2e3687d45edfccca956891ca0466cf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add missing case in QScriptEnginePrivate::createJędrzej Nowacki2012-04-171-0/+1
| | | | | | | | | Currently QMetaType::UnknownType, instead of QMetaType::Void, is used to check if a type id is valid or not. Change-Id: Ib185e3f28ef675c57d9b8b0d2eb4e4f124999131 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Adapt qtscript to QMetaMethod::signature() renamingKent Hansen2012-04-171-6/+6
| | | | | | | | | | QMetaMethod::methodSignature() should be used instead, and it returns a QByteArray. Change-Id: I81150e238dab7eda26d0466ac407a4f3ba79a7c7 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Fix compilation, use DefaultCodec.Friedemann Kleint2012-03-061-1/+1
| | | | | Change-Id: I0d1036eb75de9fcd2663ec5476d3b13edb2e264e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Remove the usage of deprecated qdoc macros.Casper van Donderen2012-03-061-15/+15
| | | | | | | | | | QDoc now has support for Doxygen style commands for italics, bold and list items. This change applies that change in QDoc to the actual documentation. Task-number: QTBUG-24578 Change-Id: I7733d18ce1e3459ef618802060d176c9211d3d5f Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Fix link for QObject integration documentation in QScriptEngineTeemu Katajisto2012-02-211-1/+1
| | | | | | | | | Picked from 4.8 commit 3826203f744a2147bebf5f088de0d524156f59fd Task-number: QTBUG-8323 Change-Id: I360f7592cb6a0906ab7bf402963109b7aa1edebe Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I752b02a8155143626d22bd86082177550bd1cfb4 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update obsolete contact address.Jason McDonald2012-01-231-2/+2
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I6597406c8041227410e672b86a567e1161a0ab59 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Fix JS to QVariant type conversionKent Hansen2012-01-091-2/+2
| | | | | | | | | | | | | | | | | | 1) The special case for LastType (QVariant) should be done before the general conversion, to avoid calling convertValue() with targetType == -1 (which is useless and causes a qWarning). 2) moc is about to be changed to use QMetaType::QVariant instead of QVariant::LastType to represent the QVariant type. But to keep the CI happy in the transition period we have to check for both. The LastType check will be removed once qtbase has been updated. 3) Get rid of the variantFromValue function in qscriptqobject. It was identical to QScriptEnginePrivate::jscValueToVariant. Change-Id: Ie418facc06c6c7308bc60a3ff66b9a78b109d3d3 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-091-1/+1
| | | | | Change-Id: I323b788326712d95f6213ab8a68c18cfe28b7c76 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Fix translation context for QML files in a QRC.Michael Brasser2011-07-291-1/+6
| | | | | | | | | Task-number: QTBUG-17255 Change-Id: Id4685f2531af1113947c55184870e3b3cd874c32 Reviewed-on: http://codereview.qt.nokia.com/2355 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Replace all QAtomicInt ref variables by QSharedData inheritance.Jedrzej Nowacki2011-07-111-2/+2
| | | | | | | | | | There is no need to do reference counting by hand. QSharedData class provide good encapsulation of reference counter. Change-Id: I2611a51c2fa6673ccca69fe8ff83741ffac06ee9 Reviewed-on: http://codereview.qt.nokia.com/1378 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
* Use QAtomicInt instead of QBasicAtomicIntThiago Macieira2011-07-081-2/+2
| | | | | | | | | | | | None of these classes are POD, so they don't need to use the POD version of QAtomicInt. Change-Id: Ic7b134c85c4b314560ae79250e05159ffde74dfe Merge-request: 1 Reviewed-by: Jedrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-on: http://codereview.qt.nokia.com/1377 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Nierob <jedrzej.nowacki@nokia.com>
* Doc: Fixed qdoc warnings.David Boddie2011-05-201-1/+1
|
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+4456
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12