[tor-commits] r24538: {arm} Freezing connection display when tor stops. (arm/trunk/src/interface/connections)
Damian Johnson
atagar1 at gmail.com
Sat Apr 2 23:00:12 UTC 2011
Author: atagar
Date: 2011-04-02 23:00:11 +0000 (Sat, 02 Apr 2011)
New Revision: 24538
Modified:
arm/trunk/src/interface/connections/connPanel.py
Log:
Freezing connection display when tor stops.
Modified: arm/trunk/src/interface/connections/connPanel.py
===================================================================
--- arm/trunk/src/interface/connections/connPanel.py 2011-04-02 22:42:48 UTC (rev 24537)
+++ arm/trunk/src/interface/connections/connPanel.py 2011-04-02 23:00:11 UTC (rev 24538)
@@ -54,6 +54,7 @@
self._showDetails = False # presents the details panel if true
self._lastUpdate = -1 # time the content was last revised
+ self._isTorRunning = True # indicates if tor is currently running or not
self._isPaused = True # prevents updates if true
self._pauseTime = None # time when the panel was paused
self._halt = False # terminates thread if true
@@ -77,7 +78,27 @@
for entry in self._entries:
if isinstance(entry, connEntry.ConnectionEntry):
entry.getLines()[0].isInitialConnection = True
+
+ # listens for when tor stops so we know to stop reflecting changes
+ torTools.getConn().addStatusListener(self.torStateListener)
+ def torStateListener(self, conn, eventType):
+ """
+ Freezes the connection contents when Tor stops.
+
+ Arguments:
+ conn - tor controller
+ eventType - type of event detected
+ """
+
+ self._isTorRunning = eventType == torTools.State.INIT
+
+ if self._isPaused or not self._isTorRunning:
+ if not self._pauseTime: self._pauseTime = time.time()
+ else: self._pauseTime = None
+
+ self.redraw(True)
+
def setPaused(self, isPause):
"""
If true, prevents the panel from updating.
@@ -86,7 +107,8 @@
if not self._isPaused == isPause:
self._isPaused = isPause
- if isPause: self._pauseTime = time.time()
+ if isPause or not self._isTorRunning:
+ if not self._pauseTime: self._pauseTime = time.time()
else: self._pauseTime = None
# redraws so the display reflects any changes between the last update
@@ -151,7 +173,7 @@
while not self._halt:
currentTime = time.time()
- if self._isPaused or currentTime - lastDraw < self._config["features.connection.refreshRate"]:
+ if self._isPaused or not self._isTorRunning or currentTime - lastDraw < self._config["features.connection.refreshRate"]:
self._cond.acquire()
if not self._halt: self._cond.wait(0.2)
self._cond.release()
More information about the tor-commits
mailing list