Skip to content

Commit 95f23de

Browse files
authored
Merge pull request #216 from MightyCreak/fix-version-option
fix: error when runnin with arg --version
2 parents 7a616ce + f5e1173 commit 95f23de

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/diffuse/main.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import encodings
2323

2424
from gettext import gettext as _
25+
from typing import Optional
2526

2627
from diffuse import constants, utils
2728
from diffuse.resources import theResources
@@ -35,13 +36,14 @@
3536
class DiffuseApplication(Gtk.Application):
3637
"""The main application class."""
3738

38-
def __init__(self, sysconfigdir):
39+
def __init__(self, sysconfigdir: str):
3940
super().__init__(
4041
application_id=constants.APP_ID,
4142
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.NON_UNIQUE)
4243

43-
self.window = None
4444
self.sysconfigdir = sysconfigdir
45+
self.window: Optional[DiffuseWindow] = None
46+
self.statepath: str = ""
4547

4648
self.connect('shutdown', self.on_shutdown)
4749

@@ -196,7 +198,8 @@ def __init__(self, sysconfigdir):
196198

197199
def do_activate(self) -> None:
198200
"""Called when the application is activated."""
199-
self.window.present()
201+
if self.window is not None:
202+
self.window.present()
200203

201204
def do_command_line(self, command_line):
202205
"""Called to treat the command line options."""
@@ -369,7 +372,8 @@ def do_command_line(self, command_line):
369372
return 0
370373

371374
def on_shutdown(self, application: Gio.Application) -> None:
372-
self.window.save_state(self.statepath)
375+
if self.window is not None and self.statepath != '':
376+
self.window.save_state(self.statepath)
373377

374378

375379
def main(version: str, sysconfigdir: str) -> int:

0 commit comments

Comments
 (0)