Part of this is already upstream, the other part has been submitted to
https://gitlab.com/Nalin-x-Linux/lios-3/merge_requests/5
---
 lios/main.py |  126 +++++++++++++++++++++++++++++++----------------------------
 1 file changed, 67 insertions(+), 59 deletions(-)

--- a/lios/main.py
+++ b/lios/main.py
@@ -1099,27 +1099,29 @@ class linux_intelligent_ocr_solution():
 		#self.make_ocr_widgets_inactive(lock=True)
 		#self.make_preferences_widgets_inactive(lock=True)
 		#self.make_image_widgets_inactive(lock=True)
-		progress_step = 1/len(self.iconview.get_selected_item_names())
-		progress = 0;
-		mode = self.preferences.mode_of_rotation
-		angle = self.preferences.rotation_angle
-		for item in self.iconview.get_selected_item_names():
-			self.notify_information(_("Running OCR on selected image {}")
-			.format(item))
-			
-			#self.announce(_("Recognising {}").format(self.liststore_images[item[0]][1]))
-			progress = progress + progress_step;			
-			text,angle = self.ocr(item,mode,angle)
-			self.insert_text_to_textview(text,self.preferences.insert_position,True)
-			self.preferences.update_page_number()
-			loop.acquire_lock()
-			self.iconview.reload_preview(item)
-			loop.release_lock()
-			if mode == 1:#Changing partial automatic to Manual
-				mode = 2
-				#self.announce(_("Angle to be rotated = {}").format(angle))
-			if(self.process_breaker):
-				break
+		length = len(self.iconview.get_selected_item_names())
+		if length > 0:
+			progress_step = 1/length
+			progress = 0;
+			mode = self.preferences.mode_of_rotation
+			angle = self.preferences.rotation_angle
+			for item in self.iconview.get_selected_item_names():
+				self.notify_information(_("Running OCR on selected image {}")
+				.format(item))
+
+				#self.announce(_("Recognising {}").format(self.liststore_images[item[0]][1]))
+				progress = progress + progress_step;
+				text,angle = self.ocr(item,mode,angle)
+				self.insert_text_to_textview(text,self.preferences.insert_position,True)
+				self.preferences.update_page_number()
+				loop.acquire_lock()
+				self.iconview.reload_preview(item)
+				loop.release_lock()
+				if mode == 1:#Changing partial automatic to Manual
+					mode = 2
+					#self.announce(_("Angle to be rotated = {}").format(angle))
+				if(self.process_breaker):
+					break
 		self.imageview.redraw()
 		#self.make_ocr_widgets_active(lock=True)
 		#self.make_preferences_widgets_active(lock=True)
@@ -1136,19 +1138,21 @@ class linux_intelligent_ocr_solution():
 		#self.make_ocr_widgets_inactive(lock=True)
 		#self.make_preferences_widgets_inactive(lock=True)
 		#self.make_image_widgets_inactive(lock=True)
-		progress_step = 1/len(self.iconview.get_selected_item_names())
-		progress = 0;
-		for item in self.iconview.get_selected_item_names():
-			self.notify_information(_("Running OCR on selected image {} (without rotating)")
-			.format(item))
-			
-			#self.announce(_("Recognising {} without rotating").format(self.liststore_images[item[0]][1]))
-			progress = progress + progress_step;
-			text,angle = self.ocr(item,2,00)
-			self.insert_text_to_textview(text,self.preferences.insert_position,True)
-			self.preferences.update_page_number()
-			if(self.process_breaker):
-				break
+		length = len(self.iconview.get_selected_item_names())
+		if length > 0:
+			progress_step = 1/length
+			progress = 0;
+			for item in self.iconview.get_selected_item_names():
+				self.notify_information(_("Running OCR on selected image {} (without rotating)")
+				.format(item))
+
+				#self.announce(_("Recognising {} without rotating").format(self.liststore_images[item[0]][1]))
+				progress = progress + progress_step;
+				text,angle = self.ocr(item,2,00)
+				self.insert_text_to_textview(text,self.preferences.insert_position,True)
+				self.preferences.update_page_number()
+				if(self.process_breaker):
+					break
 		self.notify_information(_("completed!"),0)
 		#self.announce(_("Completed!"))
 		#self.make_ocr_widgets_active(lock=True)
@@ -1182,16 +1186,18 @@ class linux_intelligent_ocr_solution():
 		if(len(self.iconview.get_selected_item_names()) == 0):
 			self.notify_information(_("Nothing selected"),0)
 			return
-		progress_step = 1/len(self.iconview.get_selected_item_names())
-		progress = 0;
-		for item in reversed(self.iconview.get_selected_item_names()):
-			os.system("convert -rotate {0} {1} {1}".format(angle,item))
-			loop.acquire_lock()
-			self.iconview.reload_preview(item)
-			loop.release_lock()
-			self.notify_information(_("Rotating selected image {} to {}")
-			.format(item,angle),progress)
-			progress = progress + progress_step;
+		length = len(self.iconview.get_selected_item_names())
+		if length > 0:
+			progress_step = 1/length
+			progress = 0;
+			for item in reversed(self.iconview.get_selected_item_names()):
+				os.system("convert -rotate {0} {1} {1}".format(angle,item))
+				loop.acquire_lock()
+				self.iconview.reload_preview(item)
+				loop.release_lock()
+				self.notify_information(_("Rotating selected image {} to {}")
+				.format(item,angle),progress)
+				progress = progress + progress_step;
 		self.imageview.redraw()
 		self.notify_information(_("completed!"),0)
 
@@ -1297,21 +1303,23 @@ class linux_intelligent_ocr_solution():
 		#self.make_preferences_widgets_inactive(lock=True)
 		#self.make_ocr_widgets_inactive(lock=True)
 		#self.make_image_widgets_inactive(lock=True)
-		progress_step = 1/len(self.imageview.get_selection_list());
-		progress = 0;
-		for item in self.imageview.get_selection_list():
-			self.notify_information(_("Running OCR on selected Area [ X={} Y={} Width={} Height={} ]")
-			.format(item[0],item[1],item[2],item[3]))
-			
-			progress = progress + progress_step;
-			self.imageview.save_sub_image("{0}tmp".format(macros.tmp_dir),
-				item[0],item[1],item[2],item[3])
-			
-			#Will always be Manual with no rotation
-			text,angle = self.ocr("{0}tmp".format(macros.tmp_dir),2,00)
-			self.insert_text_to_textview(text,False,False)
-			if(self.process_breaker):
-				break;
+		length = len(self.imageview.get_selection_list())
+		if length > 0:
+			progress_step = 1/length
+			progress = 0;
+			for item in self.imageview.get_selection_list():
+				self.notify_information(_("Running OCR on selected Area [ X={} Y={} Width={} Height={} ]")
+				.format(item[0],item[1],item[2],item[3]))
+
+				progress = progress + progress_step;
+				self.imageview.save_sub_image("{0}tmp".format(macros.tmp_dir),
+					item[0],item[1],item[2],item[3])
+
+				#Will always be Manual with no rotation
+				text,angle = self.ocr("{0}tmp".format(macros.tmp_dir),2,00)
+				self.insert_text_to_textview(text,False,False)
+				if(self.process_breaker):
+					break;
 
 		self.notify_information(_("completed!"),0)
 		#self.make_preferences_widgets_active(lock=True)
