From d5d305193ce527f1cc3022c406de35d9a85d4ccb Mon Sep 17 00:00:00 2001 From: hrxi Date: Sun, 1 Sep 2019 18:18:25 +0200 Subject: Fix some warnings Instances of `RegexError` are just asserted as `assert_not_reached` as they cannot really fail except for allocation failure if the given regex is valid. --- main/src/ui/global_search.vala | 44 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'main/src/ui/global_search.vala') diff --git a/main/src/ui/global_search.vala b/main/src/ui/global_search.vala index 73a61dc5..db7dbc0f 100644 --- a/main/src/ui/global_search.vala +++ b/main/src/ui/global_search.vala @@ -206,27 +206,31 @@ public class GlobalSearch : Overlay { // Color the keywords int elongated_by = 0; - Regex highlight_regex = new Regex(regex_str); - MatchInfo match_info; - string markup_text_bak = markup_text.down(); - highlight_regex.match(markup_text_bak, 0, out match_info); - for (; match_info.matches(); match_info.next()) { - int start, end; - match_info.fetch_pos(0, out start, out end); - markup_text = markup_text[0:start+elongated_by] + "" + markup_text[start+elongated_by:end+elongated_by] + "" + markup_text[end+elongated_by:markup_text.length]; - elongated_by += "".length + "".length; + try { + Regex highlight_regex = new Regex(regex_str); + MatchInfo match_info; + string markup_text_bak = markup_text.down(); + highlight_regex.match(markup_text_bak, 0, out match_info); + for (; match_info.matches(); match_info.next()) { + int start, end; + match_info.fetch_pos(0, out start, out end); + markup_text = markup_text[0:start+elongated_by] + "" + markup_text[start+elongated_by:end+elongated_by] + "" + markup_text[end+elongated_by:markup_text.length]; + elongated_by += "".length + "".length; + } + markup_text_bak += ""; // We need markup_text_bak to live until here because url_regex.match does not copy the string + + label.label = markup_text; + grid.attach(label, 1, 1, 1, 1); + + Button button = new Button() { relief=ReliefStyle.NONE, visible=true }; + button.clicked.connect(() => { + selected_item(item); + }); + button.add(grid); + return button; + } catch (RegexError e) { + assert_not_reached(); } - markup_text_bak += ""; // We need markup_text_bak to live until here because url_regex.match does not copy the string - - label.label = markup_text; - grid.attach(label, 1, 1, 1, 1); - - Button button = new Button() { relief=ReliefStyle.NONE, visible=true }; - button.clicked.connect(() => { - selected_item(item); - }); - button.add(grid); - return button; } private Grid get_context_message_widget(MessageItem item) { -- cgit v1.2.3-54-g00ecf