From 8d241dea5c18414ec92776044feda4c909ec5007 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 21 Mar 2012 00:11:12 +0000 Subject: [PATCH] Fix display of "const" methods in wxGTK assert dialog. Don't separate the function name and its arguments types in 2 different columns in the assert dialog, this doesn't really work with const methods as "const" can't be separated from the function like this. The old code just didn't take "const" into account at all and mangled all the const methods by showing ") cons" (no typo) at the end. Just show everything in one column to avoid the problem and also simplify the code. Closes #14104. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70954 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/gtk/assertdlg_gtk.h | 1 - src/gtk/assertdlg_gtk.cpp | 29 +++++++++++------------------ src/gtk/utilsgtk.cpp | 14 -------------- 4 files changed, 12 insertions(+), 33 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 819d20a225..4f65b5b05c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -501,6 +501,7 @@ GTK: - Implement support for wxBG_STYLE_TRANSPARENT (Armel Asselin). - Fix wxNotebook best size calculation. - Implement wxDirDialog::Create() and wxFileDialog::Create() (vinayakgarg). +- Fix const methods display in assert dialog (vinayakgarg). MSW: diff --git a/include/wx/gtk/assertdlg_gtk.h b/include/wx/gtk/assertdlg_gtk.h index 4842c7c202..2e1a7a800a 100644 --- a/include/wx/gtk/assertdlg_gtk.h +++ b/include/wx/gtk/assertdlg_gtk.h @@ -72,7 +72,6 @@ void gtk_assert_dialog_set_backtrace_callback(GtkAssertDialog *assertdlg, /* appends a stack frame to the dialog */ void gtk_assert_dialog_append_stack_frame(GtkAssertDialog *dlg, const gchar *function, - const gchar *arguments, const gchar *sourcefile, guint line_number); diff --git a/src/gtk/assertdlg_gtk.cpp b/src/gtk/assertdlg_gtk.cpp index 4df435b37e..2a80149a77 100644 --- a/src/gtk/assertdlg_gtk.cpp +++ b/src/gtk/assertdlg_gtk.cpp @@ -23,10 +23,9 @@ in gtk_assert_dialog_create_backtrace_list_model() function */ #define STACKFRAME_LEVEL_COLIDX 0 -#define FUNCTION_NAME_COLIDX 1 +#define FUNCTION_PROTOTYPE_COLIDX 1 #define SOURCE_FILE_COLIDX 2 #define LINE_NUMBER_COLIDX 3 -#define FUNCTION_ARGS_COLIDX 4 @@ -86,12 +85,11 @@ GtkWidget *gtk_assert_dialog_create_backtrace_list_model () GtkWidget *treeview; /* create list store */ - store = gtk_list_store_new (5, + store = gtk_list_store_new (4, G_TYPE_UINT, /* stack frame number */ - G_TYPE_STRING, /* function name */ + G_TYPE_STRING, /* function prototype */ G_TYPE_STRING, /* source file name */ - G_TYPE_STRING, /* line number */ - G_TYPE_STRING); /* function arguments */ + G_TYPE_STRING); /* line number */ /* create the tree view */ treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store)); @@ -100,8 +98,7 @@ GtkWidget *gtk_assert_dialog_create_backtrace_list_model () /* append columns */ gtk_assert_dialog_append_text_column(treeview, "#", STACKFRAME_LEVEL_COLIDX); - gtk_assert_dialog_append_text_column(treeview, "Function name", FUNCTION_NAME_COLIDX); - gtk_assert_dialog_append_text_column(treeview, "Function args", FUNCTION_ARGS_COLIDX); + gtk_assert_dialog_append_text_column(treeview, "Function Prototype", FUNCTION_PROTOTYPE_COLIDX); gtk_assert_dialog_append_text_column(treeview, "Source file", SOURCE_FILE_COLIDX); gtk_assert_dialog_append_text_column(treeview, "Line #", LINE_NUMBER_COLIDX); @@ -381,7 +378,7 @@ gchar *gtk_assert_dialog_get_message (GtkAssertDialog *dlg) gchar *gtk_assert_dialog_get_backtrace (GtkAssertDialog *dlg) { - gchar *function, *arguments, *sourcefile, *linenum; + gchar *function, *sourcefile, *linenum; guint count; GtkTreeModel *model; @@ -399,16 +396,15 @@ gchar *gtk_assert_dialog_get_backtrace (GtkAssertDialog *dlg) do { /* append this stack frame's info to the string */ - gtk_tree_model_get (model, &iter, + gtk_tree_model_get(model, &iter, STACKFRAME_LEVEL_COLIDX, &count, - FUNCTION_NAME_COLIDX, &function, - FUNCTION_ARGS_COLIDX, &arguments, + FUNCTION_PROTOTYPE_COLIDX, &function, SOURCE_FILE_COLIDX, &sourcefile, LINE_NUMBER_COLIDX, &linenum, -1); - g_string_append_printf (string, "[%u] %s(%s)", - count, function, arguments); + g_string_append_printf(string, "[%u] %s", + count, function); if (sourcefile[0] != '\0') g_string_append_printf (string, " %s", sourcefile); if (linenum[0] != '\0') @@ -416,7 +412,6 @@ gchar *gtk_assert_dialog_get_backtrace (GtkAssertDialog *dlg) g_string_append (string, "\n"); g_free (function); - g_free (arguments); g_free (sourcefile); g_free (linenum); @@ -451,7 +446,6 @@ void gtk_assert_dialog_set_backtrace_callback(GtkAssertDialog *assertdlg, void gtk_assert_dialog_append_stack_frame(GtkAssertDialog *dlg, const gchar *function, - const gchar *arguments, const gchar *sourcefile, guint line_number) { @@ -474,8 +468,7 @@ void gtk_assert_dialog_append_stack_frame(GtkAssertDialog *dlg, gtk_list_store_append (GTK_LIST_STORE(model), &iter); gtk_list_store_set (GTK_LIST_STORE(model), &iter, STACKFRAME_LEVEL_COLIDX, count+1, /* start from 1 and not from 0 */ - FUNCTION_NAME_COLIDX, function, - FUNCTION_ARGS_COLIDX, arguments, + FUNCTION_PROTOTYPE_COLIDX, function, SOURCE_FILE_COLIDX, sourcefile, LINE_NUMBER_COLIDX, linenum->str, -1); diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index 0d1add821a..fefda2bd80 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -304,25 +304,11 @@ protected: virtual void OnStackFrame(const wxStackFrame& frame) { wxString fncname = frame.GetName(); - wxString fncargs = fncname; - - size_t n = fncname.find(wxT('(')); - if (n != wxString::npos) - { - // remove arguments from function name - fncname.erase(n); - - // remove function name and brackets from arguments - fncargs = fncargs.substr(n+1, fncargs.length()-n-2); - } - else - fncargs = wxEmptyString; // append this stack frame's info in the dialog if (!frame.GetFileName().empty() || !fncname.empty()) gtk_assert_dialog_append_stack_frame(m_dlg, fncname.mb_str(), - fncargs.mb_str(), frame.GetFileName().mb_str(), frame.GetLine()); } -- 2.45.2