Skip to content

Commit

Permalink
Bugfix: Fixing error when closing wallets due to alosed asyncio loop (#…
Browse files Browse the repository at this point in the history
…73)

- the fix is in nostr-chat  0.6.2
- fixing also a mac workflow bug
actions/runner-images#7522
  • Loading branch information
andreasgriffin authored Jan 25, 2025
1 parent 51d0b3f commit 9527f56
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 73 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/build-mac-arm.yml

This file was deleted.

2 changes: 1 addition & 1 deletion bitcoin_safe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# this is the source of the version information
__version__ = "1.0.3"
__version__ = "1.0.4"
43 changes: 33 additions & 10 deletions bitcoin_safe/gui/qt/qt_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

import bdkpython as bdk
from bitcoin_qr_tools.data import Data
from PyQt6.QtCore import Qt, QTimer, pyqtSignal
from PyQt6.QtCore import Qt, QTimer, pyqtBoundSignal, pyqtSignal
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import (
QApplication,
Expand Down Expand Up @@ -287,15 +287,17 @@ def __init__(
self.quick_receive.update_content(UpdateFilter(refresh_all=True))

#### connect signals
self.signal_on_change_sync_status.connect(self.update_status_visualization)
self.signals.language_switch.connect(self.updateUi)
self.wallet_signals.updated.connect(self.signals.any_wallet_updated.emit)
self.wallet_signals.export_labels.connect(self.export_labels)
self.wallet_signals.export_bip329_labels.connect(self.export_bip329_labels)
self.wallet_signals.import_labels.connect(self.import_labels)
self.wallet_signals.import_bip329_labels.connect(self.import_bip329_labels)
self.wallet_signals.import_electrum_wallet_labels.connect(self.import_electrum_wallet_labels)
self.signal_on_change_sync_status.connect(self.update_display_balance)
self.connect_signal(self.signal_on_change_sync_status, self.update_status_visualization)
self.connect_signal(self.signals.language_switch, self.updateUi)
self.connect_signal(self.wallet_signals.updated, self.signals.any_wallet_updated.emit)
self.connect_signal(self.wallet_signals.export_labels, self.export_labels)
self.connect_signal(self.wallet_signals.export_bip329_labels, self.export_bip329_labels)
self.connect_signal(self.wallet_signals.import_labels, self.import_labels)
self.connect_signal(self.wallet_signals.import_bip329_labels, self.import_bip329_labels)
self.connect_signal(
self.wallet_signals.import_electrum_wallet_labels, self.import_electrum_wallet_labels
)
self.connect_signal(self.signal_on_change_sync_status, self.update_display_balance)

self._start_sync_retry_timer()
self._start_sync_regularly_timer()
Expand Down Expand Up @@ -427,6 +429,27 @@ def stop_sync_timer(self) -> None:
self.timer_sync_retry.stop()
self.timer_sync_regularly.stop()

def disconnect_signals(self) -> None:
def discon_sig(signal: pyqtBoundSignal):
"""
Disconnect only breaks one connection at a time,
so loop to be safe.
"""
while True:
try:
signal.disconnect()
except TypeError:
break
return

super().disconnect_signals()
signals = self.wallet_signals
for signal_name in dir(signals):
signal = getattr(signals, signal_name)
if not isinstance(signal, pyqtBoundSignal):
continue
discon_sig(signal)

def close(self) -> None:
self.disconnect_signals()
self.label_syncer.send_all_labels_to_myself()
Expand Down
17 changes: 13 additions & 4 deletions bitcoin_safe/gui/qt/signal_carrying_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import logging
from typing import Callable, List, Tuple

from PyQt6.QtCore import QObject
from PyQt6.QtCore import QObject, pyqtBoundSignal

from bitcoin_safe.typestubs import TypedPyQtSignal, TypedPyQtSignalNo

from ...signals import SignalFunction

Expand All @@ -40,9 +42,16 @@
class SignalCarryingObject(QObject):
def __init__(self, parent=None, **kwargs) -> None:
super().__init__(parent, **kwargs)
self._connected_signals: List[Tuple[SignalFunction, Callable]] = []

def connect_signal(self, signal, f, **kwargs) -> None:
self._connected_signals: List[
Tuple[SignalFunction | pyqtBoundSignal | TypedPyQtSignalNo | TypedPyQtSignal, Callable]
] = []

def connect_signal(
self,
signal: SignalFunction | pyqtBoundSignal | TypedPyQtSignalNo | TypedPyQtSignal,
f: Callable,
**kwargs
) -> None:
signal.connect(f, **kwargs)
self._connected_signals.append((signal, f))

Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ line-length = 110
name = "bitcoin-safe"
# the version here and in all other places in this toml are updated automatically
# from the source: bitcoin_safe/__init__.py
version = "1.0.3"
version = "1.0.4"
description = "A bitcoin savings wallet for the entire family."
authors = [ "andreasgriffin <[email protected]>",]
license = "GPL-3.0"
Expand Down Expand Up @@ -42,7 +42,7 @@ numpy = "2.2.1" # error in wine/pyinstaller when increased
# bitcoin-nostr-chat = {path="../bitcoin-nostr-chat"} # "^0.2.6"
# bitcoin-usb = {path="../bitcoin-usb"} # "^0.3.3"
bitcoin-qr-tools = "^1.0.3"
bitcoin-nostr-chat = "^0.6.1" # { git = "https://github.com/andreasgriffin/bitcoin-nostr-chat.git", rev = "1707c7479d9de4c1915f2b0d907b27f58703e7c0" }
bitcoin-nostr-chat = "^0.6.2" # { git = "https://github.com/andreasgriffin/bitcoin-nostr-chat.git", rev = "fda38f7c4879fbced753a8d3466d50c571c06769" }
bitcoin-usb = "^0.7.4"
pysocks = "^1.7.1"

Expand Down
21 changes: 15 additions & 6 deletions tools/build-mac/make_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,21 @@ info "Finished building unsigned dist/${PACKAGE}.app. This hash should be reprod
find "dist/${PACKAGE}.app" -type f -print0 | sort -z | xargs -0 shasum -a 256 | shasum -a 256

info "Creating unsigned .DMG"
hdiutil create \
-fs HFS+ \
-volname "$PACKAGE" \
-srcfolder "dist/$PACKAGE.app" \
"dist/bitcoin_safe-$VERSION-unsigned.dmg" \
|| fail "Could not create .DMG"
# Workaround resource busy bug on github on MacOS 13
# https://github.com/actions/runner-images/issues/7522
i=0
until hdiutil create \
-fs HFS+ \
-volname "$PACKAGE" \
-srcfolder "dist/$PACKAGE.app" \
"dist/bitcoin_safe-$VERSION-unsigned.dmg"
do
if [ $i -eq 10 ]; then
fail "Could not create .DMG";
fi
i=$((i+1))
sleep 1
done

info "Done. The .app and .dmg are *unsigned* and will trigger macOS Gatekeeper warnings."
info "To ship, you’ll need to sign and notarize. See: sign_osx.sh"

0 comments on commit 9527f56

Please sign in to comment.