In trying to get Code::Blocks to build using wxWidgets 2.9, I updated the log methods to using wxString.
Here it is if anyone wants to look at it. Note, I also patched most of the log calls in C::B main project to use the new methods. It did nothing to fix the issues with wxWidgets 2.9, still crashes on exit.
Index: src/sdk/messagemanager.cpp
===================================================================
--- src/sdk/messagemanager.cpp (revision 4341)
+++ src/sdk/messagemanager.cpp (working copy)
@@ -267,6 +267,14 @@
m_Logs[m_AppLog]->log->AddLog(tmp);
}
+void MessageManager::DebugLog(const wxString& msg)
+{
+ wxDateTime timestamp = wxDateTime::UNow();
+ wxString ts;
+ ts.Printf(_T("%2.2d:%2.2d:%2.2d.%3.3d"), timestamp.GetHour(), timestamp.GetMinute(), timestamp.GetSecond(), timestamp.GetMillisecond());
+ m_Logs[m_DebugLog]->log->AddLog(_T("[") + ts + _T("]: ") + msg);
+}
+
void MessageManager::DebugLog(const wxChar* msg, ...)
{
if (!CheckLogId(m_DebugLog))
@@ -286,6 +294,27 @@
// m_Logs[mltDebug]->AddLog(tmp);
}
+void MessageManager::LogWarning(const wxString& msg)
+{
+ wxString typ = _("WARNING");
+// wxSafeShowMessage(typ, typ + _T(":\n\n") + msg);
+
+ if (CheckLogId(m_DebugLog))
+ {
+ ((SimpleTextLog*)m_Logs[m_DebugLog]->log)->GetTextControl()->SetDefaultStyle(wxTextAttr(*wxBLUE));
+ DebugLog(typ + _T(": ") + msg);
+ ((SimpleTextLog*)m_Logs[m_DebugLog]->log)->GetTextControl()->SetDefaultStyle(wxTextAttr(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)));
+ }
+ if (CheckLogId(m_AppLog))
+ {
+ ((SimpleTextLog*)m_Logs[m_AppLog]->log)->GetTextControl()->SetDefaultStyle(wxTextAttr(*wxBLUE));
+ Log(typ + _T(": ") + msg);
+ ((SimpleTextLog*)m_Logs[m_AppLog]->log)->GetTextControl()->SetDefaultStyle(wxTextAttr(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)));
+ }
+
+ m_HasWarnings = true;
+}
+
void MessageManager::LogWarning(const wxChar* msg, ...)
{
wxString tmp;
@@ -314,6 +343,27 @@
m_HasWarnings = true;
}
+void MessageManager::LogError(const wxString& msg)
+{
+ wxString typ = _("ERROR");
+// wxSafeShowMessage(typ, typ + _T(":\n\n") + msg);
+
+ if (CheckLogId(m_DebugLog))
+ {
+ ((SimpleTextLog*)m_Logs[m_DebugLog]->log)->GetTextControl()->SetDefaultStyle(wxTextAttr(*wxRED));
+ DebugLog(typ + _T(": ") + msg);
+ ((SimpleTextLog*)m_Logs[m_DebugLog]->log)->GetTextControl()->SetDefaultStyle(wxTextAttr(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)));
+ }
+ if (CheckLogId(m_AppLog))
+ {
+ ((SimpleTextLog*)m_Logs[m_AppLog]->log)->GetTextControl()->SetDefaultStyle(wxTextAttr(*wxRED));
+ Log(typ + _T(": ") + msg);
+ ((SimpleTextLog*)m_Logs[m_AppLog]->log)->GetTextControl()->SetDefaultStyle(wxTextAttr(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)));
+ }
+
+ m_HasErrors = true;
+}
+
void MessageManager::LogError(const wxChar* msg, ...)
{
wxString tmp;
@@ -498,6 +548,11 @@
}
}
+void MessageManager::AppendLog(const wxString& msg)
+{
+ m_Logs[m_AppLog]->log->AddLog(msg, false);
+}
+
void MessageManager::AppendLog(const wxChar* msg, ...)
{
wxString tmp;
@@ -510,6 +565,14 @@
m_Logs[m_AppLog]->log->AddLog(tmp, false);
}
+void MessageManager::AppendLog(int id, const wxString& msg)
+{
+ if (!CheckLogId(id))
+ return;
+
+ m_Logs[id]->log->AddLog(msg, false);
+}
+
void MessageManager::AppendLog(int id, const wxChar* msg, ...)
{
if (!CheckLogId(id))
Index: src/include/messagemanager.h
===================================================================
--- src/include/messagemanager.h (revision 4341)
+++ src/include/messagemanager.h (working copy)
@@ -158,6 +158,10 @@
/** @brief Log to the debug log.
* @param msg The message.
*/
+ void DebugLog(const wxString& msg);
+ /** @brief Log to the debug log (varargs version).
+ * @param msg The message.
+ */
void DebugLog(const wxChar* msg, ...);
/** @brief Log to the log with ID @c id.
* @param id The log's id.
@@ -172,11 +176,20 @@
/** @brief Append to the main log (no LF is automatically added).
* @param msg The message.
*/
+ void AppendLog(const wxString& msg);
+ /** @brief Append to the main log (no LF is automatically added) (varargs version).
+ * @param msg The message.
+ */
void AppendLog(const wxChar* msg, ...);
/** @brief Append to the log with ID @c id (no LF is automatically added).
* @param id The log's id.
* @param msg The message.
*/
+ void AppendLog(int id, const wxString& msg);
+ /** @brief Append to the log with ID @c id (no LF is automatically added) (varargs version).
+ * @param id The log's id.
+ * @param msg The message.
+ */
void AppendLog(int id, const wxChar* msg, ...);
/** @brief Log a warning.
*
@@ -184,12 +197,25 @@
* and is colored blue to stand out.
* @param msg The message.
*/
+ void LogWarning(const wxString& msg);
+ /** @brief Log a warning (varargs version).
+ *
+ * This is logged in the main log, as well as the debug log
+ * and is colored blue to stand out.
+ * @param msg The message.
+ */
void LogWarning(const wxChar* msg, ...);
/** @brief Log an error.
* This is logged in the main log, as well as the debug log
* and is colored red to stand out.
* @param msg The message.
*/
+ void LogError(const wxString& msg);
+ /** @brief Log an error (varargs version).
+ * This is logged in the main log, as well as the debug log
+ * and is colored red to stand out.
+ * @param msg The message.
+ */
void LogError(const wxChar* msg, ...);
/** @brief Switch to log with ID @c id.
* @param id The log's id.