Permalink
Browse files

fix #43 limit port number in preferences

  • Loading branch information...
tka committed Dec 26, 2011
1 parent 7fb768c commit 86163018d4da6a6868fbff5bc407b2ac9abaf303
Showing with 25 additions and 15 deletions.
  1. +25 −15 src/ui/preference_panel.rb
View
@@ -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

0 comments on commit 8616301

Please sign in to comment.