mirror of
https://github.com/onionshare/onionshare.git
synced 2025-07-26 08:05:49 -04:00
start the webapp thread in a QThread instead of using threading
This commit is contained in:
parent
3e65bf7884
commit
800a4edb6e
1 changed files with 19 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
||||||
import onionshare, webapp
|
import onionshare, webapp
|
||||||
import threading, os, sys, subprocess
|
import os, sys, subprocess
|
||||||
|
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
|
@ -7,6 +7,22 @@ from PyQt4.QtWebKit import *
|
||||||
|
|
||||||
qtapp = QApplication(sys.argv)
|
qtapp = QApplication(sys.argv)
|
||||||
|
|
||||||
|
class WebAppThread(QThread):
|
||||||
|
def __init__(self, webapp_port, onionshare_port, filename, onion_host):
|
||||||
|
QThread.__init__(self)
|
||||||
|
self.webapp_port = webapp_port
|
||||||
|
|
||||||
|
global qtapp
|
||||||
|
webapp.onionshare = onionshare
|
||||||
|
webapp.onionshare_port = onionshare_port
|
||||||
|
webapp.filename = filename
|
||||||
|
webapp.onion_host = onion_host
|
||||||
|
webapp.qtapp = qtapp
|
||||||
|
webapp.clipboard = qtapp.clipboard()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
webapp.app.run(port=self.webapp_port)
|
||||||
|
|
||||||
def alert(msg, icon=QMessageBox.NoIcon):
|
def alert(msg, icon=QMessageBox.NoIcon):
|
||||||
dialog = QMessageBox()
|
dialog = QMessageBox()
|
||||||
dialog.setWindowTitle("OnionShare")
|
dialog.setWindowTitle("OnionShare")
|
||||||
|
@ -38,19 +54,6 @@ def select_file(strings):
|
||||||
basename = os.path.basename(filename)
|
basename = os.path.basename(filename)
|
||||||
return filename, basename
|
return filename, basename
|
||||||
|
|
||||||
def start_webapp(webapp_port, onionshare_port, filename, onion_host):
|
|
||||||
global qtapp
|
|
||||||
|
|
||||||
webapp.onionshare = onionshare
|
|
||||||
webapp.onionshare_port = onionshare_port
|
|
||||||
webapp.filename = filename
|
|
||||||
webapp.onion_host = onion_host
|
|
||||||
|
|
||||||
webapp.qtapp = qtapp
|
|
||||||
webapp.clipboard = qtapp.clipboard()
|
|
||||||
|
|
||||||
webapp.app.run(port=webapp_port)
|
|
||||||
|
|
||||||
def launch_window(webapp_port, onionshare_port, basename):
|
def launch_window(webapp_port, onionshare_port, basename):
|
||||||
def shutdown():
|
def shutdown():
|
||||||
onionshare.tails_close_port(onionshare_port)
|
onionshare.tails_close_port(onionshare_port)
|
||||||
|
@ -91,14 +94,8 @@ def main():
|
||||||
|
|
||||||
# start the gui web server
|
# start the gui web server
|
||||||
webapp_port = onionshare.choose_port()
|
webapp_port = onionshare.choose_port()
|
||||||
t = threading.Thread(target=start_webapp, kwargs={
|
webapp_thread = WebAppThread(webapp_port, onionshare_port, filename, onion_host)
|
||||||
'webapp_port': webapp_port,
|
webapp_thread.start()
|
||||||
'onionshare_port': onionshare_port,
|
|
||||||
'filename': filename,
|
|
||||||
'onion_host': onion_host
|
|
||||||
})
|
|
||||||
t.daemon = True
|
|
||||||
t.start()
|
|
||||||
onionshare.tails_open_port(webapp_port)
|
onionshare.tails_open_port(webapp_port)
|
||||||
|
|
||||||
# launch the window
|
# launch the window
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue