Destroy the main UI and connection objects before popping up the fatal error
message. This avoids a lot of problems with recursion and trying to send
events over a dead socket.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4582 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index cfe5cfa..7b9434f 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -66,9 +66,15 @@
static char aboutText[1024];
static bool exitMainloop = false;
+static const char *exitError = NULL;
-void exit_vncviewer()
+void exit_vncviewer(const char *error)
{
+ // Prioritise the first error we get as that is probably the most
+ // relevant one.
+ if ((error != NULL) && (exitError == NULL))
+ exitError = strdup(error);
+
exitMainloop = true;
}
@@ -267,7 +273,7 @@
return 1;
}
- CConn cc(vncServerName);
+ CConn *cc = new CConn(vncServerName);
while (!exitMainloop) {
int next_timer;
@@ -282,5 +288,10 @@
}
}
+ delete cc;
+
+ if (exitError != NULL)
+ fl_alert(exitError);
+
return 0;
}