I found a mistake in my code that I was calling batch function again in loop apart from timeout's SLOT. So, I modified my approach, but now the application is crashing.
// cresultstable.h
{
Q_OBJECT
public:
private:
std::vector<std::string>::iterator it;
std::vector<std::string>::iterator endOfFile;
int rowIterator;
.... // other widgets
private slots:
void batchLoadRecords();
public slots:
void loadTable(); // This will be called on signal
};
// cresultstable.h
class CResultsTable : public QTableWidget
{
Q_OBJECT
public:
CResultsTable(QString fName, QWidget *parent = 0);
private:
QTimer *batchTimer;
std::vector<std::string>::iterator it;
std::vector<std::string>::iterator endOfFile;
int rowIterator;
.... // other widgets
private slots:
void batchLoadRecords();
public slots:
void loadTable(); // This will be called on signal
};
To copy to clipboard, switch view to plain text mode
Now I'm not using loop to iterate for each index of the string vector. Instead, I'm calling the batchLoadRecords() in timer's timeout slot only.
// cresultstable.cpp
{
... // other initializations
...
batchTimer = new QTimer(this);
connect(batchTimer, SIGNAL(timeout()), this, SLOT(batchLoadRecords()));
};
void CResultsTable::loadTable()
{
XMLParser *xmlParse;
xmlParse= new XMLParser();
xmlParse->Parse();
std::vector<std::string> info = xmlParse->GetInfo(); // info contains the data of parsed XML document
int numOfItems = info.size();
setRowCount(numOfItems);
rowIterator = 0;
it = info.begin();
endOfFile = info.end();
batchTimer->start(); // Starting the timer here;
delete resultParse;
resultParse = NULL;
}
void CResultsTable::batchLoadRecords()
{
int temp = 0;
if(it == endOfFile)
{
batchTimer->stop();
emit loadComplete();
return;
}
std::string str = *it; // Break-point here
// --------- vv
// Adding the data into table rows here
// --------- ^^
it++;
rowNumber++;
}
// cresultstable.cpp
CResultsTable::CResultsTable(QString fName, QWidget *parent) :
QTableWidget(parent)
{
... // other initializations
...
batchTimer = new QTimer(this);
connect(batchTimer, SIGNAL(timeout()), this, SLOT(batchLoadRecords()));
};
void CResultsTable::loadTable()
{
XMLParser *xmlParse;
xmlParse= new XMLParser();
xmlParse->Parse();
std::vector<std::string> info = xmlParse->GetInfo(); // info contains the data of parsed XML document
int numOfItems = info.size();
setRowCount(numOfItems);
rowIterator = 0;
it = info.begin();
endOfFile = info.end();
batchTimer->start(); // Starting the timer here;
delete resultParse;
resultParse = NULL;
}
void CResultsTable::batchLoadRecords()
{
int temp = 0;
QStringList txt;
QString s;
if(it == endOfFile)
{
batchTimer->stop();
emit loadComplete();
return;
}
std::string str = *it; // Break-point here
// --------- vv
// Adding the data into table rows here
// --------- ^^
it++;
rowNumber++;
}
To copy to clipboard, switch view to plain text mode
I put break-point, but the application crashes and shows some dissembler code.
The stack points at 0
0 RaiseException KERNELBASE 0x75a1812f
1 CxxThrowException MSVCR100 0x6ee8872d
2 fcloseall MSVCR100 0x6ee9f30f
3 com_ximpleware::VTDNav::getXPathStringVal MyApp 0xfb1c88
4 com_ximpleware::VTDNav::getXPathStringVal MyApp 0xfb1f7e
5 com_ximpleware::VTDNav::getXPathStringVal MyApp 0xfc3e6a
0 RaiseException KERNELBASE 0x75a1812f
1 CxxThrowException MSVCR100 0x6ee8872d
2 fcloseall MSVCR100 0x6ee9f30f
3 com_ximpleware::VTDNav::getXPathStringVal MyApp 0xfb1c88
4 com_ximpleware::VTDNav::getXPathStringVal MyApp 0xfb1f7e
5 com_ximpleware::VTDNav::getXPathStringVal MyApp 0xfc3e6a
To copy to clipboard, switch view to plain text mode
Bookmarks