Consolidate how to run the FLTK loop in one place
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index a2bc029..d71cb7f 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -128,6 +128,20 @@
fl_message("%s", about_text());
}
+void run_mainloop()
+{
+ int next_timer;
+
+ next_timer = Timer::checkTimeouts();
+ if (next_timer == 0)
+ next_timer = INT_MAX;
+
+ if (Fl::wait((double)next_timer / 1000.0) < 0.0) {
+ vlog.error(_("Internal FLTK error. Exiting."));
+ exit(-1);
+ }
+}
+
#ifdef __APPLE__
static void about_callback(Fl_Widget *widget, void *data)
{
@@ -590,18 +604,8 @@
CConn *cc = new CConn(vncServerName, sock);
- while (!exitMainloop) {
- int next_timer;
-
- next_timer = Timer::checkTimeouts();
- if (next_timer == 0)
- next_timer = INT_MAX;
-
- if (Fl::wait((double)next_timer / 1000.0) < 0.0) {
- vlog.error(_("Internal FLTK error. Exiting."));
- break;
- }
- }
+ while (!exitMainloop)
+ run_mainloop();
delete cc;