vendredi 29 janvier 2016

Qt executable running in release folder - Runtime error in Program Files (x86)

I seem to be getting a runtime error when trying to run my Qt application.

I am able to successfully build my application in release mode and it runs just fine sitting in the release folder. That's not where it's going to sit when users install it, however. I need it to run in C:/Program Files (x86)/ApplicationName/application.exe.

So I moved the application there. I recently added some SQLite functionality to the application. So I expected to get some sort of missing dll file error. I did. So I found the correct dll file (Qt5Sql.dll) and moved it into that directory. Now I'm getting a Runtime Error.

To figure out what was causing this Runtime Error, I threw in a bunch of QMessageBox::warnings to see when it was getting the error. The error is being caused by this line of code:

sqlite = new SQLite(QString("%1%2").arg(myDocuments).arg(SQLite::DATABASE_NAME));

I checked to make sure I was getting the expected QString from QString("%1%2").arg(myDocuments).arg(SQLite::DATABASE_NAME) and I was.

Here is what that constructor looks like in sqlite.cpp:

SQLite::SQLite(const QString& path)
{
    database = QSqlDatabase::addDatabase("QSQLITE");
    database.setDatabaseName(path);

    if (!database.open())
    {
        QMessageBox::warning(NULL, "Error", "Failed to open database.");
    }
}

The peculiar thing is I know I'm not even getting into that constructor because I put a QMessageBox::warning before the first line in the constructor and I'm not seeing that before the Runtime Error. I am seeing the QMessageBox::warning directly before the constructor though.

Anyone out there have any idea what might be causing this?

Aucun commentaire:

Enregistrer un commentaire