diff -upr evince/po/POTFILES.in evince.new/po/POTFILES.in
--- evince/po/POTFILES.in	2005-07-10 17:55:42.000000000 +0400
+++ evince.new/po/POTFILES.in	2005-07-15 04:12:04.000000000 +0400
@@ -18,6 +18,7 @@ shell/eggfindbar.c
 shell/ev-application.c
 shell/ev-document-types.c
 shell/ev-page-action.c
+shell/ev-page-cache.c
 shell/ev-password.c
 shell/ev-password-view.c
 shell/ev-print-job.c
diff -upr evince/shell/ev-jobs.c evince.new/shell/ev-jobs.c
--- evince/shell/ev-jobs.c	2005-07-02 11:21:06.000000000 +0400
+++ evince.new/shell/ev-jobs.c	2005-07-15 04:08:37.000000000 +0400
@@ -359,9 +359,13 @@ ev_job_load_run (EvJobLoad *job)
 	    
 	ev_document_load (EV_JOB(job)->document, job->uri, &job->error);
 	
-	EV_JOB (job)->finished = TRUE;
+	if (job->error == NULL) {
+		ev_page_cache_create (EV_JOB (job)->document, &job->error);
+	}		
 
 	ev_document_doc_mutex_unlock ();
+
+	EV_JOB (job)->finished = TRUE;
 }
 
 static void ev_job_fonts_init (EvJobFonts *job) { /* Do Nothing */ }
diff -upr evince/shell/ev-page-cache.c evince.new/shell/ev-page-cache.c
--- evince/shell/ev-page-cache.c	2005-06-15 01:04:22.000000000 +0400
+++ evince.new/shell/ev-page-cache.c	2005-07-15 04:11:40.000000000 +0400
@@ -1,7 +1,10 @@
+#include <config.h>
+
 #include "ev-page-cache.h"
 #include "ev-job-queue.h"
 #include <stdlib.h>
 #include <string.h>
+#include <glib/gi18n.h>
 
 typedef struct _EvPageCacheInfo
 {
@@ -100,140 +103,6 @@ ev_page_cache_finalize (GObject *object)
 	ev_document_info_free (page_cache->page_info);
 }
 
-EvPageCache *
-ev_page_cache_new (EvDocument *document)
-{
-	EvPageCache *page_cache;
-	EvPageCacheInfo *info;
-	gint i;
-	double saved_height;
-
-	page_cache = (EvPageCache *) g_object_new (EV_TYPE_PAGE_CACHE, NULL);
-
-	ev_document_doc_mutex_lock ();
-
-	/* We read page information out of the document */
-
-	/* Assume all pages are the same size until proven otherwise */
-	page_cache->uniform = TRUE;
-	page_cache->has_labels = FALSE;
-	page_cache->n_pages = ev_document_get_n_pages (document);
-	page_cache->page_labels = g_new0 (char *, page_cache->n_pages);
-	page_cache->max_width = 0;
-	page_cache->max_height = 0;
-	page_cache->page_info = ev_document_get_info (document);
-
-	if (page_cache->page_info->fields_mask & EV_DOCUMENT_INFO_TITLE) {
-		page_cache->title = g_strdup (page_cache->page_info->title);
-	} else {
-		page_cache->title = NULL;
-	}
-
-	for (i = 0; i < page_cache->n_pages; i++) {
-		double page_width = 0;
-		double page_height = 0;
-		
-		ev_document_get_page_size (document, i, &page_width, &page_height);
-
-	    	page_cache->page_labels[i] = ev_document_get_page_label (document, i);
-		
-		if (page_cache->page_labels[i] != NULL) {
-		
-			page_cache->max_label_chars = MAX(page_cache->max_label_chars, 
-							    g_utf8_strlen (page_cache->page_labels[i], 256));
-			if (!page_cache->has_labels) {
-				gchar *expected_label;
-			
-				expected_label = g_strdup_printf ("%d", i + 1);
-				if (strcmp (expected_label, page_cache->page_labels[i]))  
-					page_cache->has_labels = TRUE;
-				g_free (expected_label);
-			}
-		}
-
-		if (page_width > page_cache->max_width) {
-			page_cache->max_width = page_width;
-		}
-
-		if (page_height > page_cache->max_height) {
-			page_cache->max_height = page_height;
-		}
-			
-		if (i == 0) {
-			page_cache->uniform_width = page_width;
-			page_cache->uniform_height = page_height;
-		} else if (page_cache->uniform &&
-			   (page_cache->uniform_width != page_width ||
-			    page_cache->uniform_height != page_height)) {
-			/* It's a different page size.  Backfill the array. */
-			int j;
-
-			page_cache->size_cache = g_new0 (EvPageCacheInfo, page_cache->n_pages);
-
-			for (j = 0; j < i; j++) {
-				info = &(page_cache->size_cache [j]);
-				info->width = page_cache->uniform_width;
-				info->height = page_cache->uniform_height;
-			}
-			page_cache->uniform = FALSE;
-
-		}
-
-		if (! page_cache->uniform) {
-			info = &(page_cache->size_cache [i]);
-
-			info->width = page_width;
-			info->height = page_height;
-		}
-	}
-
-	page_cache->height_to_page = g_new0(double, page_cache->n_pages);
-	page_cache->dual_height_to_page = g_new0(double, page_cache->n_pages / 2 + 1);
-	
-	saved_height = 0;
-	for (i = 0; i < page_cache->n_pages; i++) {
-
-		if (page_cache->uniform) {
-			page_cache->height_to_page [i] = (i + 1) * page_cache->uniform_height;
-		} else {
-			page_cache->height_to_page [i] = saved_height + page_cache->size_cache [i].height;
-			saved_height = page_cache->height_to_page [i];
-		}
-	}
-	
-	saved_height = 0;
-	for (i = 0; i < page_cache->n_pages; i += 2) {
-
-    		if (page_cache->uniform) {
-			page_cache->dual_height_to_page [i / 2] = (i / 2 + 1) * page_cache->uniform_height;
-		} else {
-			if (i == page_cache->n_pages - 1) {
-				page_cache->dual_height_to_page [i / 2] =
-					saved_height + page_cache->size_cache [i].height;
-			}
-			else {
-				page_cache->dual_height_to_page [i / 2] = saved_height +
-				       MAX(page_cache->size_cache [i].height,			    	    
-				    	   page_cache->size_cache [i + 1].height);
-				saved_height = page_cache->dual_height_to_page [i / 2];
-			}
-		}
-	}
-
-	/* make some sanity check assertions */
-	if (! page_cache->uniform)
-		g_assert (page_cache->size_cache != NULL);
-	if (page_cache->uniform)
-		g_assert (page_cache->uniform_width > 0 && page_cache->uniform_height > 0);
-
-	ev_document_doc_mutex_unlock ();
-
-	if (page_cache->n_pages > 0)
-		ev_page_cache_set_current_page (page_cache, 0);
-
-	return page_cache;
-}
-
 gint
 ev_page_cache_get_n_pages (EvPageCache *page_cache)
 {
@@ -467,6 +336,152 @@ ev_page_cache_prev_page (EvPageCache *pa
 #define PAGE_CACHE_STRING "ev-page-cache"
 
 EvPageCache *
+ev_page_cache_create (EvDocument *document, GError **error)
+{
+	EvPageCache *page_cache;
+	EvPageCacheInfo *info;
+	gint i;
+	double saved_height;
+
+	page_cache = (EvPageCache *) g_object_new (EV_TYPE_PAGE_CACHE, NULL);
+
+	/* We read page information out of the document */
+
+	/* Assume all pages are the same size until proven otherwise */
+	page_cache->uniform = TRUE;
+	page_cache->has_labels = FALSE;
+	page_cache->n_pages = ev_document_get_n_pages (document);
+	page_cache->page_labels = g_new0 (char *, page_cache->n_pages);
+	page_cache->max_width = 0;
+	page_cache->max_height = 0;
+	page_cache->page_info = ev_document_get_info (document);
+
+	if (page_cache->page_info->fields_mask & EV_DOCUMENT_INFO_TITLE) {
+		page_cache->title = g_strdup (page_cache->page_info->title);
+	} else {
+		page_cache->title = NULL;
+	}
+
+	for (i = 0; i < page_cache->n_pages; i++) {
+		double page_width = 0;
+		double page_height = 0;
+		
+		ev_document_get_page_size (document, i, &page_width, &page_height);
+
+	    	page_cache->page_labels[i] = ev_document_get_page_label (document, i);
+		
+		if (page_cache->page_labels[i] != NULL) {
+		
+			page_cache->max_label_chars = MAX(page_cache->max_label_chars, 
+							    g_utf8_strlen (page_cache->page_labels[i], 256));
+			if (!page_cache->has_labels) {
+				gchar *expected_label;
+			
+				expected_label = g_strdup_printf ("%d", i + 1);
+				if (strcmp (expected_label, page_cache->page_labels[i]))  
+					page_cache->has_labels = TRUE;
+				g_free (expected_label);
+			}
+		}
+
+		if (page_width > page_cache->max_width) {
+			page_cache->max_width = page_width;
+		}
+
+		if (page_height > page_cache->max_height) {
+			page_cache->max_height = page_height;
+		}
+			
+		if (i == 0) {
+			page_cache->uniform_width = page_width;
+			page_cache->uniform_height = page_height;
+		} else if (page_cache->uniform &&
+			   (page_cache->uniform_width != page_width ||
+			    page_cache->uniform_height != page_height)) {
+			/* It's a different page size.  Backfill the array. */
+			int j;
+
+			page_cache->size_cache = g_new0 (EvPageCacheInfo, page_cache->n_pages);
+
+			for (j = 0; j < i; j++) {
+				info = &(page_cache->size_cache [j]);
+				info->width = page_cache->uniform_width;
+				info->height = page_cache->uniform_height;
+			}
+			page_cache->uniform = FALSE;
+
+		}
+
+		if (! page_cache->uniform) {
+			info = &(page_cache->size_cache [i]);
+
+			info->width = page_width;
+			info->height = page_height;
+		}
+	}
+
+	page_cache->height_to_page = g_new0(double, page_cache->n_pages);
+	page_cache->dual_height_to_page = g_new0(double, page_cache->n_pages / 2 + 1);
+	
+	saved_height = 0;
+	for (i = 0; i < page_cache->n_pages; i++) {
+
+		if (page_cache->uniform) {
+			page_cache->height_to_page [i] = (i + 1) * page_cache->uniform_height;
+		} else {
+			page_cache->height_to_page [i] = saved_height + page_cache->size_cache [i].height;
+			saved_height = page_cache->height_to_page [i];
+		}
+	}
+	
+	saved_height = 0;
+	for (i = 0; i < page_cache->n_pages; i += 2) {
+
+    		if (page_cache->uniform) {
+			page_cache->dual_height_to_page [i / 2] = (i / 2 + 1) * page_cache->uniform_height;
+		} else {
+			if (i == page_cache->n_pages - 1) {
+				page_cache->dual_height_to_page [i / 2] =
+					saved_height + page_cache->size_cache [i].height;
+			}
+			else {
+				page_cache->dual_height_to_page [i / 2] = saved_height +
+				       MAX(page_cache->size_cache [i].height,			    	    
+				    	   page_cache->size_cache [i + 1].height);
+				saved_height = page_cache->dual_height_to_page [i / 2];
+			}
+		}
+	}
+
+	/* make some sanity check assertions */
+	if (page_cache->n_pages > 0) {
+		ev_page_cache_set_current_page (page_cache, 0);
+	} else {
+	    	g_set_error (error,
+			     EV_DOCUMENT_ERROR,
+			     EV_DOCUMENT_ERROR_INVALID,
+			     _("Document has no pages"));
+		g_object_unref (page_cache);
+		return NULL;
+	}
+
+	if (page_cache->max_width <= 0 || page_cache->max_height <= 0) { 
+	    	g_set_error (error,
+			     EV_DOCUMENT_ERROR,
+			     EV_DOCUMENT_ERROR_INVALID,
+			     _("All document pages have invalid size"));
+		g_object_unref (page_cache);
+		return NULL;
+	}
+
+	
+	g_object_set_data_full (G_OBJECT (document), PAGE_CACHE_STRING, page_cache, g_object_unref);
+
+	return page_cache;
+}
+
+
+EvPageCache *
 ev_page_cache_get (EvDocument *document)
 {
 	EvPageCache *page_cache;
@@ -475,8 +490,7 @@ ev_page_cache_get (EvDocument *document)
 
 	page_cache = g_object_get_data (G_OBJECT (document), PAGE_CACHE_STRING);
 	if (page_cache == NULL) {
-		page_cache = ev_page_cache_new (document);
-		g_object_set_data_full (G_OBJECT (document), PAGE_CACHE_STRING, page_cache, g_object_unref);
+		page_cache = ev_page_cache_create (document, NULL);
 	}
 
 	return page_cache;
diff -upr evince/shell/ev-page-cache.h evince.new/shell/ev-page-cache.h
--- evince/shell/ev-page-cache.h	2005-06-15 01:04:22.000000000 +0400
+++ evince.new/shell/ev-page-cache.h	2005-07-15 04:10:34.000000000 +0400
@@ -30,8 +30,6 @@ G_BEGIN_DECLS
 
 GType          ev_page_cache_get_type            (void) G_GNUC_CONST;
 
-/* Used by ev-document.c only */
-EvPageCache   *ev_page_cache_new                (EvDocument  *document);
 gint           ev_page_cache_get_n_pages         (EvPageCache *page_cache);
 const char    *ev_page_cache_get_title           (EvPageCache *page_cache);
 void           ev_page_cache_get_size            (EvPageCache *page_cache,
@@ -67,6 +65,7 @@ void           ev_page_cache_set_link   
 gboolean       ev_page_cache_next_page           (EvPageCache *page_cache);
 gboolean       ev_page_cache_prev_page           (EvPageCache *page_cache);
 
+EvPageCache   *ev_page_cache_create		 (EvDocument *document, GError **error);
 EvPageCache   *ev_page_cache_get		 (EvDocument *document);
 void	       ev_page_cache_clear		 (EvDocument *document);  
 
diff -upr evince/shell/ev-window.c evince.new/shell/ev-window.c
--- evince/shell/ev-window.c	2005-07-13 01:57:57.000000000 +0400
+++ evince.new/shell/ev-window.c	2005-07-15 04:14:37.000000000 +0400
@@ -878,6 +878,7 @@ ev_window_load_job_cb  (EvJobLoad *job,
 		ev_window_popup_password_dialog (ev_window);
 	} else {
 		unable_to_load (ev_window, job->error->message);
+		ev_window_clear_jobs (ev_window);
 	}	
 
 	return;
