Record a wrong use code causing the program to crash

First record a follow-up supplement:

Roughly c ++ inherits QAbstractListModel to rewrite custom model  

Put a table of information in the model to store all the information of a table for QList <Record> list

Record is a record of a table, and then a function is provided in the model Record * getRecord (int row)

Get a record of a certain line, here mistakenly passed the list [row] in the member to the interface, resulting in the repeated release of the block of memory

Record passed in main.cpp 

qmlRegisterType<Record>("uri", 1, 0, "Record "); 注册进qml中提供给界面接收用。 然后界面关闭后主动将该块内存释放了,导致内存的重复释放,

Solution: In Record * getRecord (int row), the new Record block of memory is provided to the interface 

Record  *data = new Record;

(* data) = is [row]

Solve the problem of multiple memory release

 

Wow
Published 206 original articles · praised 18 · 70,000 views

Guess you like

Origin blog.csdn.net/lvmengzou/article/details/105455393