From e9c956d23c8bf59e4ef9cebe4d39b753c62a7ae9 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 26 Apr 2004 20:07:33 +0000 Subject: [PATCH] Corrected a bug in Windows which causes wx-console to crash when typing quit before exiting the application. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1309 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/CHANGELOG | 12 ++++++++---- bacula/src/wx-console/TODO | 8 ++++++-- bacula/src/wx-console/console_thread.cpp | 12 ++++++++++-- bacula/src/wx-console/csprint.h | 1 + bacula/src/wx-console/wxbmainframe.cpp | 9 ++++++++- bacula/src/wx-console/wxbmainframe.h | 4 ++-- 6 files changed, 35 insertions(+), 11 deletions(-) diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index dc3c35c7ef..b972d01d2a 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -1,4 +1,8 @@ -25-04-2003 : +26-04-2004 : + - Corrected a bug in Windows which causes wx-console to crash when + typing quit before exiting the application. + +25-04-2004 : - general : status text is more often used - wxbRestorePanel : restore aborted if there's no client or no fileset - wxbRestorePanel : corrected problem if one double clicks on a @@ -13,7 +17,7 @@ - wxbMainFrame : Automatically scrolling to the bottom of console text control. -24-04-2003 : +24-04-2004 : - wxbMainFrame : When starting wx-console, the initial key input focus is set into the command window. - wxbMainFrame : the user is now prompted when an @@ -22,11 +26,11 @@ - wxbRestorePanel : using dot commands (.clients, .filesets) - console_thread : implemented prompt and heartbeat messages -23-04-2003 : +23-04-2004 : - general : Don't concatenate lines in csprint, but in wxbDataParser (necessary for dot commands) -22-04-2003 : +22-04-2004 : - wxbRestorePanel : improved restore appearance - wxbRestorePanel : configure is allowed to change client diff --git a/bacula/src/wx-console/TODO b/bacula/src/wx-console/TODO index d56fd38159..ffd5c4b8de 100644 --- a/bacula/src/wx-console/TODO +++ b/bacula/src/wx-console/TODO @@ -18,8 +18,8 @@ wxbRestorePanel : Add a Cancel Restore button general : Allow the user to quit however the state is (kill thread if necessary) -VC++ : crashing when there's no configuration file, or server is unreachable - (on every error ?) +VC++ : crashing when there's no configuration file, when server is unreachable, + when connection has been interrupted and wants to quit (on every error ?) [postponed to July:] @@ -83,6 +83,10 @@ wxbRestorePanel : Check more carefully which job we just have run wxbRestorePanel : Add a timeout when waiting for commands results +bacula-dir : correct director to handle correctly + marked status + (In fact there is a bug in the director : If you mark a directory + (not a file), and then unmark it, its parents keep the "+" status.) + general : make a good documentation with snapshots BUGS diff --git a/bacula/src/wx-console/console_thread.cpp b/bacula/src/wx-console/console_thread.cpp index 3e59546983..ede22cd565 100644 --- a/bacula/src/wx-console/console_thread.cpp +++ b/bacula/src/wx-console/console_thread.cpp @@ -80,7 +80,7 @@ void* console_thread::Entry() { init_stack_dump(); my_name_is(0, NULL, "wx-console"); - textdomain("bacula-console"); + //textdomain("bacula-console"); init_msg(NULL, NULL); /* TODO (#4#): Allow the user to choose his config file. */ @@ -99,6 +99,8 @@ void* console_thread::Entry() { csprint("Failed to connect to the director\n"); csprint(NULL, CS_END); csprint(NULL, CS_DISCONNECTED); + csprint(NULL, CS_TERMINATED); + Exit(); return NULL; } @@ -110,6 +112,8 @@ void* console_thread::Entry() { csprint(UA_sock->msg); csprint(NULL, CS_END); csprint(NULL, CS_DISCONNECTED); + csprint(NULL, CS_TERMINATED); + Exit(); return NULL; } @@ -157,8 +161,12 @@ void* console_thread::Entry() { csprint("Connection terminated\n"); UA_sock = NULL; + + csprint(NULL, CS_TERMINATED); + + Exit(); - return 0; + return NULL; } void console_thread::Write(const char* str) { diff --git a/bacula/src/wx-console/csprint.h b/bacula/src/wx-console/csprint.h index 6f76255754..e4777a32ee 100644 --- a/bacula/src/wx-console/csprint.h +++ b/bacula/src/wx-console/csprint.h @@ -32,6 +32,7 @@ #define CS_CONNECTED 4 /* the socket is now connected */ #define CS_DISCONNECTED 5 /* the socket is now disconnected */ #define CS_DEBUG 10 /* used to print debug messages */ +#define CS_TERMINATED 99 /* used to signal that the thread is terminated */ /* function called by console_thread to send events back to the GUI */ void csprint(char* str, int status=CS_DATA); diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index d557cc709f..520b916797 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -164,7 +164,7 @@ wxbMainFrame* wxbMainFrame::GetInstance() */ wxbMainFrame::~wxbMainFrame() { - if ((ct != NULL) && (!ct->IsRunning())) { + if (ct != NULL) { // && (!ct->IsRunning()) ct->Delete(); } } @@ -325,6 +325,13 @@ void wxbMainFrame::OnPrint(wxbThreadEvent& event) { */ void wxbMainFrame::Print(wxString str, int status) { + if (status == CS_TERMINATED) { + SetStatusText("Console thread terminated."); + ct = NULL; + DisablePanels(); + return; + } + if (status == CS_CONNECTED) { SetStatusText("Connected to the director."); EnablePanels(); diff --git a/bacula/src/wx-console/wxbmainframe.h b/bacula/src/wx-console/wxbmainframe.h index a22c8cd18b..34c41f0063 100644 --- a/bacula/src/wx-console/wxbmainframe.h +++ b/bacula/src/wx-console/wxbmainframe.h @@ -123,6 +123,8 @@ public: /* Unregister a wxbDataParser */ void Unregister(wxbDataParser* dp); + console_thread* ct; /* thread interacting with the director */ + private: /* private constructor, singleton */ wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style); @@ -135,8 +137,6 @@ private: wxbPanel **panels; /* panels array, contained in the notebook */ wxbDataParsers parsers; /* Data parsers, which need to receive director informations */ - console_thread* ct; /* thread interacting with the director */ - wxbPromptParser* promptparser; /* prompt parser catching uncatched questions */ static wxbMainFrame *frame; /* this */ -- 2.39.5