X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/954f8d64fb6202884b4ad5c235af188e9a6622e4..09f84bc71682e86a035497694e3dda907ebe78b9:/src/generic/logg.cpp?ds=sidebyside diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index be7d63af69..a56044a05f 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -69,11 +69,7 @@ #include "wx/image.h" #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG -#if defined(__MWERKS__) && wxUSE_UNICODE - #include -#endif - -#include "wx/datetime.h" +#include "wx/time.h" // the suffix we add to the button to show that the dialog can be expanded #define EXPAND_SUFFIX wxT(" >>") @@ -90,7 +86,6 @@ // allows to exclude the usage of wxDateTime static wxString TimeStamp(const wxString& format, time_t t) { -#if wxUSE_DATETIME wxChar buf[4096]; struct tm tm; if ( !wxStrftime(buf, WXSIZEOF(buf), format, wxLocaltime_r(&t, &tm)) ) @@ -99,9 +94,6 @@ static wxString TimeStamp(const wxString& format, time_t t) wxFAIL_MSG(wxT("strftime() failed")); } return wxString(buf); -#else // !wxUSE_DATETIME - return wxEmptyString; -#endif // wxUSE_DATETIME/!wxUSE_DATETIME } @@ -380,7 +372,7 @@ void wxLogGui::DoLogRecord(wxLogLevel level, // find the top window and set it's status text if it has any if ( pFrame == NULL ) { wxWindow *pWin = wxTheApp->GetTopWindow(); - if ( pWin != NULL && pWin->IsKindOf(CLASSINFO(wxFrame)) ) { + if ( wxDynamicCast(pWin, wxFrame) ) { pFrame = (wxFrame *)pWin; } } @@ -417,10 +409,25 @@ void wxLogGui::DoLogRecord(wxLogLevel level, m_bHasMessages = true; break; - default: - // let the base class deal with debug/trace messages as well as any - // custom levels + case wxLOG_Debug: + case wxLOG_Trace: + // let the base class deal with debug/trace messages wxLog::DoLogRecord(level, msg, info); + break; + + case wxLOG_FatalError: + case wxLOG_Max: + // fatal errors are shown immediately and terminate the program so + // we should never see them here + wxFAIL_MSG("unexpected log level"); + break; + + case wxLOG_Progress: + case wxLOG_User: + // just ignore those: passing them to the base class would result + // in asserts from DoLogText() because DoLogTextAtLevel() would + // call it as it doesn't know how to handle these levels otherwise + break; } } @@ -441,6 +448,9 @@ public: wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxString& szTitle); virtual ~wxLogFrame(); + // Don't prevent the application from exiting if just this frame remains. + virtual bool ShouldPreventAppExit() const { return false; } + // menu callbacks void OnClose(wxCommandEvent& event); void OnCloseWindow(wxCloseEvent& event); @@ -506,7 +516,7 @@ wxLogFrame::wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxString& szTi wxMenuBar *pMenuBar = new wxMenuBar; wxMenu *pMenu = new wxMenu; #if CAN_SAVE_FILES - pMenu->Append(Menu_Save, _("&Save..."), _("Save log contents to file")); + pMenu->Append(Menu_Save, _("Save &As..."), _("Save log contents to file")); #endif // CAN_SAVE_FILES pMenu->Append(Menu_Clear, _("C&lear"), _("Clear the log contents")); pMenu->AppendSeparator(); @@ -595,6 +605,11 @@ wxLogWindow::wxLogWindow(wxWindow *pParent, bool bShow, bool bDoPass) { + // Initialize it to NULL to ensure that we don't crash if any log messages + // are generated before the frame is fully created (while this doesn't + // happen normally, it might, in principle). + m_pLogFrame = NULL; + PassMessages(bDoPass); m_pLogFrame = new wxLogFrame(pParent, this, szTitle); @@ -706,7 +721,7 @@ wxLogDialog::wxLogDialog(wxWindow *parent, bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); // create the controls which are always shown and layout them: we use - // sizers even though our window is not resizeable to calculate the size of + // sizers even though our window is not resizable to calculate the size of // the dialog properly wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); wxBoxSizer *sizerAll = new wxBoxSizer(isPda ? wxVERTICAL : wxHORIZONTAL); @@ -737,11 +752,17 @@ wxLogDialog::wxLogDialog(wxWindow *parent, // add the details pane #ifndef __SMARTPHONE__ + +#if wxUSE_COLLPANE wxCollapsiblePane * const collpane = new wxCollapsiblePane(this, wxID_ANY, ms_details); sizerTop->Add(collpane, wxSizerFlags(1).Expand().Border()); wxWindow *win = collpane->GetPane(); +#else + wxPanel* win = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxBORDER_NONE); +#endif wxSizer * const paneSz = new wxBoxSizer(wxVERTICAL); CreateDetailsControls(win); @@ -762,7 +783,7 @@ wxLogDialog::wxLogDialog(wxWindow *parent, btnSizer->Add(new wxButton(win, wxID_SAVE), flagsBtn); #endif // CAN_SAVE_FILES - paneSz->Add(btnSizer, wxSizerFlags().Right().Border(wxTOP)); + paneSz->Add(btnSizer, wxSizerFlags().Right().Border(wxTOP|wxBOTTOM)); #endif // wxUSE_CLIPBOARD || CAN_SAVE_FILES win->SetSizer(paneSz); @@ -814,7 +835,7 @@ void wxLogDialog::CreateDetailsControls(wxWindow *parent) wxImageList *imageList = new wxImageList(ICON_SIZE, ICON_SIZE); // order should be the same as in the switch below! - static const wxChar* const icons[] = + static const char* const icons[] = { wxART_ERROR, wxART_WARNING, @@ -830,7 +851,7 @@ void wxLogDialog::CreateDetailsControls(wxWindow *parent) // This may very well fail if there are insufficient colours available. // Degrade gracefully. - if ( !bmp.Ok() ) + if ( !bmp.IsOk() ) { loadedIcons = false;