Ensure that QCloseEvents can be vetoed by wx

These events use a different convention from all the other ones in Qt
and need to be ignored, rather than accepted, to prevent the default
action from occurring.

And these events are also sent to disabled windows, which are never
supposed to receive them in wx API.

Closes https://github.com/wxWidgets/wxWidgets/pull/1371
This commit is contained in:
Matthew Griffin 2019-06-28 09:40:11 +01:00 committed by Vadim Zeitlin
parent fcd6ee5324
commit 9434a443f5
2 changed files with 7 additions and 2 deletions

View File

@ -104,7 +104,7 @@ protected:
if ( !this->GetHandler()->QtHandleCloseEvent(this, event) )
Widget::closeEvent(event);
else
event->accept();
event->ignore();
}
//wxContextMenuEvent

View File

@ -1557,12 +1557,17 @@ bool wxWindowQt::QtHandleChangeEvent ( QWidget *handler, QEvent *event )
return false;
}
// Returns true if the closing should be vetoed and false if the window should be closed.
bool wxWindowQt::QtHandleCloseEvent ( QWidget *handler, QCloseEvent *WXUNUSED( event ) )
{
if ( GetHandle() != handler )
return false;
return Close();
// This is required as Qt will still send out close events when the window is disabled.
if ( !IsEnabled() )
return true;
return !Close();
}
bool wxWindowQt::QtHandleContextMenuEvent ( QWidget *WXUNUSED( handler ), QContextMenuEvent *event )