diff --git a/BirdyNet.py b/BirdyNet.py index 7cb8c93..22f7444 100644 --- a/BirdyNet.py +++ b/BirdyNet.py @@ -28,9 +28,9 @@ import configparser import json import time import html -browserWindows = [] - +import threading os.chdir(sp) + distro = os.path.splitext(s.rsplit(os.path.sep)[-1])[0] version = { "major": 0, @@ -41,6 +41,9 @@ version = { versionString = ".".join(map(str,[version["major"],version["minor"]])) versionStringExt = ".".join(map(str,[version["major"],version["minor"],version["patch"]])) + " " + version["stage"] +browserWindows = [] +browserWindowsLock = threading.Lock() + def runCode(str, lcs = False, description = "loose-code"): if lcs == False: lcs = {} code = compile(str,description,"exec") @@ -131,8 +134,10 @@ class browserWindow(QMainWindow): self.cResizeElements() def closeEvent(self,event): + browserWindowsLock.acquire() browserWindows.remove(self) - event.accept() + self.destroy() + browserWindowsLock.release() def cNavigate(self,event = None): try: @@ -140,7 +145,7 @@ class browserWindow(QMainWindow): self.cStatusBar.showMessage("Downloading...") self.update() start = time.time() - response = downloadPage(self.cUrlBar.text(),{"User-Agent": self.cUserAgent}) + response = downloadPage(self.cUrlBar.text(),[("User-Agent",self.cUserAgent)]) self.cUrlBar.setText(response["url"]) end = time.time() print("Downloading page: " +str(end - start)) @@ -160,13 +165,14 @@ class browserWindow(QMainWindow): #print(prettyJson(response["headers"])) except Exception as e: self.cDoc.cRenderHtml(html.escape(str(e))) - self.cDoc.cRenderHtml(str(e)) raise def cNewWindow(self): w = browserWindow() + browserWindowsLock.acquire() browserWindows.append(w) w.show() + browserWindowsLock.release() def main(): # load program default addons @@ -198,7 +204,9 @@ def main(): app.setWindowIcon(QtGui.QIcon("assets/BirdyNet-XP.ico")) except Exception as e: print("Could not set window icon: " +print(e)) + browserWindowsLock.acquire() browserWindows.append(browserWindow()) + browserWindowsLock.release() sys.exit(app.exec_())