Skip to content

Commit

Permalink
list view: Don't remove the dummy (Loading) entry except during
Browse files Browse the repository at this point in the history
post-loading updates.

When expanding a directory row, the directory is re-checked, to
determine whether there are actually any children to add to the
model. This calls the model's file-changed handler, which could
remove the existing dummy row in the process, causing the model
to become corrupted.

Avoid removing this dummy row while expanding the parent, regardless
of whether or not the parent has any actual children.  If it turns
out there are no longer children to load, show the traditional
"Empty" row.

Fixes #2256

Note: This prevents the crash, but does not fix the behavior of
the parent folder not knowing it has gained or lost it's only child.
This is a limitation due to the fact that the currently visible
tree items are only monitored as 'files', not folders - folders get
an initial count when loading the view, allowing the expander to
be added (or not).  This is pre-existing behavior.  It may or may
not be possible to change this in the future.
  • Loading branch information
mtwebster committed Dec 11, 2019
1 parent 0599ae2 commit 9085829
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/nemo-list-model.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct FileEntry {
GSequence *files;
GSequenceIter *ptr;
guint loaded : 1;
guint expanding : 1;
};

G_DEFINE_TYPE_WITH_CODE (NemoListModel, nemo_list_model, G_TYPE_OBJECT,
Expand Down Expand Up @@ -1078,13 +1079,18 @@ update_dummy_row (NemoListModel *model,
FileEntry *dummy_entry = g_sequence_get (dummy_ptr);

if (dummy_entry->file == NULL) {
model->details->stamp++;
g_sequence_remove (dummy_ptr);
changed = TRUE;
if (!file_entry->expanding) {

model->details->stamp++;
g_sequence_remove (dummy_ptr);
changed = TRUE;
}
}
}
}

file_entry->expanding = FALSE;

return changed;
}

Expand Down Expand Up @@ -1802,3 +1808,25 @@ nemo_list_model_get_temporarily_disable_sort (NemoListModel *model)
{
return model->details->temp_unsorted;
}

void
nemo_list_model_set_expanding (NemoListModel *model, NemoDirectory *directory)
{
FileEntry *entry;
GSequenceIter *ptr;

ptr = NULL;

if (directory) {
ptr = g_hash_table_lookup (model->details->directory_reverse_map,
directory);
}

if (!ptr) {
g_warning ("nemo_list_model_set_expanding: No pointer found, something's wrong?");
return;
}

entry = g_sequence_get (ptr);
entry->expanding = TRUE;
}
1 change: 1 addition & 0 deletions src/nemo-list-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,5 @@ void nemo_list_model_set_highlight_for_files (NemoListModel *model,

void nemo_list_model_set_temporarily_disable_sort (NemoListModel *model, gboolean disable);
gboolean nemo_list_model_get_temporarily_disable_sort (NemoListModel *model);
void nemo_list_model_set_expanding (NemoListModel *model, NemoDirectory *directory);
#endif /* NEMO_LIST_MODEL_H */
1 change: 1 addition & 0 deletions src/nemo-list-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@ row_expanded_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *pa
g_free (uri);

nemo_view_add_subdirectory (NEMO_VIEW (view), directory);
nemo_list_model_set_expanding (view->details->model, directory);

if (nemo_directory_are_all_files_seen (directory)) {
nemo_list_model_subdirectory_done_loading (view->details->model,
Expand Down

0 comments on commit 9085829

Please sign in to comment.