From 3c471f39667477fcdd83efb44dad4fc3968ca535 Mon Sep 17 00:00:00 2001
From: Marek Siarkowicz <mareksiarkowicz@gmail.com>
Date: Mon, 15 Jun 2015 03:06:49 +0200
Subject: Deactivation of interface starts reconnection.

---
 ParrotZikTray | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ParrotZikTray b/ParrotZikTray
index 4c86adf..d5b113c 100755
--- a/ParrotZikTray
+++ b/ParrotZikTray
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 import functools
+from threading import Lock
 
 import gtk
 
@@ -23,22 +24,27 @@ class repeat(object):
     def __init__(self, f):
         self.f = f
         self.id = None
+        self.lock = Lock()
 
     def __call__(self, cls):
         self.f(cls)
 
     def start(self, cls, frequency):
+        self.lock.acquire()
         if not self.id:
             def run():
                 self.f(cls)
                 return True
 
             self.id = gtk.timeout_add(frequency, run)
+        self.lock.release()
 
     def stop(self):
+        self.lock.acquire()
         if self.id:
             gtk.timeout_remove(self.id)
             self.id = None
+        self.lock.release()
 
 
 class ParrotZikIndicator(SysIndicator):
@@ -148,6 +154,7 @@ class ParrotZikBaseInterface(object):
         self.indicator.active_interface = None
         self.indicator.setIcon("zik-audio-headset")
         self.indicator.info('Lost Connection')
+        self.indicator.reconnect.start(self.indicator, RECONNECT_FREQUENCY)
 
     def toggle_auto_connection(self, widget):
         try:
-- 
cgit v1.2.1