Re: Digest for qdjango@googlegroups.com - 1 Message in 1 Topic

24 views
Skip to first unread message

William Tambellini

unread,
Jun 25, 2013, 12:06:09 PM6/25/13
to qdj...@googlegroups.com, pete....@canonical.com
Hi Pete,
 QSqlDatabase is usually not copy friendly.
 Strangely, the code from qdjango is not using a reference and consequently doing a copy :
    QDjango::setDatabase(QSqlDatabase db)
    vs
    QDjango::setDatabase(QSqlDatabase &db)
 Perhpas Qt5 is more sensitive than Qt4 regarding that.
 If it could help.
Yours
William.


2013/6/25 <qdj...@googlegroups.com>

Group: http://groups.google.com/group/qdjango/topics

    Pete Woods <pete....@canonical.com> Jun 24 02:21AM -0700  

    Hi,
     
    I'm considering using qdjango in a Qt5 app I'm writing at the moment, but
    I'm not getting very far with the examples.
     
    For example:
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");
    db.open();
    QDjango::setDatabase(db);
     
    Causes the following segmentation fault:
    Program received signal SIGSEGV, Segmentation fault.
    0x00007ffff49ea8d4 in QString::operator==(QLatin1String const&) const ()
    from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
    (gdb) bt
    #0 0x00007ffff49ea8d4 in QString::operator==(QLatin1String const&) const
    () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
    #1 0x00007ffff70f2d08 in operator!= (s=..., this=0x7fffffffdc20) at
    /usr/include/qt4/QtCore/qstring.h:413
    #2 QDjango::setDatabase (database=...) at QDjango.cpp:164
     
    If I copy the the same code from there into my code locally, e.g.:
     
    QSqlDatabase database(db);
    if (database.driverName() != QLatin1String("QSQLITE")
    && database.driverName() != QLatin1String("QSQLITE2")
    && database.driverName() != QLatin1String("QMYSQL")
    && database.driverName() != QLatin1String("QPSQL")) {
    qWarning() << "Unsupported database driver" << database.driverName();
    }
     
    then that doesn't segfault. Is this problem the result of mixing qt4 and
    qt5 libraries together?
     
    I'm using the Ubuntu-packaged version of qdjango (0.2.6) on a 64-bit VM.
     
    Cheers,
    Pete

     

You received this message because you are subscribed to the Google Group qdjango.
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit this group.

--
You received this message because you are subscribed to the Google Groups "QDjango" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qdjango+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages