Destructor array of object
-
After hours i found the problem. The problem is a desctructor of QString. I have one class that load some string from a file and store it in a vector (now i can use a QList but this is old code). This vector is used by some class and is copy. In this old project there aren't delete and the program have much memory leak. The code is this:
@//Class that load string
class Loader
{
public:
Loader();
~Loader();
QString* getList();
private:
QString str[500];
};Loader::Loader()
{
for(quint16 a=0;a<500;a++)
str[a] = "a"; //This is example fill str with 'a'
}//This is another class that have loader class and call descructor
class Test : public QDialog, private Ui::Dprodotti {
Q_OBJECT
public:
Test(QWidget *parent = 0);
~Test();private:
Loader *loader;
QString myStr[500];private slots:
void on_pushButton_clicked();
};Test::Test(QWidget *parent) : QDialog(parent)
{
setupUi(this);loader = new Loader(); memcpy(myStr,product->getList(),sizeof(myStr)); setAttribute(Qt::WA_DeleteOnClose);
}
Test::~Test()
{
delete loader;
}void Test::on_pushButton_clicked()
{
close();
}@There something wrong in that QString vector but i don't understand what...