summaryrefslogtreecommitdiff
path: root/src/lib/corelib/language/language.h
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2023-03-03 10:01:29 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2023-03-06 09:17:43 +0000
commit73994b550f85576844df229c6c7bea44604091e9 (patch)
tree2bbdbe27c9e7ffab496791917b0b02831d8cbb8a /src/lib/corelib/language/language.h
parent1f8c6d3560607078cf33a396f1907bb1677ba234 (diff)
downloadqbs-73994b550f85576844df229c6c7bea44604091e9.tar.gz
Prevent dangling JS values
As opposed to QtScript, such values cannot be re-used in QuickJS. This was overlooked in 087c22e17721f37490dd2048a567b6a58065d939. I assume this is the culprit for seemingly random crashes and "not a function" messages we have been seeing sometimes when building with Qt Creator. Change-Id: Ia4e7aed0cda97439ac75db5ecfbf08ff096a02b2 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'src/lib/corelib/language/language.h')
-rw-r--r--src/lib/corelib/language/language.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h
index d055aa132..a1115519d 100644
--- a/src/lib/corelib/language/language.h
+++ b/src/lib/corelib/language/language.h
@@ -70,15 +70,12 @@
#include <mutex>
#include <vector>
-QT_BEGIN_NAMESPACE
-class QScriptEngine;
-QT_END_NAMESPACE
-
namespace qbs {
namespace Internal {
class BuildGraphLocker;
class BuildGraphLoader;
class BuildGraphVisitor;
+class ScriptEngine;
class FileTagger
{
@@ -335,8 +332,8 @@ class PrivateScriptFunction
friend bool operator==(const PrivateScriptFunction &a, const PrivateScriptFunction &b);
public:
void initialize(const ScriptFunctionPtr &sharedData) { m_sharedData = sharedData; }
- mutable JSValue scriptFunction = JS_UNDEFINED; // not stored
+ JSValue getFunction(ScriptEngine *engine, const QString &errorMessage) const;
QString &sourceCode() const { return m_sharedData->sourceCode; }
CodeLocation &location() const { return m_sharedData->location; }
ResolvedFileContextConstPtr &fileContext() const { return m_sharedData->fileContext; }
@@ -349,6 +346,7 @@ public:
private:
ScriptFunctionPtr m_sharedData;
+ mutable JSValue scriptFunction = JS_UNDEFINED; // not stored
};
bool operator==(const PrivateScriptFunction &a, const PrivateScriptFunction &b);