Index: src/import-export/qif-import/druid-qif-import.c
===================================================================
--- src/import-export/qif-import/druid-qif-import.c	(revision 16943)
+++ src/import-export/qif-import/druid-qif-import.c	(working copy)
@@ -198,6 +198,13 @@
   g_free(window);
 }
 
+
+/********************************************************************\
+ * get_next_druid_page
+ *
+ * Determine which page should be shown after the current page.
+\********************************************************************/
+
 static GtkWidget * 
 get_next_druid_page(QIFImportWindow * wind, GnomeDruidPage * page)
 {
@@ -225,9 +232,10 @@ To be consistent with get_prev_druid_page
   }
   
   next = current->next;
-  while(!next ||
-        (!wind->show_doc_pages &&
-         g_list_find(wind->doc_pages, next->data))) {
+  while (!next ||
+         (!wind->show_doc_pages && g_list_find(wind->doc_pages, next->data)) ||
+         (wind->new_stocks == SCM_BOOL_F &&
+          GNOME_DRUID_PAGE(next->data) == get_named_page(wind, "commodity_doc_page"))) {
     if(next && next->next) {
       next = next->next;
     }
@@ -254,6 +262,13 @@
   else return NULL;
 }
 
+
+/********************************************************************\
+ * get_prev_druid_page
+ *
+ * Determine which page was shown before the current page.
+\********************************************************************/
+
 static GtkWidget * 
 get_prev_druid_page(QIFImportWindow * wind, GnomeDruidPage * page)
 {
@@ -280,10 +295,23 @@
     where = 1;
   }
   
-  prev = current->prev;
-  while(!prev ||
-        (!wind->show_doc_pages &&
-         g_list_find(wind->doc_pages, prev->data))) {
+  /*
+   * Now that we know where we are, find the correct page to go back to.
+   */
+  if (where == 3 && SCM_NULLP(wind->match_transactions))
+    /* No duplicates were found, so skip all post-conversion pages. */
+    prev = NULL;
+  else
+    prev = current->prev;
+
+  /* Keep going back through the sets of available pages as long as:
+   * (a) there are no remaining pages in this set, or
+   * (b) the page is a doc page and we're not supposed to show them, or
+   * (c) the page is commodity related and the are no new commodities. */
+  while (!prev ||
+         (!wind->show_doc_pages && g_list_find(wind->doc_pages, prev->data)) ||
+         (wind->new_stocks == SCM_BOOL_F &&
+          GNOME_DRUID_PAGE(prev->data) == get_named_page(wind, "commodity_doc_page"))) {
     if(prev && prev->prev) {
       prev = prev->prev;
     }
@@ -1635,6 +1663,10 @@
     #undef FUNC_NAME
     new_page = make_qif_druid_page(commodity);
 
+    g_signal_connect(new_page->page, "back",
+		     G_CALLBACK(gnc_ui_qif_import_generic_back_cb),
+		     wind);
+
     g_signal_connect(new_page->page, "next",
 		     G_CALLBACK(gnc_ui_qif_import_comm_check_cb),
 		     wind);
