diff options
author | bubnikv <bubnikv@gmail.com> | 2016-06-03 10:36:23 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2016-06-03 10:36:23 +0300 |
commit | 5573faec6b878a3f618618441eef070f4e7e8e95 (patch) | |
tree | 0cf4260fcdbb74c5712bbda1f732c34922cf4567 /lib | |
parent | bb9c3dd9cea918da8478b606bdc38b1b34b4ea75 (diff) |
Moved the Bonjour discovery to Tab.pm,
when no Bonjour devices found, a simple message box is shown.
Otherwise the Bonjour selection dialog with an empty list crashes on windows.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Slic3r/GUI/BonjourBrowser.pm | 8 | ||||
-rw-r--r-- | lib/Slic3r/GUI/Tab.pm | 25 |
2 files changed, 20 insertions, 13 deletions
diff --git a/lib/Slic3r/GUI/BonjourBrowser.pm b/lib/Slic3r/GUI/BonjourBrowser.pm index 21966d6e8..469d0302e 100644 --- a/lib/Slic3r/GUI/BonjourBrowser.pm +++ b/lib/Slic3r/GUI/BonjourBrowser.pm @@ -9,14 +9,10 @@ use base 'Wx::Dialog'; sub new { my $class = shift; - my ($parent) = @_; + my ($parent, $devices) = @_; my $self = $class->SUPER::new($parent, -1, "Device Browser", wxDefaultPosition, [350,700], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER); - # look for devices - eval "use Net::Bonjour; 1"; - my $res = Net::Bonjour->new('http'); - $res->discover; - $self->{devices} = [ $res->entries ]; + $self->{devices} = $devices; # label my $text = Wx::StaticText->new($self, -1, "Choose an OctoPrint device in your network:", wxDefaultPosition, wxDefaultSize); diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 9c0ee5788..e7ad8370b 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -1130,13 +1130,24 @@ sub build { } EVT_BUTTON($self, $btn, sub { - my $dlg = Slic3r::GUI::BonjourBrowser->new($self); - if ($dlg->ShowModal == wxID_OK) { - my $value = $dlg->GetValue . ":" . $dlg->GetPort; - $self->{config}->set('octoprint_host', $value); - $self->update_dirty; - $self->_on_value_change('octoprint_host', $value); - $self->reload_config; + # look for devices + my $entries; + { + my $res = Net::Bonjour->new('http'); + $res->discover; + $entries = [ $res->entries ]; + } + if (@{$entries}) { + my $dlg = Slic3r::GUI::BonjourBrowser->new($self, $entries); + if ($dlg->ShowModal == wxID_OK) { + my $value = $dlg->GetValue . ":" . $dlg->GetPort; + $self->{config}->set('octoprint_host', $value); + $self->update_dirty; + $self->_on_value_change('octoprint_host', $value); + $self->reload_config; + } + } else { + Wx::MessageDialog->new($self, 'No Bonjour device found', 'Device Browser', wxOK | wxICON_INFORMATION)->ShowModal; } }); |