[Qt-interest] How t o use sqlite3_create_collation_v2() API in QTapplication
Scott Aron Bloom
Scott.Bloom at onshorecs.com
Sat Jan 29 18:09:04 CET 2011
When you step in with debugger.. whats the problem?
From: qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com
[mailto:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com] On
Behalf Of ashish yadav
Sent: Saturday, January 29, 2011 8:07 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] How t o use sqlite3_create_collation_v2() API in
QTapplication
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/8facbb65/attachment.html
More information about the Qt-interest-old
mailing list