Index: node_gallery.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_gallery/node_gallery.pages.inc,v
retrieving revision 1.11.4.29
diff -u -r1.11.4.29 node_gallery.pages.inc
--- node_gallery.pages.inc	8 May 2010 14:02:30 -0000	1.11.4.29
+++ node_gallery.pages.inc	10 May 2010 21:49:51 -0000
@@ -144,9 +144,11 @@
   // Handle new uploads, and merge tmp files into node-files.
   node_gallery_upload_images($cached_form, $form_state);
   
-  //if upload failed.
-  if (drupal_get_messages('error', FALSE)) {
-    print drupal_to_js(array('status' => TRUE, 'data' => theme('status_messages') . drupal_get_form('node_gallery_upload_form')));
+  // Exit if no images were successfully uploaded
+  if (empty($form_state['values']['files'])) {
+    if (drupal_get_messages('error', FALSE)) {
+      print drupal_to_js(array('status' => TRUE, 'data' => theme('status_messages') . drupal_get_form('node_gallery_upload_form')));
+    }
     exit;
   }
   
@@ -675,7 +677,7 @@
   $errors = array();
   
   if ($user->uid != 1) {
-    $current_number = db_result(db_query("SELECT COUNT(*) FROM {files} WHERE uid = %d", $user->uid));
+    $current_number = db_result(db_query("SELECT COUNT(*) FROM {files} WHERE uid = %d and status = 1", $user->uid));
     if ($current_number >= $max_number && $max_number != '0') {
       $errors[] = t("You can only upload a maximum of %num images.", array('%num' => $max_number));
     }
