From 5102fa96876907adca3d0897d67108c60a2545b0 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 18 Nov 2015 16:23:21 +0100 Subject: [PATCH] Consolidate how to run the FLTK loop in one place --- vncviewer/CConn.cxx | 8 +------- vncviewer/vncviewer.cxx | 28 ++++++++++++++++------------ vncviewer/vncviewer.h | 1 + 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index 78eadb54..fb136b5f 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -228,13 +228,7 @@ const char *CConn::connectionInfo() void CConn::blockCallback() { - int next_timer; - - next_timer = Timer::checkTimeouts(); - if (next_timer == 0) - next_timer = INT_MAX; - - Fl::wait((double)next_timer / 1000.0); + run_mainloop(); if (should_exit()) throw rdr::Exception("Termination requested"); diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index a2bc0297..d71cb7f9 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -128,6 +128,20 @@ void about_vncviewer() 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 @@ int main(int argc, char** argv) 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; diff --git a/vncviewer/vncviewer.h b/vncviewer/vncviewer.h index 4d0566bb..c98c2e94 100644 --- a/vncviewer/vncviewer.h +++ b/vncviewer/vncviewer.h @@ -24,5 +24,6 @@ void exit_vncviewer(const char *error = NULL); bool should_exit(); void about_vncviewer(); +void run_mainloop(); #endif -- 2.39.5