diff --git a/plugins/ticket/templates.cpp b/plugins/ticket/templates.cpp index 8348be2..ea3dca3 100755 --- a/plugins/ticket/templates.cpp +++ b/plugins/ticket/templates.cpp @@ -273,9 +273,18 @@ namespace ns_tickets_tab struct TicketsTabValue { - bool is_ticket; // true if there is a ticket + bool is_item; // true if there is an item (item pointer is valid) + bool is_ticket; // true if there is a ticket (ticket pointer is valid) + Item * item; // an item for that ticket (if is_item is true) Ticket * ticket; // pointer to the ticket (if is_ticket is true) - Item * item; // an item for that ticket (if is_ticket is true) + + /* + there can be two situations: + - is_item is false and is_ticket is false + - is_item is true and is_ticket is false + - is_item is true and is_ticket is true + so when is_ticket is true then is_item is true as well so you don't have to check it + */ TicketsTabValue() { @@ -284,6 +293,7 @@ struct TicketsTabValue void Clear() { + is_item = false; is_ticket = false; ticket = 0; item = 0; @@ -369,14 +379,15 @@ void tickets_tab(Info & i) if( i.res ) { + tickets_value.is_item = true; + tickets_value.item = ticket_info.item_sort_tab[item_sort_index]; + long file_id = ticket_info.item_sort_tab[item_sort_index]->id; size_t ticket_index; - long file_id = ticket_info.item_sort_tab[item_sort_index]->id; if( find_ticket(file_id, ticket_info.ticket_tab, ticket_index) ) { tickets_value.is_ticket = true; tickets_value.ticket = &ticket_info.ticket_tab[ticket_index]; - tickets_value.item = ticket_info.item_sort_tab[item_sort_index]; } plugin.Call(WINIX_PL_THREAD_SET_SORTTAB_INDEX, item_sort_index); @@ -388,7 +399,7 @@ void tickets_tab_url(Info & i) { tickets_tab_check_reqid(); - if( tickets_value.is_ticket ) + if( tickets_value.is_item ) i.out << tickets_value.item->url; } @@ -397,7 +408,7 @@ void tickets_tab_subject_empty(Info & i) { tickets_tab_check_reqid(); - if( tickets_value.is_ticket ) + if( tickets_value.is_item ) i.res = tickets_value.item->subject.empty(); } @@ -406,7 +417,7 @@ void tickets_tab_subject(Info & i) { tickets_tab_check_reqid(); - if( tickets_value.is_ticket ) + if( tickets_value.is_item ) i.out << tickets_value.item->subject; }