aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-12-07 11:20:07 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-12-07 15:53:21 +0100
commitc8d98dc206714abd5c0dc76008ffa729973d3a8f (patch)
treef57120bd95ff0762fd7c5059c297f2c38da80a6f /src/qml/qml/v8
parent33c87736db7ec79c89c0497192727697d126628d (diff)
Allow the QML console methods to be called from outside JS
There may not be a stack frame and that is OK. Change-Id: Iccac4db1530c9a4b316905a3a283d36674c146a8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 0610bf0ccc..0e0bd5c164 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1391,9 +1391,10 @@ static ReturnedValue writeToConsole(const FunctionObject *b, const Value *argv,
if (!loggingCategory)
loggingCategory = v4->qmlEngine() ? &qmlLoggingCategory : &jsLoggingCategory;
QV4::CppStackFrame *frame = v4->currentStackFrame;
- const QByteArray baSource = frame->source().toUtf8();
- const QByteArray baFunction = frame->function().toUtf8();
- QMessageLogger logger(baSource.constData(), frame->lineNumber(), baFunction.constData(), loggingCategory->categoryName());
+ const QByteArray baSource = frame ? frame->source().toUtf8() : QByteArray();
+ const QByteArray baFunction = frame ? frame->function().toUtf8() : QByteArray();
+ QMessageLogger logger(baSource.constData(), frame ? frame->lineNumber() : 0,
+ baFunction.constData(), loggingCategory->categoryName());
switch (logType) {
case Log: