From 39870556c865297689d3e39fb63bf6f432d6cae9 Mon Sep 17 00:00:00 2001
From: mkaay <mkaay@mkaay.de>
Date: Mon, 6 Sep 2010 16:39:26 +0200
Subject: gui double logging fix

---
 pyLoadCore.py | 8 ++++++++
 pyLoadGui.py  | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/pyLoadCore.py b/pyLoadCore.py
index d92841d56..7919ba2b8 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -293,6 +293,7 @@ class Core(object):
             if self.do_kill:
                 self.shutdown()
                 self.log.info(_("pyLoad quits"))
+                self.removeLogger()
                 exit()
 
             self.threadManager.work()
@@ -333,6 +334,7 @@ class Core(object):
         frm = logging.Formatter("%(asctime)s %(levelname)-8s  %(message)s", "%d.%m.%Y %H:%M:%S")
         console.setFormatter(frm)
         self.log = logging.getLogger("log") # settable in config
+        self.log.myhandlers = []
 
         if self.config['log']['file_log']:
             file_handler = logging.handlers.RotatingFileHandler(join(self.config['log']['log_folder'], 'log.txt'),
@@ -346,6 +348,11 @@ class Core(object):
         self.log.addHandler(console) #if console logging
         self.log.setLevel(level)
 
+    def removeLogger(self):
+        for h in list(self.log.handlers):
+            self.log.removeHandler(h)
+            h.close()
+    
     def check_install(self, check_name, legend, python=True, essential=False):
         """check wether needed tools are installed"""
         try:
@@ -737,4 +744,5 @@ if __name__ == "__main__":
     except KeyboardInterrupt:
         pyload_core.shutdown()
         pyload_core.log.info(_("killed pyLoad from Terminal"))
+        self.removeLogger()
         _exit(1)
diff --git a/pyLoadGui.py b/pyLoadGui.py
index 9eac96f94..3f8a57910 100755
--- a/pyLoadGui.py
+++ b/pyLoadGui.py
@@ -439,7 +439,7 @@ class main(QObject):
                 self.core = Core()
                 thread.start_new_thread(self.core.start, (False,False))
                 self.connector.setAddr(("core", self.core))
-                self.mainWindow.mactions["manager"].setDisabled(True) #workaround to supress bug
+                #self.mainWindow.mactions["manager"].setDisabled(True) #workaround to supress bug
 
 
         self.startMain()
-- 
cgit v1.2.3