@@ -7,6 +7,7 @@ const Main = imports.ui.main;
77const PopupMenu = imports . ui . popupMenu ;
88const CheckBox = imports . ui . checkBox ;
99const RadioButton = imports . ui . radioButton ;
10+ const SignalManager = imports . misc . signalManager ;
1011
1112var BaseMnemonicMenuItem = class BaseMnemonicMenuItem extends PopupMenu . PopupBaseMenuItem {
1213 _init ( label , params ) {
@@ -366,7 +367,8 @@ var WindowMenu = class extends PopupMenu.PopupMenu {
366367
367368var WindowMenuManager = class {
368369 constructor ( ) {
369- this . _manager = new PopupMenu . PopupMenuManager ( this ) ;
370+ this . _manager = null ;
371+ this . _wmsignals = null ;
370372
371373 this . _sourceActor = new St . Widget ( { reactive : true , visible : false } ) ;
372374 this . _sourceActor . connect ( 'button-press-event' , ( ) => {
@@ -379,7 +381,6 @@ var WindowMenuManager = class {
379381
380382 this . current_menu = null ;
381383 this . current_window = null ;
382- this . destroyId = 0 ;
383384 }
384385
385386 showWindowMenuForWindow ( window , type , rect ) {
@@ -391,19 +392,21 @@ var WindowMenuManager = class {
391392 }
392393
393394 this . destroyMenu ( ) ;
395+ this . _manager = new PopupMenu . PopupMenuManager ( this ) ;
396+ this . _wmsignals = new SignalManager . SignalManager ( null ) ;
394397
395398 let menu = new WindowMenu ( window , this . _sourceActor ) ;
396399
397400 this . _manager . addMenu ( menu ) ;
398401
399- menu . connect ( 'activate' , ( ) => {
402+ this . _wmsignals . connect ( menu , 'activate' , ( ) => {
400403 window . check_alive ( global . get_current_time ( ) ) ;
401404 } ) ;
402- menu . connect ( 'menu-animated-closed' , ( ) => {
405+ this . _wmsignals . connect ( menu , 'menu-animated-closed' , ( ) => {
403406 this . destroyMenu ( ) ;
404407 } ) ;
405408
406- let destroyId = window . connect ( 'unmanaged' , ( ) => {
409+ this . _wmsignals . connect ( window , 'unmanaged' , ( ) => {
407410 this . destroyMenu ( ) ;
408411 } ) ;
409412
@@ -417,7 +420,7 @@ var WindowMenuManager = class {
417420
418421 menu . open ( ) ;
419422 menu . actor . navigate_focus ( null , Gtk . DirectionType . TAB_FORWARD , false ) ;
420- menu . connect ( 'open-state-changed' , ( menu_ , isOpen ) => {
423+ this . _wmsignals . connect ( menu , 'open-state-changed' , ( ) => {
421424 this . destroyMenu ( ) ;
422425 } ) ;
423426
@@ -426,16 +429,17 @@ var WindowMenuManager = class {
426429 }
427430
428431 destroyMenu ( ) {
429- this . _sourceActor . hide ( ) ;
432+ if ( this . _wmsignals != null ) {
433+ this . _wmsignals . disconnectAllSignals ( ) ;
434+ this . _wmsignals = null ;
430435
431- if ( this . destroyId > 0 ) {
432- this . current_window . disconnect ( destroyId ) ;
433- this . destroyId = 0 ;
434- }
436+ this . _sourceActor . hide ( ) ;
435437
436- if ( this . current_menu ) {
437- this . current_menu . destroy ( ) ;
438- this . current_menu = null ;
438+ if ( this . current_menu ) {
439+ this . current_menu . close ( false )
440+ this . _manager . destroy ( )
441+ this . _manager = null
442+ }
439443 }
440444 }
441445} ;
0 commit comments