Prevent a Qt race condition where the dialog can be tested as existing, then the dialog pointer can be set to NULL by a dialog internal exit before a subsequent dialog call executes.

Essentially these patches lock out the dialog pointer reset until the subsequent dialog call completes after the dialog exist check.



git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1116662 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 14 years ago
parent 1d558b0bda
commit 8ff2829c73

@ -137,7 +137,8 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
mPipeOpen(false), mPipeOpen(false),
mPipeOpen_out(false), mPipeOpen_out(false),
mInfoMessageDisplayed(false), mInfoMessageDisplayed(false),
mForceReject(false) mForceReject(false),
mDialogControLock(false);
{ {
setupSignals(); setupSignals();
setupPipe(); setupPipe();
@ -293,20 +294,24 @@ void LockProcess::checkPipe()
if (numread > 0) { if (numread > 0) {
if (readbuf[0] == 'C') { if (readbuf[0] == 'C') {
mInfoMessageDisplayed=false; mInfoMessageDisplayed=false;
mDialogControLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
currentDialog->close(); currentDialog->close();
} }
mDialogControLock = false;
} }
if (readbuf[0] == 'T') { if (readbuf[0] == 'T') {
to_display = readbuf; to_display = readbuf;
to_display = to_display.remove(0,1); to_display = to_display.remove(0,1);
// Lock out password dialogs and close any active dialog // Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true; mInfoMessageDisplayed=true;
mDialogControLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
currentDialog->close(); currentDialog->close();
} }
mDialogControLock = false;
// Display info message dialog // Display info message dialog
QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) ); QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) );
InfoDlg inDlg( this ); InfoDlg inDlg( this );
@ -321,10 +326,12 @@ void LockProcess::checkPipe()
to_display = to_display.remove(0,1); to_display = to_display.remove(0,1);
// Lock out password dialogs and close any active dialog // Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true; mInfoMessageDisplayed=true;
mDialogControLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
currentDialog->close(); currentDialog->close();
} }
mDialogControLock = false;
// Display info message dialog // Display info message dialog
QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) ); QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) );
InfoDlg inDlg( this ); InfoDlg inDlg( this );
@ -342,10 +349,12 @@ void LockProcess::checkPipe()
to_display = to_display.remove(0,1); to_display = to_display.remove(0,1);
// Lock out password dialogs and close any active dialog // Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true; mInfoMessageDisplayed=true;
mDialogControLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
currentDialog->close(); currentDialog->close();
} }
mDialogControLock = false;
// Display query dialog // Display query dialog
QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) ); QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) );
QueryDlg qryDlg( this ); QueryDlg qryDlg( this );
@ -646,10 +655,12 @@ void LockProcess::createSaverWindow()
void LockProcess::desktopResized() void LockProcess::desktopResized()
{ {
mDialogControLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
currentDialog->close(); currentDialog->close();
} }
mDialogControLock = false;
// Get root window size // Get root window size
XWindowAttributes rootAttr; XWindowAttributes rootAttr;
@ -1142,6 +1153,10 @@ int LockProcess::execDialog( QDialog *dlg )
mDialogs.prepend( dlg ); mDialogs.prepend( dlg );
fakeFocusIn( dlg->winId()); fakeFocusIn( dlg->winId());
int rt = dlg->exec(); int rt = dlg->exec();
while (mDialogControLock == true) {
sleep(1);
}
currentDialog = NULL;
mDialogs.remove( dlg ); mDialogs.remove( dlg );
if( mDialogs.isEmpty() ) { if( mDialogs.isEmpty() ) {
XChangeActivePointerGrab( qt_xdisplay(), GRABEVENTS, XChangeActivePointerGrab( qt_xdisplay(), GRABEVENTS,
@ -1149,7 +1164,6 @@ int LockProcess::execDialog( QDialog *dlg )
resume( false ); resume( false );
} else } else
fakeFocusIn( mDialogs.first()->winId()); fakeFocusIn( mDialogs.first()->winId());
currentDialog = NULL;
return rt; return rt;
} }

@ -135,6 +135,7 @@ private:
bool mAutoLogout; bool mAutoLogout;
bool mInfoMessageDisplayed; bool mInfoMessageDisplayed;
QDialog *currentDialog; QDialog *currentDialog;
bool mDialogControLock;
bool mForceReject; bool mForceReject;
bool mPipeOpen; bool mPipeOpen;

Loading…
Cancel
Save