Skip to content

Commit

Permalink
fix: spotube doesn't exit properly, hangs in infinite loop #768
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Oct 29, 2023
1 parent 83c0b49 commit 353ca79
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/collections/intents.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:spotube/components/player/player_controls.dart';
Expand Down Expand Up @@ -115,7 +116,7 @@ class CloseAppAction extends Action<CloseAppIntent> {
@override
invoke(intent) {
if (kIsDesktop) {
DesktopTools.window.close();
exit(0);
} else {
SystemNavigator.pop();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/components/shared/page_window_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:spotube/utils/platform.dart';
import 'package:titlebar_buttons/titlebar_buttons.dart';
import 'dart:math';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'dart:io' show Platform;
import 'dart:io' show Platform, exit;
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:local_notifier/local_notifier.dart';

Expand All @@ -17,7 +17,7 @@ final closeNotification = DesktopTools.createNotification(
LocalNotificationAction(text: 'Close The App'),
],
)?..onClickAction = (value) {
DesktopTools.window.close();
exit(0);
};

class PageWindowTitleBar extends StatefulHookConsumerWidget
Expand Down Expand Up @@ -113,7 +113,7 @@ class WindowTitleBarButtons extends HookConsumerWidget {

Future<void> onClose() async {
if (preferences.closeBehavior == CloseBehavior.close) {
await DesktopTools.window.close();
exit(0);
} else {
await DesktopTools.window.hide();
await closeNotification?.show();
Expand Down
4 changes: 3 additions & 1 deletion lib/hooks/use_init_sys_tray.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
Expand Down Expand Up @@ -70,7 +72,7 @@ void useInitSysTray(WidgetRef ref) {
label: "Quit",
name: "quit",
onClicked: (item) async {
await DesktopTools.window.close();
exit(0);
},
),
],
Expand Down
4 changes: 2 additions & 2 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@
"use_system_title_bar": "Use system title bar",
"crunching_results": "Crunching results...",
"search_to_get_results": "Search to get results",
"use_amoled_mode": "Use AMOLED mode",
"pitch_dark_theme": "Pitch black dart theme",
"use_amoled_mode": "Pitch black dark theme",
"pitch_dark_theme": "AMOLED Mode",
"normalize_audio": "Normalize audio",
"change_cover": "Change cover",
"add_cover": "Add cover",
Expand Down
3 changes: 1 addition & 2 deletions lib/services/audio_services/linux_audio_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ class _MprisMediaPlayer2 extends DBusObject {

/// Implementation of org.mpris.MediaPlayer2.Quit()
Future<DBusMethodResponse> doQuit() async {
await windowManager.close();
return DBusMethodSuccessResponse();
exit(0);
}

@override
Expand Down

0 comments on commit 353ca79

Please sign in to comment.