Skip to content

Commit

Permalink
Cancel file loading when closing tab (#637) (#644)
Browse files Browse the repository at this point in the history
new method _xed_tab_cancel_load is called in xed-notebook to prevent use of computer resources after closing xed or a xed tab
  • Loading branch information
BanceDev authored Jun 11, 2024
1 parent 2f5293b commit c3b7079
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xed/xed-notebook.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,12 @@ static void
remove_tab (XedTab *tab,
XedNotebook *nb)
{
/* First cancel any loading */
if (xed_tab_get_state (tab) == XED_TAB_STATE_LOADING)
{
_xed_tab_cancel_load (tab);
}

gint position;

position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
Expand Down
9 changes: 9 additions & 0 deletions xed/xed-tab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,15 @@ _xed_tab_load (XedTab *tab,
load (tab, encoding, line_pos);
}

void
_xed_tab_cancel_load (XedTab *tab)
{
g_return_if_fail (XED_IS_PROGRESS_INFO_BAR (tab->priv->info_bar));
g_return_if_fail (G_IS_CANCELLABLE (tab->priv->cancellable));

g_cancellable_cancel (tab->priv->cancellable);
}

void
_xed_tab_load_stream (XedTab *tab,
GInputStream *stream,
Expand Down
2 changes: 2 additions & 0 deletions xed/xed-tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ void _xed_tab_load (XedTab *tab,
gint line_pos,
gboolean create);

void _xed_tab_cancel_load (XedTab *tab);

void _xed_tab_load_stream (XedTab *tab,
GInputStream *location,
const GtkSourceEncoding *encoding,
Expand Down

0 comments on commit c3b7079

Please sign in to comment.