* fix precondition, which could cause a crash
[modest] / src / modest-ui-dimming-rules.c
index 3547a0a..a4c6df1 100644 (file)
@@ -34,6 +34,7 @@
 #include <string.h>
 #include "modest-ui-dimming-rules.h"
 #include "modest-dimming-rule.h"
+#include "modest-debug.h"
 #include "modest-tny-folder.h"
 #include "modest-tny-account.h"
 #include "modest-text-utils.h"
@@ -1808,7 +1809,7 @@ modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_dat
                        GtkClipboard *clipboard;
                        if (GTK_IS_HTML (focused)) {
                                const gchar *sel;
-                               guint len = -1;
+                               int len = -1;
                                sel = gtk_html_get_selection_html (GTK_HTML (focused), &len);
                                do_check = !((sel == NULL) || (sel[0] == '\0'));
                        }
@@ -2303,7 +2304,7 @@ _invalid_clipboard_selected (ModestWindow *win,
                result = !has_selection;
        } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
                if (focused) {
-                       g_message ("FOCUSED %s", g_type_name (G_TYPE_FROM_INSTANCE (focused)));
+                       MODEST_DEBUG_BLOCK (g_message ("FOCUSED %s", g_type_name (G_TYPE_FROM_INSTANCE (focused))););
                        if (GTK_IS_LABEL (focused) && 
                            !gtk_label_get_selection_bounds (GTK_LABEL (focused), NULL, NULL)) {
                                result = TRUE;
@@ -2313,10 +2314,12 @@ _invalid_clipboard_selected (ModestWindow *win,
                                result = !gtk_text_buffer_get_has_selection (buffer);
                        } else if (GTK_IS_HTML (focused)) {
                                const gchar *sel;
-                               guint len = -1;
+                               int len = -1;
                                sel = gtk_html_get_selection_html (GTK_HTML (focused), &len);
                                result = ((sel == NULL) || (sel[0] == '\0'));
-                       } else if (!MODEST_IS_ATTACHMENTS_VIEW (focused)) {
+                       } else if (MODEST_IS_ATTACHMENTS_VIEW (focused)) {
+                               result = TRUE;
+                       } else {
                                GtkClipboard *clipboard;
                                gchar *selection;