[Qt-interest] How t o use sqlite3_create_collation_v2() API in QT application
ashish yadav
ashishyadav78 at gmail.com
Sat Jan 29 17:07:28 CET 2011
Hi ,
I am trying to use sqlite3_create_collation_v2() in QT application, but it
give Segmentation fault when application try to access this function.
The part of code which i use for this :
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE" );
db.setDatabaseName( "./testdatabase.db" );
if( !db.open() )
{
qDebug() << db.lastError();
qFatal( "Failed to connect." );
exit(1);
}
qDebug("Data Base Connected.");
QVariant v = db.driver()->handle();
if (v.isValid() && strcmp(v.typeName(), "sqlite3*") == 0)
{
// v.data() returns a pointer to the handle
sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
if (handle != 0)
{ // check that it is not NULL
qDebug() << "Able to get Sqlite3 driver handle.";
int rc ;
UCollator *pUCollator;
UErrorCode status = U_ZERO_ERROR;
pUCollator = ucol_open("en_EN", &status);
if( U_FAILURE(status) )
{
qDebug() << "Error in ucol_open\n";
return 0;
}
qDebug() << "going for sqlite3_create_collation_v2\n";
rc = sqlite3_create_collation_v2(handle,"ENGLISH", SQLITE_UTF16,
(void *)pUCollator,
icuCollationColl, icuCollationDel );
if( rc!=SQLITE_OK )
{
ucol_close(pUCollator);
qDebug() << "Error registering collation function" ;
}
}
else
{
qDebug() << "Could not get sqlite Driver handle.";
db.close();
exit(1);
}
}
else
{
qDebug() << "Not vaild handle variant returned." ;
db.close();
exit(1);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I also define/declare icuCollationColl & icuCollationDel function ..
Now when i run this application , its give Segmentation fault :
./code
Data Base Connected.
Able to get Sqlite3 driver handle.
going for sqlite3_create_collation_v2
Segmentation fault
Can any one please help me to resolve this issue ?
Please give me your suggestion , it will be help full to resolve this
issue.
Thanks & Regards
Ashish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110129/3faac112/attachment.html
More information about the Qt-interest-old
mailing list