On 07/31/2012 01:35 PM, Jakub Filak wrote:
Signed-off-by: Jakub Filak <[email protected]>
---
src/gui-gtk/main.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c
index 12b14e9..87c8205 100644
--- a/src/gui-gtk/main.c
+++ b/src/gui-gtk/main.c
@@ -153,6 +153,19 @@ static void watch_this_dir(const char *dir_name)
}
}
+/* Returns non 0 if str is NULL or if str consists from white spaces */
+static int is_null_or_mepty_string(const char *str)
+{
+ if (!str)
+ return 1;
+
+ while(*str)
- this ^^^^^^^^^^^ is dangerous
+ if (!isspace(*str++))
+ return 0;
+
+ return 1;
+}
+
static void add_directory_to_dirlist(const char *problem_dir_path, gpointer
data)
{
bool use_dbus = (bool)data;
@@ -192,15 +205,25 @@ static void add_directory_to_dirlist(const char
*problem_dir_path, gpointer data
time_buf[time_len] = '\0';
}
- const char *not_reportable_reason = problem_data_get_content_or_NULL(pd,
FILENAME_NOT_REPORTABLE);
- const char *reason = problem_data_get_content_or_NULL(pd, FILENAME_REASON);
+ const char *reason = problem_data_get_content_or_NULL(pd,
FILENAME_NOT_REPORTABLE);
+ if (is_null_or_mepty_string(reason)) /* if problem is NOT not reportable
we use reason */
+ {
+ reason = problem_data_get_content_or_NULL(pd, FILENAME_REASON);
+ if (is_null_or_mepty_string(reason)) /* if we don't have reason we use
'N/A' */
+ reason = "N/A";
+ }
/* the source of the problem:
* - first we try to load component, as we use it on Fedora
*/
const char *source = problem_data_get_content_or_NULL(pd,
FILENAME_COMPONENT);
- if (!source) /* if we don't have component, we fallback to executable */
+ if (is_null_or_mepty_string(source)) /* if we don't have component, we
fallback to executable */
+ {
source = problem_data_get_content_or_NULL(pd, FILENAME_EXECUTABLE);
+ if (is_null_or_mepty_string(source)) /* even if we don't have
executable, we use 'N/A' */
+ source = "N/A";
+ }
+
const char *msg = problem_data_get_content_or_NULL(pd,
FILENAME_REPORTED_TO);
GtkListStore *list_store = s_dumps_list_store;
@@ -215,7 +238,7 @@ static void add_directory_to_dirlist(const char
*problem_dir_path, gpointer data
gtk_list_store_append(list_store, &iter);
gtk_list_store_set(list_store, &iter,
COLUMN_SOURCE, source,
- COLUMN_REASON, not_reportable_reason ? : reason,
+ COLUMN_REASON, reason,
//OPTION: time format
COLUMN_LATEST_CRASH_STR, time_buf,
COLUMN_LATEST_CRASH, t,
- the "N/A" should appear in all columns where we don't have text to show