Avoid holding objects in daemon connect callbacks

This commit is contained in:
asonix 2021-05-04 21:28:02 -05:00
parent c16ed01fbe
commit 35462e1cae
3 changed files with 12 additions and 6 deletions

View file

@ -1,13 +1,11 @@
namespace Streamdeck.Dialogs {
public class EditCommandDialog : Granite.Dialog {
private Gtk.Stack stack;
public EditCommandDialog (string serial_number, Data.Command initial_command) {
var disconnected_page = new Widgets.DisconnectedPage ();
var command_page = new Views.ConfigCommand.from_existing (serial_number, initial_command);
stack = new Gtk.Stack ();
var stack = new Gtk.Stack ();
stack.add_named (disconnected_page, "disconnected");
stack.add_named (command_page, "command");

View file

@ -1,9 +1,10 @@
namespace Streamdeck.Dialogs {
public class NewCommandDialog : Granite.Dialog {
private string serial_number;
private Gtk.Stack stack;
private ReadInput key_info;
public signal void key_press (ReadInput key_info);
public NewCommandDialog (string serial_number) {
this.serial_number = serial_number;
@ -25,7 +26,7 @@ namespace Streamdeck.Dialogs {
var command_page = new Views.ConfigCommand (serial_number);
stack = new Gtk.Stack ();
var stack = new Gtk.Stack ();
stack.add_named (disconnected_page, "disconnected");
stack.add_named (press_page, "keypress");
stack.add_named (command_page, "command");
@ -40,7 +41,7 @@ namespace Streamdeck.Dialogs {
show_all ();
Daemon.instance.key_press_signal.connect ((_obj, key_info) => {
key_press.connect ((_obj, key_info) => {
if (serial_number == key_info.serial_number) {
this.key_info = key_info;
command_page.key = key_info.key;

View file

@ -42,6 +42,13 @@ namespace Streamdeck.Widgets {
scrolled.expand = true;
scrolled.add (list_box);
Daemon.instance.key_press_signal.connect ((_obj, key_info) => {
if (new_command_dialog != null) {
new_command_dialog.key_press (key_info);
}
});
var commands = Daemon.instance.get_commands (info.serial_number);
if (commands != null) {
foreach (CommandInfo cmd_info in commands) {