Daimonie
17th February 2009, 23:02
Hey guys,
my program quits with a segmentation fault.
The gnu debugger tells me its these lines:
TorpiaDownload * download = this->downloads.at (processID);
QString sPath = download->path ();
QString TorpiaDownload::path ()
{
return this->sPath;
}
#ifndef TORPIADOWNLOAD_H
#define TORPIADOWNLOAD_H
#include <QString>
class TorpiaDownload
{
public:
QString path ();
int id ();
void setPath (QString path);
void setProcess (int ID);
private:
QString sPath;
int processID;
};
#endif
edit: after reading a bit..
int HTTPObject::downloadFile ( QString paramPath)
{
int processID = this->downloads.size ();
if (processID >= this->maxRequests)
{
return -1;
}
TorpiaDownload currentDownload;
currentDownload.setPath (paramPath);
currentDownload.setProcess (processID);
this->downloads.append (¤tDownload);
this->downloadQueue.append (processID);
if (this->timer->isActive () == false) {
timer->start (this->iInterval);
}
return processID;
}
now, what i'm trying to do here isn't that sophisticated.
The TorpiaDownload object holds a path and an id. Now, i want to ask for those two little things. I don't want 'you' to be able to edit them; no, you must use setPath for that.
Basically, i wanted QString path () to be of type const. But, that didn't work. So i removed it, and i still got that segmentation error .
Anybody sees my mistake?
Ps: i'm not used to working with the const keyword. any examples on how to return these (IE, have a normal property and a function that returns it, but casted to const), would be very useful :)
thanks in advance
my program quits with a segmentation fault.
The gnu debugger tells me its these lines:
TorpiaDownload * download = this->downloads.at (processID);
QString sPath = download->path ();
QString TorpiaDownload::path ()
{
return this->sPath;
}
#ifndef TORPIADOWNLOAD_H
#define TORPIADOWNLOAD_H
#include <QString>
class TorpiaDownload
{
public:
QString path ();
int id ();
void setPath (QString path);
void setProcess (int ID);
private:
QString sPath;
int processID;
};
#endif
edit: after reading a bit..
int HTTPObject::downloadFile ( QString paramPath)
{
int processID = this->downloads.size ();
if (processID >= this->maxRequests)
{
return -1;
}
TorpiaDownload currentDownload;
currentDownload.setPath (paramPath);
currentDownload.setProcess (processID);
this->downloads.append (¤tDownload);
this->downloadQueue.append (processID);
if (this->timer->isActive () == false) {
timer->start (this->iInterval);
}
return processID;
}
now, what i'm trying to do here isn't that sophisticated.
The TorpiaDownload object holds a path and an id. Now, i want to ask for those two little things. I don't want 'you' to be able to edit them; no, you must use setPath for that.
Basically, i wanted QString path () to be of type const. But, that didn't work. So i removed it, and i still got that segmentation error .
Anybody sees my mistake?
Ps: i'm not used to working with the const keyword. any examples on how to return these (IE, have a normal property and a function that returns it, but casted to const), would be very useful :)
thanks in advance