I have an application in Qt that will override a shut down in case a user didn't save their document. It looks like this:
class MyApplication : public QtSingleApplication
{
public:
MyApplication(int argc, char *argv[]) : QtSingleApplication(argc, argv, true)
{
}
~MyApplication()
{
}
void commitData(QSessionManager &manager)
{
if(manager.allowsInteraction())
{
main->RequestShutdownOverride();
}
}
void SetMainWindow(MainWindow *m)
{
main = m;
}
MainWindow *main;
};
void MainWindow::RequestShutdownOverride()
{
if(myDocument->hasChanges() == true)
{
switch
(
QMessageBox::warning
(
NULL,
"Foobar",
"You are exiting without saving. Would you like to save?",
"Yes, save my document", "No, don't save my document",
0,
0,
1
)
)
{
case 0:
myDocument->save();
break;
case 1:
app->exit(0);
break;
}
}
}
The problem is for a couple of users they go to shut down, the shut down is overridden they click "no" and it saves the document anyway. I've tried troubleshooting this code and I can't find anything obvious, and worse - if I create a profile of my own on their machine it works fine again.
Is there anything code-wise that I've screwed up, or could there be something else causing it? I've tried switching Qt versions. The only other thing that these two users seem to have in common is that they both use windows vista, but others use vista and haven't reported this problem. Any ideas?
EDIT
I'm using this definition:
static int QMessageBox::warning
(
QWidget *parent,
const QString &title,
const QString &text,
const QString &button0Text,
const QString &button1Text = QString(),
const QString &button2Text = QString(),
int defaultButtonNumber = 0,
int escapeButtonNumber = -1
)