Skip to content

Commit 95868f2

Browse files
Improve restart dialogs
1 parent 0a8d45d commit 95868f2

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

src/robotide/application/application.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
import builtins
1717
import os
18+
from csv import excel
19+
1820
import wx
1921
from contextlib import contextmanager
2022
from pathlib import Path
@@ -332,24 +334,25 @@ def change_locale(self, message):
332334
self._locale.AddCatalog('RIDE')
333335
if len(message.keys) > 1: # Avoid initial setting
334336
from multiprocessing import shared_memory
335-
from .restartutil import restart_dialog
337+
from .restartutil import do_restart
336338
new_locale = self._locale.GetName()
337339
# print(f"DEBUG: application.py RIDE change_locale from {initial_locale} to {new_locale}")
338340
if initial_locale != new_locale:
339-
if restart_dialog(): # DEBUG: See the in implementation why we don't restart
340-
# print("DEBUG: application.py RIDE change_locale Restart accepted.")
341-
# Shared memory to store language definition
341+
#if restart_dialog(): # DEBUG: See the in implementation why we don't restart
342+
# print("DEBUG: application.py RIDE change_locale Restart accepted.")
343+
# Shared memory to store language definition
344+
try:
345+
sharemem = shared_memory.ShareableList(['en'], name="language")
346+
except FileExistsError: # Other instance created file
347+
sharemem = shared_memory.ShareableList(name="language")
348+
result = do_restart()
349+
if result:
342350
try:
343-
sharemem = shared_memory.ShareableList(['en'], name="language")
344-
except FileExistsError: # Other instance created file
345-
sharemem = shared_memory.ShareableList(name="language")
346-
finally:
347351
sharemem.shm.close()
348352
sharemem.shm.unlink()
349-
# wx.CallAfter(self.ExitMainLoop)
350-
# wx.CallLater(1000, self.Destroy)
351-
wx.CallLater(1000, self.ExitMainLoop)
352-
# self.DeletePendingEvents()
353+
except FileNotFoundError:
354+
pass
355+
353356

354357
@staticmethod
355358
def update_excludes(message):

src/robotide/application/restartutil.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727

2828

2929
def restart_dialog():
30-
if not _askyesno(
31-
_("Re-open RIDE for Language Change"),
30+
if not _askyesno(_("Re-open RIDE for Language Change"),
3231
f"{SPC}{_('Language change will only be correct after re-opening RIDE.')}"
3332
f"{SPC}\n{SPC}{_('Do you want to CLOSE RIDE now?')}\n{SPC}"
3433
# f"{_('After restarting RIDE you will see another dialog informing to close this RIDE instance.')}"
@@ -41,16 +40,15 @@ def restart_dialog():
4140

4241
def do_restart():
4342
my_pid = psutil.Process()
44-
command = sys.executable + " -m robotide.__init__ --noupdatecheck"
4543
# DEBUG: The starting of new RIDE instance with subsequent closing of this instance,
4644
# makes problems in editing the current file, and even opening new file. Because of
47-
# this, the restarting is disabled, until someone finds a good way to clean-up memory.
48-
# wx.CallLater(100, subprocess.Popen, command.split(' '), start_new_session=True)
49-
# Wait 10 seconds before trying to kill this process
50-
""" Not working well:
51-
wx.CallLater(10000, psutil.Process.kill, my_pid.pid)
52-
"""
53-
wx.CallLater(5000, _askyesno, _("Completed Language Change"),
54-
f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{my_pid.pid}){SPC}",
55-
wx.GetActiveWindow())
56-
45+
# this, the restarting was disabled, until someone finds a good way to clean-up memory.
46+
command = sys.executable + " -m robotide.__init__ --noupdatecheck"
47+
wx.CallLater(500, subprocess.Popen, command.split(' '), start_new_session=True)
48+
result = _askyesno(_("Completed Language Change"),
49+
f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{my_pid.pid}){SPC}"
50+
f"\n{SPC}{_('Do you want to CLOSE RIDE now?')}\n{SPC}",
51+
wx.GetActiveWindow())
52+
if result:
53+
wx.CallLater(1000, wx.App.Get().GetTopWindow().Close)
54+
return True

src/robotide/application/updatenotifier.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ def start_upgraded(message):
175175
__ = message
176176
command = sys.executable + " -m robotide.__init__ --noupdatecheck"
177177
wx.CallLater(500, subprocess.Popen, command.split(' '), start_new_session=True)
178-
pid = psutil.Process
179-
result = _askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{pid}){SPC}",
178+
p = psutil.Process()
179+
result = _askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{p.pid}){SPC}"
180+
f"\n{SPC}{_('Do you want to CLOSE RIDE now?')}\n{SPC}",
180181
wx.GetActiveWindow())
181182
PUBLISHER.unsubscribe(start_upgraded, RideRunnerStopped)
182183
if result:
183-
time.sleep(10)
184-
wx.CallAfter(wx.App.Get().Close)
185-
# wx.App.Get().OnExit()
184+
wx.CallAfter(wx.App.Get().GetTopWindow().Close)
185+
# wx.CallAfter(p.terminate)
186186

187187

188188
class LocalHtmlWindow(HtmlWindow):

0 commit comments

Comments
 (0)