Просмотр исходного кода

tools: do not hold reference to LevelEditorApplication

Daniele Bartolini 5 лет назад
Родитель
Сommit
bb36a31cc8
2 измененных файлов с 4 добавлено и 5 удалено
  1. 1 1
      tools/level_editor/level_editor.vala
  2. 3 4
      tools/widgets/console_view.vala

+ 1 - 1
tools/level_editor/level_editor.vala

@@ -345,7 +345,7 @@ namespace Crown
 			_combo.append("game", "Game");
 			_combo.set_active_id("editor");
 
-			_console_view = new ConsoleView(this, _project, _combo);
+			_console_view = new ConsoleView(_project, _combo);
 			_project_browser = new ProjectBrowser(_project, _project_store);
 			_level_treeview = new LevelTreeView(_database, _level);
 			_level_layers_treeview = new LevelLayersTreeView(_database, _level);

+ 3 - 4
tools/widgets/console_view.vala

@@ -59,7 +59,6 @@ namespace Crown
 		// Data
 		public EntryHistory _entry_history;
 		public uint _distance;
-		public LevelEditorApplication _editor;
 		public Project _project;
 
 		// Widgets
@@ -68,14 +67,13 @@ namespace Crown
 		public Gtk.Entry _entry;
 		public Gtk.Box _entry_hbox;
 
-		public ConsoleView(LevelEditorApplication editor, Project project, Gtk.ComboBoxText combo)
+		public ConsoleView(Project project, Gtk.ComboBoxText combo)
 		{
 			Object(orientation: Gtk.Orientation.VERTICAL, spacing: 0);
 
 			// Data
 			_entry_history = new EntryHistory(256);
 			_distance = 0;
-			_editor = editor;
 			_project = project;
 
 			// Widgets
@@ -126,7 +124,8 @@ namespace Crown
 				_entry_history.push(text);
 				_distance = 0;
 
-				ConsoleClient? client = _editor.current_selected_client();
+				Gtk.Application app = ((Gtk.Window)this.get_toplevel()).application;
+				ConsoleClient? client = ((LevelEditorApplication)app).current_selected_client();
 
 				if (text[0] == ':')
 				{