diff --git a/common/single_top.cpp b/common/single_top.cpp index bc95336f0a..2a7f18ca08 100644 --- a/common/single_top.cpp +++ b/common/single_top.cpp @@ -224,7 +224,7 @@ struct APP_SINGLE_TOP : public wxApp dlgs.push_back( dialog ); } // Under GTK, sometimes the modal flag is cleared before hiding - else if( !event.IsShown() ) + else if( !event.IsShown() && !dlgs.empty() ) { // If we close the expected dialog, remove it from our stack if( dlgs.back() == dialog ) diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 61cd364584..311a011d8b 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -485,7 +485,7 @@ struct APP_KICAD : public wxApp dlgs.push_back( dialog ); } // Under GTK, sometimes the modal flag is cleared before hiding - else if( !event.IsShown() ) + else if( !event.IsShown() && !dlgs.empty() ) { // If we close the expected dialog, remove it from our stack if( dlgs.back() == dialog ) diff --git a/kicad/kicad_cli.cpp b/kicad/kicad_cli.cpp index d5ca0e7e0d..ee8fd5c10a 100644 --- a/kicad/kicad_cli.cpp +++ b/kicad/kicad_cli.cpp @@ -512,7 +512,7 @@ struct APP_KICAD_CLI : public wxAppConsole dlgs.push_back( dialog ); } // Under GTK, sometimes the modal flag is cleared before hiding - else if( !event.IsShown() ) + else if( !event.IsShown() && !dlgs.empty() ) { // If we close the expected dialog, remove it from our stack if( dlgs.back() == dialog )