Index: nautilus-3.20.3/src/nautilus-desktop-canvas-view.c
===================================================================
--- nautilus-3.20.3.orig/nautilus-desktop/nautilus-desktop-canvas-view.c
+++ nautilus-3.20.3/nautilus-desktop/nautilus-desktop-canvas-view.c
@@ -29,6 +29,7 @@
 #include "nautilus-desktop-canvas-view-container.h"
 #include "nautilus-desktop-icon-file.h"
 #include "nautilus-desktop-directory.h"
+#include "nautilus-canvas-private.h"
 
 #include <X11/Xatom.h>
 #include <gtk/gtk.h>
@@ -279,6 +280,7 @@ nautilus_desktop_canvas_view_end_loading
     guint current_icon_size;
     gchar *current_icon_size_string;
     NautilusFile *file;
+    NautilusCanvasContainer *canvas_container;
 
     NAUTILUS_FILES_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->end_loading (view, all_files_seen);
 
@@ -291,13 +293,30 @@ nautilus_desktop_canvas_view_end_loading
     g_return_if_fail (file != NULL);
 
     stored_size_icon = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_DESKTOP_ICON_SIZE, NULL);
-    current_zoom = nautilus_canvas_container_get_zoom_level (get_canvas_container (view));
+    canvas_container = get_canvas_container (view);
+    current_zoom = nautilus_canvas_container_get_zoom_level (canvas_container);
     current_icon_size = nautilus_canvas_container_get_icon_size_for_zoom_level (current_zoom);
     needs_reorganization = stored_size_icon == NULL || atoi (stored_size_icon) != current_icon_size;
 
     if (needs_reorganization)
     {
         current_icon_size_string = g_strdup_printf ("%d", current_icon_size);
+
+        // If there's no stored_size_icon and any icon has has_lazy_position to TRUE
+        // then nautilus crashes on a g_assert(!auto_layout) in finish_adding_new_icons
+        // because nautilus_canvas_container_sort sets it to TRUE, so in that case
+        // we reassign the position of all icons by setting has_lazy_position to FALSE.
+        if (stored_size_icon == NULL) {
+            GList *p, *new_icons;
+            NautilusCanvasIcon *icon;
+
+            new_icons = canvas_container->details->new_icons;
+            for (p = new_icons; p != NULL; p = p->next) {
+                icon = p->data;
+                icon->has_lazy_position = FALSE;
+            }
+        }
+
         nautilus_canvas_view_clean_up_by_name (NAUTILUS_CANVAS_VIEW (view));
         nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_DESKTOP_ICON_SIZE,
                                     NULL, current_icon_size_string);
