[Interest] Sqlite3 handler access
Scott Aron Bloom
Scott.Bloom at onshorecs.com
Tue Aug 14 16:14:20 CEST 2012
Same crash.. the pointer is fine, somethine else is screwy
Scott
-----Original Message-----
From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of Constantin Makshin
Sent: Tuesday, August 14, 2012 4:52 AM
To: Qt Interest
Subject: Re: [Interest] Sqlite3 handler access
Don't use the undocumented QVariant::data() method designed for some Qt's internal purposes. Use QVariant::value():
sqlite3* handler = v.value<sqlite3*>();
On Mon, Aug 13, 2012 at 10:16 PM, Scott Aron Bloom <Scott.Bloom at onshorecs.com> wrote:
> I need to add a custom command to my sqlite3 system Im accessing via
> QSqlDatabase..
>
>
>
> Per reading found at sourceforge and qtcentre, I have compiled in the
> code locally from the Qt source area..
>
>
>
> However, on the call to sqlite3_create_function, sqlite is crashing…
>
>
>
> extern "C"
>
> void getMsgID( sqlite3_context * context, int argc, sqlite3_value **
> argv )
>
> {
>
> assert( argc == 2 );
>
> sqlite3_result_int( context, 0 );
>
> }
>
>
>
> bool loadCustomCommands( QSqlDatabase & db )
>
> {
>
> QVariant v = db.driver()->handle();
>
> if ( !v.isValid() || qstrcmp( v.typeName(), "sqlite3*" ) != 0 )
>
> {
>
> return false;
>
> }
>
>
>
> sqlite3 * handler = *static_cast<sqlite3**>( v.data() );
>
> if ( !handler )
>
> return false;
>
>
>
> sqlite3_create_function( handler, "msgid", 2, SQLITE_ANY, NULL,
> &getMsgID, NULL, NULL );
>
> return true;
>
> }
>
>
>
> Any thoughts, ideas??
>
>
> Scott
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list