Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, March 2002
Mutex destroy failure


Message 1 in thread

Hi,

I have a simple piece of test code which opens a connection to a MySQL
database, issues a simple query, prints the result to cout and exits. It
compiles fine without any warnings and it prints out the right
information but it also prints out this message right at the end:

Mutex destroy failure: Device or resource busy

Does anybody know why this is happening?

cheers,
tomek

-------------------------------------------------------------------------------

#include <qapplication.h>
#include <qsqldatabase.h>
#include <qsqlquery.h>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QSqlDatabase *db = QSqlDatabase::addDatabase("QMYSQL3");
    if (db) {
        db->setDatabaseName("wxscape");
        db->setHostName("pirhana.met.co.nz");
        db->setUserName("wxscape");
        if (!db->open()) {
            qWarning("Failed to open locations database: " +
                     db->lastError().driverText());
            qWarning(db->lastError().databaseText());
            app.exit(1);
        }
    } else {
        qWarning("Failed to connect to driver");
        app.exit(1);
    }

    QString name = argv[1];


    QSqlQuery query("SELECT full_name,cc1,dd_lat,dd_long FROM locations
WHERE full_name LIKE \"%"+name+"%\" ORDER BY cc1,full_name;", db);

    QString output;
    if (query.isActive()) {
        while (query.next()) {

            QString name = query.value(0).toString();
            QString cc = query.value(1).toString();
            float lat = query.value(2).toDouble();
            float lon = query.value(3).toDouble();

            cout << output.sprintf("%-32s\t%s\t%+03.3f\t%+03.3f",
                                   name.latin1(), cc.latin1(), lat, lon)
                 << endl;
        }
    }

    return(0);
}



Message 2 in thread

On 4 Mar 2002, Tomek Piatek wrote:

> I have a simple piece of test code which opens a connection to a MySQL
> database, issues a simple query, prints the result to cout and exits. It
> compiles fine without any warnings and it prints out the right
> information but it also prints out this message right at the end:
>
> Mutex destroy failure: Device or resource busy

I'd like to know this as well.

I had exactly the same problem (i.e. "Mutex destroy failure:  Device or
resource busy") but wasn't doing anything complicated (like database
queries), I was just reading a file and showing a dialog.  Admittedly, I
*was* trying to read my file from an invalid pointer, and when I fixed
this, it stopeed, but I was slightly confused at to what was printing the
error.

Is there something in Qt that's trying to catch segfaults (and friends)?
Is that even possible?

Charlie - Queens' College - Cavendish Astrophysics - 07866 636318