Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.1
-
None
Description
I create a widget that has 3 nested rectangles.
When all three are in the same data file, the logic works correctly.
I remove one of the rectangles into a separate file, and replace its
presence with the reference to the external file. The results is
that a function call to an embedded function no longer works. (it is skipped)
as if it does not exist. I have tried to find out where it went. In debug mode
the call is executed and returns immediately. No console.log message in the
called function is produced. I replace the reference to the external file, in the
same document tree location with the actual code, and the message from the called function appears.
Here is the simple widget I placed in a separate file:
==================================================
Local_dummy.qml
-------------------------------------------------
import QtQuick 2.12
import QtQuick.Window 2.12
Rectangle
{
function prt(msg)
{console.log(msg)}function constructor() { prt("dummy constructor")}
}
===========================================================
Here is the main application file
======================================================
Project_file.qml
----------------------------------------------------
import QtQuick 2.12
import QtQuick.Window 2.12
Window
{
width: 640
height: 480
visible: true
title: qsTr("nested_call_fails")
Rectangle // background_frame
{
id: r1
anchors.fill: parent
Rectangle
{
id: r2
function prt(msg) {console.log(msg)}
function constructor()
{ console.log("breadboard constructor")}
anchors.fill: parent
property var _controler: testing
Local_dummy // shell rectangle
{
id: testing
function constructor()
function _App_constructor()
{ prt("did we get this far?") constructor() prt("got back from constructor") }}
Component.onCompleted: // member of r2
{ _controler._App_constructor() } }
}
}
============================================================
The external file name is Local_dummy.qml
The expected output when the Local_dummy Rectangle is
replaced (not invoking the widget) is 3 console.log messages.
When the external widget is used there are only 2 console.log messages.
It does not matter if the external widget is in the same directory as the main file,
or in a sub-directory, and accessed via an import, the same effect is only 2
console.log messages are displayed in the application output.
==========================================================
Here is the application output data (with reference to external file)
-----------------------------------------------------------
16:25:35: Starting /home/leemke/Qt/5.15.0/gcc_64/bin/qmlscene /home/leemke/proj/qt/nested_call_fails/nested_call_fails.qml...
qml: did we get this far?
qml: got back from constructor
16:25:38: /home/leemke/Qt/5.15.0/gcc_64/bin/qmlscene exited with code 0
=============================================
As you can see there are only 2 qml: output message. Replacing the
widget instance with the same code in the proper place results in
the missing message just before "got back from constructor".
Attachments
Issue Links
- resulted in
-
QTBUG-87094 Lack of naming convention leads to name collisions and unexpected results.
- Closed