I've spent a day completely reinstalling MySql, QT and various devel packages; then compiling everything from scratch. Result: No difference at all! Qt4.4.3 works, Qt4.5.0Beta doesn't.
To recap:
amodel.setQuery("SELECT sourceid FROM videosource"); //BANG! SIGSEGV
QSqlQueryModel amodel;
amodel.setQuery("SELECT sourceid FROM videosource"); //BANG! SIGSEGV
To copy to clipboard, switch view to plain text mode
Reason for segv: setQuery() eventually calls QMYSQLResult::size in file: $QTDIR/src/sql/drivers/mysql/qsql_mysql.cpp
Here's the code:
int QMYSQLResult::size()
{
if (isSelect())
if (d->d->preparedQuerys)
#if MYSQL_VERSION_ID >= 40108
return int(mysql_stmt_num_rows(d->stmt)); //<---we get here but d->stmt is null
#else
return -1;
#endif
else
return int(mysql_num_rows(d->result)); //<--- d->result is not null, maybe we should have got here
else
return -1;
}
int QMYSQLResult::size()
{
if (isSelect())
if (d->d->preparedQuerys)
#if MYSQL_VERSION_ID >= 40108
return int(mysql_stmt_num_rows(d->stmt)); //<---we get here but d->stmt is null
#else
return -1;
#endif
else
return int(mysql_num_rows(d->result)); //<--- d->result is not null, maybe we should have got here
else
return -1;
}
To copy to clipboard, switch view to plain text mode
When mysql_stmt_num_rows(d->stmt) is called it blows because d->stmt is 0x0.
Well I assume that's the reason; mysql_stmt_num_rows is in a mysql library and expects to see a "struct st_mysql_stmt" pointer.
I think I'll just put this down to a bug and move on - unless it rings any bells with anyone?
Bookmarks