void TickerImportThread::run()
{
status = true;
{
status = false;
return;
}
if ( !query.exec("DELETE FROM \"bardata_M1\"") )
{
status = false;
qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
return;
}
QList<QByteArray> items;
long filesize = file.size();
long completed = 0;
int percentage = 0;
if ( !query.prepare("INSERT INTO \"bardata_M1\" (symbol, \"time\", open, high, low, \"close\") VALUES ('EURUSD', :v_time, :v_open, :v_high, :v_low, :v_close)") )
{
status = false;
qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
return;
}
while ( !file.atEnd() )
{
line = file.readLine();
items = line.split(',');
query.
bindValue(":v_time",
QString(items
[0]) + " " + QString(items
[1]));
query.bindValue(":v_open", items[2]);
query.bindValue(":v_high", items[3]);
query.bindValue(":v_low", items[4]);
query.bindValue(":v_close", items[5]);
if ( !query.exec() )
{
status = false;
qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
return;
}
completed += line.length();
double newpercentage = (double)completed / (double)filesize * 100;
if ( round(newpercentage) > percentage )
{
percentage = round(newpercentage);
emit importProgress(percentage);
}
}
emit importProgress(100);
file.close();
}
void TickerImportThread::run()
{
status = true;
QSqlQuery query;
QFile file(filename);
if ( !file.open(QIODevice::Text | QIODevice::ReadOnly) )
{
status = false;
return;
}
QSqlDatabase::database().transaction();
if ( !query.exec("DELETE FROM \"bardata_M1\"") )
{
status = false;
QSqlError error = query.lastError();
qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
QSqlDatabase::database().rollback();
return;
}
QByteArray line;
QList<QByteArray> items;
long filesize = file.size();
long completed = 0;
int percentage = 0;
if ( !query.prepare("INSERT INTO \"bardata_M1\" (symbol, \"time\", open, high, low, \"close\") VALUES ('EURUSD', :v_time, :v_open, :v_high, :v_low, :v_close)") )
{
status = false;
QSqlError error = query.lastError();
qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
QSqlDatabase::database().rollback();
return;
}
while ( !file.atEnd() )
{
line = file.readLine();
items = line.split(',');
query.bindValue(":v_time", QString(items[0]) + " " + QString(items[1]));
query.bindValue(":v_open", items[2]);
query.bindValue(":v_high", items[3]);
query.bindValue(":v_low", items[4]);
query.bindValue(":v_close", items[5]);
if ( !query.exec() )
{
status = false;
QSqlError error = query.lastError();
qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
QSqlDatabase::database().rollback();
return;
}
completed += line.length();
double newpercentage = (double)completed / (double)filesize * 100;
if ( round(newpercentage) > percentage )
{
percentage = round(newpercentage);
emit importProgress(percentage);
}
}
emit importProgress(100);
QSqlDatabase::database().commit();
file.close();
}
To copy to clipboard, switch view to plain text mode
*** glibc detected *** /home/till/forex-build-desktop/forex: double free or corruption (fasttop): 0x000000000094aa70 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x78a8f)[0x7ffff5370a8f]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x73)[0x7ffff53748e3]
/lib/libcrypto.so.0.9.8(CRYPTO_free+0x1d)[0x7fffeb6b0efd]
/lib/libssl.so.0.9.8(SSL_free+0x49)[0x7fffeba0e199]
/usr/lib/libpq.so.5(+0x19e8d)[0x7fffebc45e8d]
/usr/lib/libpq.so.5(+0x11bc9)[0x7fffebc3dbc9]
/usr/lib/libpq.so.5(PQgetResult+0x9d)[0x7fffebc3bbcd]
/usr/lib/libpq.so.5(+0xfe6b)[0x7fffebc3be6b]
/usr/lib/qt4/plugins/sqldrivers/libqsqlpsql.so(+0xe327)[0x7fffebe62327]
/usr/lib/libQtSql.so.4(_ZN9QSqlQuery4execEv+0xc5)[0x7ffff718cf15]
/home/till/forex-build-desktop/forex[0x40fc0e]
/usr/lib/libQtCore.so.4(+0x74175)[0x7ffff60bf175]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c)[0x7ffff5e33d8c]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7ffff53de04d]
*** glibc detected *** /home/till/forex-build-desktop/forex: double free or corruption (fasttop): 0x000000000094aa70 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x78a8f)[0x7ffff5370a8f]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x73)[0x7ffff53748e3]
/lib/libcrypto.so.0.9.8(CRYPTO_free+0x1d)[0x7fffeb6b0efd]
/lib/libssl.so.0.9.8(SSL_free+0x49)[0x7fffeba0e199]
/usr/lib/libpq.so.5(+0x19e8d)[0x7fffebc45e8d]
/usr/lib/libpq.so.5(+0x11bc9)[0x7fffebc3dbc9]
/usr/lib/libpq.so.5(PQgetResult+0x9d)[0x7fffebc3bbcd]
/usr/lib/libpq.so.5(+0xfe6b)[0x7fffebc3be6b]
/usr/lib/qt4/plugins/sqldrivers/libqsqlpsql.so(+0xe327)[0x7fffebe62327]
/usr/lib/libQtSql.so.4(_ZN9QSqlQuery4execEv+0xc5)[0x7ffff718cf15]
/home/till/forex-build-desktop/forex[0x40fc0e]
/usr/lib/libQtCore.so.4(+0x74175)[0x7ffff60bf175]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c)[0x7ffff5e33d8c]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7ffff53de04d]
To copy to clipboard, switch view to plain text mode
Bookmarks