summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/loader.py9
-rw-r--r--ranger/fsobject/file.py10
2 files changed, 14 insertions, 5 deletions
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 1ea50f4d..5e652a28 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -55,6 +55,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 	object is removed from the queue (type ^C in ranger)
 	"""
 	finished = False
+	process = None
 	def __init__(self, args, descr, silent=False):
 		SignalDispatcher.__init__(self)
 		Loadable.__init__(self, self.generate(), descr)
@@ -68,7 +69,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 		if self.silent:
 			while process.poll() is None:
 				yield
-				sleep(0.02)
+				sleep(0.03)
 		else:
 			while process.poll() is None:
 				yield
@@ -80,8 +81,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 						if error:
 							self.fm.notify(error, bad=True)
 				except select.error:
-					pass
-				sleep(0.01)
+					sleep(0.03)
 		self.finished = True
 		self.signal_emit('after', process=process)
 
@@ -89,13 +89,16 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 		if not self.finished and not self.paused:
 			self.process.send_signal(20)
 		Loadable.pause(self)
+		self.signal_emit('pause', process=self.process)
 
 	def unpause(self):
 		if not self.finished and self.paused:
 			self.process.send_signal(18)
 		Loadable.unpause(self)
+		self.signal_emit('unpause', process=self.process)
 
 	def destroy(self):
+		self.signal_emit('destroy', process=self.process)
 		if self.process:
 			self.process.kill()
 
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index 4076b136..d7e667a2 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -95,7 +95,7 @@ class File(FileSystemObject):
 			return False
 		return True
 
-	def _update_preview(self, signal):
+	def _loader_after(self, signal):
 		self.preview_known = True
 		self.preview_data = None
 		if not signal.process.poll():
@@ -104,6 +104,11 @@ class File(FileSystemObject):
 			self.fm.ui.browser.pager.need_redraw = True
 			self.fm.ui.browser.need_redraw = True
 
+	def _loader_destroy(self, signal):
+		self.preview_known = False
+		self.preview_loading = False
+		self.preview_data = None
+
 	def get_preview_source(self, width, height):
 		if self.fm.settings.preview_script:
 			if self.preview_known or self.preview_loading:
@@ -112,7 +117,8 @@ class File(FileSystemObject):
 			loadable = CommandLoader(args=[self.fm.settings.preview_script,
 				self.path, str(width), str(height)],
 				silent=True, descr="Getting preview of %s" % self.path)
-			loadable.signal_bind('after', self._update_preview, weak=True)
+			loadable.signal_bind('after', self._loader_after, weak=True)
+			loadable.signal_bind('destroy', self._loader_destroy, weak=True)
 			self.fm.loader.add(loadable)
 			return None
 		return open(self.path, 'r')