Hi guys..
I have some problems reading a file.
always I run the program, this crash in the same position of file.
I used gdb to debug and I had this error:
#0 0x00002aaaabd4c40b in memcpy () from /lib64/libc.so.6
#1 0x00002aaaaaf9c172 in QString::append (this=0x639260, str=@0x7fff529efe10) at /usr/include/bits/string3.h:52
#2 0x00002aaaaafe4277 in QTextStreamPrivate::fillReadBuffer (this=0x6391d0, maxBytes=-1) at ../../src/corelib/tools/qstring.h:255
#3 0x00002aaaaafe4f25 in QTextStreamPrivate::scan (this=0x6391d0, ptr=0x7fff529f3f08, length=0x7fff529f3f1c, maxlen=0, delimiter=QTextStreamPrivate::EndOfLine) at io/qtextstream.cpp:696
#4 0x00002aaaaafe5a81 in QTextStream::readLine (this=<value optimized out>, maxlen=0) at io/qtextstream.cpp:1584
#5 0x0000000000401ed2 in main (argc=2, argv=0x7fff529f41b8) at main.cpp:53
the problem, I think is in.readLine() but I don't know why.
Could you help me?
{
int pos = 0;
do {
line = in.readLine(); <------- problem here
qDebug() << "pos: " << pos << " length: " << line.length();
++pos;
//process_line(line);
} while (!line.isNull());
sql_file.close();
}
if(sql_file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&sql_file);
QString line;
int pos = 0;
do {
line = in.readLine(); <------- problem here
qDebug() << "pos: " << pos << " length: " << line.length();
++pos;
//process_line(line);
} while (!line.isNull());
sql_file.close();
}
To copy to clipboard, switch view to plain text mode
Thanks in advance
Bookmarks