Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for MCUs
  4. Crash due to append() operation on a ListModel while migrating from Qt5.12 to Qt5.15

Crash due to append() operation on a ListModel while migrating from Qt5.12 to Qt5.15

Scheduled Pinned Locked Moved Unsolved Qt for MCUs
qmllistmodelqt5.15.3qt5.12migration
1 Posts 1 Posters 173 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pavankumar S V
    wrote on last edited by Pavankumar S V
    #1

    Hello,

    I'm migrating my Qt application from Qt5.12 to Qt5.15.

    Background:
    I have two qml files: screen1.qml and Object1.qml. screen1.qml is created based on user configurations in our PC application and is downloaded from PC to the embedded device.
    We are creating "Object1" from screen1.qml. A new item is added in a ListModel defined in screen1.qml based on user configuration and this new item is then appended to another listmodel in Object1.qml.

    screen1.qml:

    Rectangle 
    {
    	id: screen0001
    
    	Object1
    	{
    		objectName : "obj00"
    		x : 330
    		y : 64
    		width : 180
    		height : 384 
    		lmindex : [page11]
    		ListModel
    		{
    			id : page11
    			property string pageheading : "Menu"
    			property  bool enablereg : false 
    			property  int enableregIndx : 0 
    			property int menustrindex : 1 
    			Component.onCompleted: 
    			{
    				append({
    					promptText : "opt1",
    					nextpage : page11,
    					allowesc : 0,
    					timeBase : 0,
    					jmpscrnoffset : false,
    					nxtscreen : -1
    					})
    			}
    		}
    	}
    }
    

    Object1.qml:

    Rectangle
    {
    	id: rootrect
    	property var lmindex: [page1]
    	property var currentlm: lmindex[0]
    
    	ListModel
    	{
    		id:menuLM
    	}
    
    	onCurrentlmChanged: 
    	{
    		menuLM.clear()
    		updtTimer.start()
    	}
    
    	Timer 
    	{
    		id: updtTimer
    		interval: 1; running: false; repeat: true
    		triggeredOnStart: false
    		onTriggered:
    		{
    			if(currentlm.get(menuLM.count))
    			{
    				menuLM.append(currentlm.get(menuLM.count));
    			}
    		}
    	}
    }
    

    This code is working fine without any issues in qt5.12. But when I try this code in qt5.15, qt application is crashing while appending to the ListModel(). (Line of code - "menuLM.append(currentlm.get(menuLM.count))" in Object1.qml).

    But If a add a dummy item while defining the ListModel menuLM like below, I don't see the crash:

    ListModel
    	{
    		id:menuLM
    		Component.onCompleted:
    		{
    			append
    			({
    			        promptText : "---",
    				nextpage : dummyList,
    				allowesc : 0,
    				timeBase : 0,
    				jmpscrnoffset : false, 
                                    nxtscreen : -1
                           })
    		}
    	}
    

    I'm not able to find out the reason for this crash seen only in qt5.15.

    Questions:

    1. Please help me to know what is the reason for this crash in qt5.15.
    2. Are there any differences in ListModel between Qt5.12 and Qt5.15? (I could not see any changes related to Listmodel when I referred the release notes of Qt5.15.)
    3. It looks like in qt5.15, ListModel menuLM is not allocated any memory if there is no item in it while defining maybe to optimise it. This might be causing the crash when i try to append an item to it. But i don't have any confirmation for this. Please let me know if this is the reason.
    4. Please let me know if there is any alternate solution for this.

    Thank you,

    Best Regards,
    Pavankumar S V

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved