Przeglądaj źródła

keep menus instances (prevent potential gc crash)

Nicolas Cannasse 6 lat temu
rodzic
commit
ed2d19fbfa
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      hide/comp/ContextMenu.hx

+ 4 - 0
hide/comp/ContextMenu.hx

@@ -11,7 +11,10 @@ typedef ContextMenuItem = {
 
 
 class ContextMenu {
 class ContextMenu {
 
 
+	static var MENUS : Array<nw.Menu>;
+
 	public function new( config : Array<ContextMenuItem> ) {
 	public function new( config : Array<ContextMenuItem> ) {
+		MENUS = [];
 		var menu = makeMenu(config);
 		var menu = makeMenu(config);
 		var ide = hide.Ide.inst;
 		var ide = hide.Ide.inst;
 		// wait until mousedown to get correct mouse pos
 		// wait until mousedown to get correct mouse pos
@@ -22,6 +25,7 @@ class ContextMenu {
 
 
 	function makeMenu( config : Array<ContextMenuItem> ) {
 	function makeMenu( config : Array<ContextMenuItem> ) {
 		var m = new nw.Menu({type:ContextMenu});
 		var m = new nw.Menu({type:ContextMenu});
+		MENUS.push(m);
 		for( i in config )
 		for( i in config )
 			m.append(makeMenuItem(i));
 			m.append(makeMenuItem(i));
 		return m;
 		return m;