Sometimes yes, sometimes not. Your question is way too generic to be able to give a specific answer.
I have a class like this
class PlotData
{
private :
double *data;
public:
PlotData()
{
data = new double[1000];
}
~PlotData()
{
delete []data;
}
};
class PlotData
{
private :
double *data;
public:
PlotData()
{
data = new double[1000];
}
~PlotData()
{
delete []data;
}
};
To copy to clipboard, switch view to plain text mode
and a class which inherits QThread
{
Q_OBJECT
signals:
void signal_process(PlotData*);
public:
void run()
{
while(true)
{
PlotData *pd = new PlotData();
emit signal_process(pd);
}
}
};
class Thread:QThread
{
Q_OBJECT
signals:
void signal_process(PlotData*);
public:
void run()
{
while(true)
{
PlotData *pd = new PlotData();
emit signal_process(pd);
}
}
};
To copy to clipboard, switch view to plain text mode
now in the main gui thread i have a slot like void Delete_PlotData(PlotData*) .
connect(&thread,SIGNAL(signal_process(PlotData*)),this,Delete_PlotData(PlotData*)));
connect(&thread,SIGNAL(signal_process(PlotData*)),this,Delete_PlotData(PlotData*)));
To copy to clipboard, switch view to plain text mode
Now is it legal to call the PlotData destructor as below.
void Delete_PlotData(PlotData* pd)
{
pd->~PlotData() //Is this legal
}
void Delete_PlotData(PlotData* pd)
{
pd->~PlotData() //Is this legal
}
To copy to clipboard, switch view to plain text mode
Bookmarks