struct MuttThread *thread = NULL, *top = NULL;
int final;
- if (!Context || (Context->mailbox->msg_count == 0))
+ if (!Context || !Context->mailbox || (Context->mailbox->msg_count == 0))
return;
/* Figure out what the current message would be after folding / unfolding,
*/
static int ci_next_undeleted(int msgno)
{
+ if (!Context || !Context->mailbox)
+ return -1;
+
for (int i = msgno + 1; i < Context->mailbox->vcount; i++)
if (!Context->mailbox->emails[Context->mailbox->v2r[i]]->deleted)
return i;
*/
static int ci_previous_undeleted(int msgno)
{
+ if (!Context || !Context->mailbox)
+ return -1;
+
for (int i = msgno - 1; i >= 0; i--)
if (!Context->mailbox->emails[Context->mailbox->v2r[i]]->deleted)
return i;
*/
static int ci_first_message(void)
{
- if (!Context || (Context->mailbox->msg_count == 0))
+ if (!Context || !Context->mailbox || (Context->mailbox->msg_count == 0))
return 0;
int old = -1;
*/
static void resort_index(struct Menu *menu)
{
+ if (!Context || !Context->mailbox)
+ return;
+
struct Email *e = CUR_EMAIL;
menu->current = -1;
}
/* keepalive failure in mutt_enter_fname may kill connection. #3028 */
- if (Context && (mutt_buffer_is_empty(Context->mailbox->pathbuf)))
+ if (Context && Context->mailbox && (mutt_buffer_is_empty(Context->mailbox->pathbuf)))
ctx_free(&Context);
- if (Context)
+ if (Context && Context->mailbox)
{
char *new_last_folder = NULL;
#ifdef USE_INOTIFY
*/
void index_make_entry(char *buf, size_t buflen, struct Menu *menu, int line)
{
- if (!Context || !menu || (line < 0) || (line >= Context->mailbox->email_max))
+ if (!Context || !Context->mailbox || !menu || (line < 0) ||
+ (line >= Context->mailbox->email_max))
return;
struct Email *e = Context->mailbox->emails[Context->mailbox->v2r[line]];
*/
int index_color(int line)
{
- if (!Context || (line < 0))
+ if (!Context || !Context->mailbox || (line < 0))
return 0;
struct Email *e = Context->mailbox->emails[Context->mailbox->v2r[line]];
menu_redraw_sidebar(menu);
#endif
- if (Context && Context->mailbox->emails && !(menu->current >= Context->mailbox->vcount))
+ if (Context && Context->mailbox && Context->mailbox->emails &&
+ !(menu->current >= Context->mailbox->vcount))
{
menu_check_recenter(menu);
menu->menu_make_entry = index_make_entry;
menu->menu_color = index_color;
menu->current = ci_first_message();
- menu->help = mutt_compile_help(helpstr, sizeof(helpstr), MENU_MAIN,
+ menu->help = mutt_compile_help(
+ helpstr, sizeof(helpstr), MENU_MAIN,
#ifdef USE_NNTP
- (Context && (Context->mailbox->magic == MUTT_NNTP)) ?
- IndexNewsHelp :
+ (Context && Context->mailbox && (Context->mailbox->magic == MUTT_NNTP)) ?
+ IndexNewsHelp :
#endif
- IndexHelp);
+ IndexHelp);
menu->menu_custom_redraw = index_custom_redraw;
mutt_menu_push_current(menu);
mutt_window_reflow();
/* check if we need to resort the index because just about
* any 'op' below could do mutt_enter_command(), either here or
* from any new menu launched, and change $sort/$sort_aux */
- if (OptNeedResort && Context && (Context->mailbox->msg_count != 0) &&
- (menu->current >= 0))
+ if (OptNeedResort && Context && Context->mailbox &&
+ (Context->mailbox->msg_count != 0) && (menu->current >= 0))
resort_index(menu);
- menu->max = Context ? Context->mailbox->vcount : 0;
- oldcount = Context ? Context->mailbox->msg_count : 0;
+ menu->max = (Context && Context->mailbox) ? Context->mailbox->vcount : 0;
+ oldcount = (Context && Context->mailbox) ? Context->mailbox->msg_count : 0;
- if (OptRedrawTree && Context && (Context->mailbox->msg_count != 0) &&
- ((C_Sort & SORT_MASK) == SORT_THREADS))
+ if (OptRedrawTree && Context && Context->mailbox &&
+ (Context->mailbox->msg_count != 0) && ((C_Sort & SORT_MASK) == SORT_THREADS))
{
mutt_draw_tree(Context);
menu->redraw |= REDRAW_STATUS;
if (Context)
Context->menu = menu;
- if (Context && !attach_msg)
+ if (Context && Context->mailbox && !attach_msg)
{
int check;
/* check for new mail in the mailbox. If nonzero, then something has
{
int check;
- oldcount = Context ? Context->mailbox->msg_count : 0;
+ oldcount = (Context && Context->mailbox) ? Context->mailbox->msg_count : 0;
mutt_startup_shutdown_hook(MUTT_SHUTDOWN_HOOK);
notify_send(NeoMutt->notify, NT_GLOBAL, NT_GLOBAL_SHUTDOWN, 0);
case OP_SORT_REVERSE:
if (mutt_select_sort((op == OP_SORT_REVERSE)) == 0)
{
- if (Context && (Context->mailbox->msg_count != 0))
+ if (Context && Context->mailbox && (Context->mailbox->msg_count != 0))
{
resort_index(menu);
OptSearchInvalid = true;
#ifdef USE_IMAP
case OP_MAIN_IMAP_FETCH:
- if (Context && (Context->mailbox->magic == MUTT_IMAP))
+ if (Context && Context->mailbox && (Context->mailbox->magic == MUTT_IMAP))
imap_check_mailbox(Context->mailbox, true);
break;
case OP_MAIN_IMAP_LOGOUT_ALL:
- if (Context && (Context->mailbox->magic == MUTT_IMAP))
+ if (Context && Context->mailbox && (Context->mailbox->magic == MUTT_IMAP))
{
int check = mx_mbox_close(&Context);
if (check != 0)
#endif
case OP_MAIN_SYNC_FOLDER:
- if (Context && (Context->mailbox->msg_count == 0))
+ if (!Context || !Context->mailbox || (Context->mailbox->msg_count == 0))
break;
if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_READONLY))
case OP_MAIN_MODIFY_TAGS:
case OP_MAIN_MODIFY_TAGS_THEN_HIDE:
{
- if (!Context || !mx_tags_is_supported(Context->mailbox))
+ if (!Context || !Context->mailbox)
+ break;
+ if (!mx_tags_is_supported(Context->mailbox))
{
mutt_message(_("Folder doesn't support tagging, aborting"));
break;
cp = _("Open mailbox");
if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context &&
- !mutt_buffer_is_empty(Context->mailbox->pathbuf))
+ Context->mailbox && !mutt_buffer_is_empty(Context->mailbox->pathbuf))
{
mutt_buffer_strcpy(folderbuf, mutt_b2s(Context->mailbox->pathbuf));
mutt_buffer_pretty_mailbox(folderbuf);
#endif
else
{
- if (C_ChangeFolderNext && Context &&
+ if (C_ChangeFolderNext && Context && Context->mailbox &&
mutt_buffer_is_empty(Context->mailbox->pathbuf))
{
mutt_buffer_strcpy(folderbuf, mutt_b2s(Context->mailbox->pathbuf));
&oldcount, &index_hint);
#ifdef USE_NNTP
/* mutt_mailbox_check() must be done with mail-reader mode! */
- menu->help = mutt_compile_help(
- helpstr, sizeof(helpstr), MENU_MAIN,
- (Context && (Context->mailbox->magic == MUTT_NNTP)) ? IndexNewsHelp : IndexHelp);
+ menu->help = mutt_compile_help(helpstr, sizeof(helpstr), MENU_MAIN,
+ (Context && Context->mailbox &&
+ (Context->mailbox->magic == MUTT_NNTP)) ?
+ IndexNewsHelp :
+ IndexHelp);
#endif
mutt_buffer_expand_path(folderbuf);
#ifdef USE_SIDEBAR
}
case OP_CREATE_ALIAS:
- mutt_alias_create(Context && Context->mailbox->vcount ? CUR_EMAIL->env : NULL, NULL);
+ mutt_alias_create(Context && Context->mailbox && Context->mailbox->vcount ?
+ CUR_EMAIL->env :
+ NULL,
+ NULL);
menu->redraw |= REDRAW_CURRENT;
break;
/* fallthrough */
case OP_POST:
- if (!prereq(Context, menu, CHECK_ATTACH))
+ if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_ATTACH))
break;
if ((op != OP_FOLLOWUP) || !CUR_EMAIL->env->followup_to ||
(mutt_str_strcasecmp(CUR_EMAIL->env->followup_to, "poster") != 0) ||
if (mutt_str_strcmp(ec->name, "reply_regex") != 0)
return 0;
- if (!Context)
+ if (!Context || !Context->mailbox)
return 0;
regmatch_t pmatch[1];