qt: try even harder not to crash whole app on first start
This commit is contained in:
parent
dd848304e6
commit
363dd12a2a
@ -44,7 +44,7 @@ from electrum.plugin import run_hook
|
||||
from electrum.storage import WalletStorage
|
||||
from electrum.base_wizard import GoBack
|
||||
from electrum.util import (UserCancelled, PrintError, profiler,
|
||||
WalletFileException, BitcoinException)
|
||||
WalletFileException, BitcoinException, get_new_wallet_name)
|
||||
|
||||
from .installwizard import InstallWizard
|
||||
|
||||
@ -263,6 +263,10 @@ class ElectrumGui(PrintError):
|
||||
d = QMessageBox(QMessageBox.Warning, _('Error'),
|
||||
_('Cannot create window for wallet') + ':\n' + str(e))
|
||||
d.exec_()
|
||||
if app_is_starting:
|
||||
wallet_dir = os.path.dirname(path)
|
||||
path = os.path.join(wallet_dir, get_new_wallet_name(wallet_dir))
|
||||
self.start_new_window(path, uri)
|
||||
return
|
||||
if uri:
|
||||
w.pay_to_URI(uri)
|
||||
|
||||
@ -55,7 +55,8 @@ from electrum.util import (format_time, format_satoshis, format_fee_satoshis,
|
||||
export_meta, import_meta, bh2u, bfh, InvalidPassword,
|
||||
base_units, base_units_list, base_unit_name_to_decimal_point,
|
||||
decimal_point_to_base_unit_name, quantize_feerate,
|
||||
UnknownBaseUnit, DECIMAL_POINT_DEFAULT, UserFacingException)
|
||||
UnknownBaseUnit, DECIMAL_POINT_DEFAULT, UserFacingException,
|
||||
get_new_wallet_name)
|
||||
from electrum.transaction import Transaction, TxOutput
|
||||
from electrum.address_synchronizer import AddTransactionException
|
||||
from electrum.wallet import (Multisig_Wallet, CannotBumpFee, Abstract_Wallet,
|
||||
@ -487,13 +488,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||
except FileNotFoundError as e:
|
||||
self.show_error(str(e))
|
||||
return
|
||||
i = 1
|
||||
while True:
|
||||
filename = "wallet_%d" % i
|
||||
if filename in os.listdir(wallet_folder):
|
||||
i += 1
|
||||
else:
|
||||
break
|
||||
filename = get_new_wallet_name(wallet_folder)
|
||||
full_path = os.path.join(wallet_folder, filename)
|
||||
self.gui_object.start_new_window(full_path, None)
|
||||
|
||||
|
||||
@ -413,6 +413,17 @@ def assert_file_in_datadir_available(path, config_path):
|
||||
'Should be at {}'.format(path))
|
||||
|
||||
|
||||
def get_new_wallet_name(wallet_folder: str) -> str:
|
||||
i = 1
|
||||
while True:
|
||||
filename = "wallet_%d" % i
|
||||
if filename in os.listdir(wallet_folder):
|
||||
i += 1
|
||||
else:
|
||||
break
|
||||
return filename
|
||||
|
||||
|
||||
def assert_bytes(*args):
|
||||
"""
|
||||
porting helper, assert args type
|
||||
|
||||
Loading…
Reference in New Issue
Block a user