Skip to content

Commit c3b7079

Browse files
authored
Cancel file loading when closing tab (#637) (#644)
new method _xed_tab_cancel_load is called in xed-notebook to prevent use of computer resources after closing xed or a xed tab
1 parent 2f5293b commit c3b7079

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

xed/xed-notebook.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,12 @@ static void
902902
remove_tab (XedTab *tab,
903903
XedNotebook *nb)
904904
{
905+
/* First cancel any loading */
906+
if (xed_tab_get_state (tab) == XED_TAB_STATE_LOADING)
907+
{
908+
_xed_tab_cancel_load (tab);
909+
}
910+
905911
gint position;
906912

907913
position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));

xed/xed-tab.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,15 @@ _xed_tab_load (XedTab *tab,
19941994
load (tab, encoding, line_pos);
19951995
}
19961996

1997+
void
1998+
_xed_tab_cancel_load (XedTab *tab)
1999+
{
2000+
g_return_if_fail (XED_IS_PROGRESS_INFO_BAR (tab->priv->info_bar));
2001+
g_return_if_fail (G_IS_CANCELLABLE (tab->priv->cancellable));
2002+
2003+
g_cancellable_cancel (tab->priv->cancellable);
2004+
}
2005+
19972006
void
19982007
_xed_tab_load_stream (XedTab *tab,
19992008
GInputStream *stream,

xed/xed-tab.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ void _xed_tab_load (XedTab *tab,
129129
gint line_pos,
130130
gboolean create);
131131

132+
void _xed_tab_cancel_load (XedTab *tab);
133+
132134
void _xed_tab_load_stream (XedTab *tab,
133135
GInputStream *location,
134136
const GtkSourceEncoding *encoding,

0 commit comments

Comments
 (0)