URI: 
       tfix #4575 - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 4284f4feb3e35e2d5c9b1d274081d4da126bab92
   DIR parent f8e13c5c330c892698356ec35858785ce8dc012f
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Sat, 21 Jul 2018 23:09:46 +0200
       
       fix #4575
       
       Diffstat:
         M electrum/gui/kivy/main_window.py    |      11 +++++++++--
         M electrum/gui/kivy/uix/dialogs/qr_d… |       5 +++--
         M electrum/gui/kivy/uix/dialogs/tx_d… |       5 +++--
         M electrum/gui/kivy/uix/qrcodewidget… |      15 ++++++++++++---
         M electrum/gui/qt/transaction_dialog… |       8 +++++++-
       
       5 files changed, 34 insertions(+), 10 deletions(-)
       ---
   DIR diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py
       t@@ -391,9 +391,16 @@ class ElectrumWindow(App):
                popup.export = self.export_private_keys
                popup.open()
        
       -    def qr_dialog(self, title, data, show_text=False):
       +    def qr_dialog(self, title, data, show_text=False, text_for_clipboard=None):
                from .uix.dialogs.qr_dialog import QRDialog
       -        popup = QRDialog(title, data, show_text)
       +        def on_qr_failure():
       +            popup.dismiss()
       +            msg = _('Failed to display QR code.')
       +            if text_for_clipboard:
       +                msg += '\n' + _('Text copied to clipboard.')
       +                self._clipboard.copy(text_for_clipboard)
       +            Clock.schedule_once(lambda dt: self.show_info(msg))
       +        popup = QRDialog(title, data, show_text, on_qr_failure)
                popup.open()
        
            def scan_qr(self, on_complete):
   DIR diff --git a/electrum/gui/kivy/uix/dialogs/qr_dialog.py b/electrum/gui/kivy/uix/dialogs/qr_dialog.py
       t@@ -36,11 +36,12 @@ Builder.load_string('''
        ''')
        
        class QRDialog(Factory.Popup):
       -    def __init__(self, title, data, show_text):
       +    def __init__(self, title, data, show_text, failure_cb=None):
                Factory.Popup.__init__(self)
                self.title = title
                self.data = data
                self.show_text = show_text
       +        self.failure_cb = failure_cb
        
            def on_open(self):
       -        self.ids.qr.set_data(self.data)
       +        self.ids.qr.set_data(self.data, self.failure_cb)
   DIR diff --git a/electrum/gui/kivy/uix/dialogs/tx_dialog.py b/electrum/gui/kivy/uix/dialogs/tx_dialog.py
       t@@ -179,6 +179,7 @@ class TxDialog(Factory.Popup):
        
            def show_qr(self):
                from electrum.bitcoin import base_encode, bfh
       -        text = bfh(str(self.tx))
       +        raw_tx = str(self.tx)
       +        text = bfh(raw_tx)
                text = base_encode(text, base=43)
       -        self.app.qr_dialog(_("Raw Transaction"), text)
       +        self.app.qr_dialog(_("Raw Transaction"), text, text_for_clipboard=raw_tx)
   DIR diff --git a/electrum/gui/kivy/uix/qrcodewidget.py b/electrum/gui/kivy/uix/qrcodewidget.py
       t@@ -5,6 +5,7 @@ from threading import Thread
        from functools import partial
        
        import qrcode
       +from qrcode import exceptions
        
        from kivy.uix.floatlayout import FloatLayout
        from kivy.graphics.texture import Texture
       t@@ -50,15 +51,23 @@ class QRCodeWidget(FloatLayout):
                self.data = None
                self.qr = None
                self._qrtexture = None
       +        self.failure_cb = None
        
            def on_data(self, instance, value):
                if not (self.canvas or value):
                    return
       -        self.update_qr()
       -
       -    def set_data(self, data):
       +        try:
       +            self.update_qr()
       +        except qrcode.exceptions.DataOverflowError:
       +            if self.failure_cb:
       +                self.failure_cb()
       +            else:
       +                raise
       +
       +    def set_data(self, data, failure_cb=None):
                if self.data == data:
                    return
       +        self.failure_cb = failure_cb
                MinSize = 210 if len(data) < 128 else 500
                self.setMinimumSize((MinSize, MinSize))
                self.data = data
   DIR diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py
       t@@ -31,6 +31,9 @@ from PyQt5.QtCore import *
        from PyQt5.QtGui import *
        from PyQt5.QtWidgets import *
        
       +import qrcode
       +from qrcode import exceptions
       +
        from electrum.bitcoin import base_encode
        from electrum.i18n import _
        from electrum.plugin import run_hook
       t@@ -183,8 +186,11 @@ class TxDialog(QDialog, MessageBoxMixin):
                text = base_encode(text, base=43)
                try:
                    self.main_window.show_qrcode(text, 'Transaction', parent=self)
       +        except qrcode.exceptions.DataOverflowError:
       +            self.show_error(_('Failed to display QR code.') + '\n' +
       +                            _('Transaction is too large in size.'))
                except Exception as e:
       -            self.show_message(str(e))
       +            self.show_error(_('Failed to display QR code.') + '\n' + str(e))
        
            def sign(self):
                def sign_done(success):