Skip to content

Commit

Permalink
fix #43 limit port number in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
tka committed Dec 26, 2011
1 parent 7fb768c commit 8616301
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/ui/preference_panel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,34 @@ def services_port_handler
Swt::Widgets::Listener.impl do |method, evt|
has_change = false
port = @http_port_text.getText.to_i
port = port.to_i > 0 ? port.to_i : App::CONFIG['services_http_port']
if App::CONFIG['services_http_port'] != port
App::CONFIG['services_http_port'] = port
@http_port_text.setText(App::CONFIG['services_http_port'].to_s)
has_change = true
port = port.to_i
if port < 0 || port > 65535
App.alert("http port number should be intergers between 0 and 65535")
else

if App::CONFIG['services_http_port'] != port
App::CONFIG['services_http_port'] = port
@http_port_text.setText(App::CONFIG['services_http_port'].to_s)
has_change = true
end
end

port = @livereload_port_text.getText.to_i
port = port.to_i > 0 ? port.to_i : App::CONFIG['services_livereload_port']
if App::CONFIG['services_livereload_port'] != port
App::CONFIG['services_livereload_port'] = port
@livereload_port_text.setText(App::CONFIG['services_livereload_port'].to_s)
has_change = true
end
port = port.to_i
if port < 0 || port > 65535
App.alert("livereload port number should be intergers between 0 and 65535")
else

if App::CONFIG['services_livereload_port'] != port
App::CONFIG['services_livereload_port'] = port
@livereload_port_text.setText(App::CONFIG['services_livereload_port'].to_s)
has_change = true
end

if has_change
App.save_config
Tray.instance.rewatch
if has_change
App.save_config
Tray.instance.rewatch
end
end
end
end
Expand Down

0 comments on commit 8616301

Please sign in to comment.