Is qdjango-db safe to use from Qt5 apps?

75 views
Skip to first unread message

Pete Woods

unread,
Jun 24, 2013, 5:21:52 AM6/24/13
to qdj...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages