Skip to content

Commit

Permalink
Workaround for a Qt 5.15 bug on Windows causing the app to enter an i…
Browse files Browse the repository at this point in the history
…nfinite loop when copying text to the clipboard in protx-related dialogs.
  • Loading branch information
Bertrand256 committed Jun 19, 2023
1 parent aba79c0 commit ee41c91
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/reg_masternode_dlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
from typing import List, Callable, Optional
import ipaddress
import time

from PyQt5.QtCore import pyqtSlot, Qt, QTimerEvent, QTimer
from PyQt5.QtWidgets import QDialog, QMessageBox, QApplication, QWidget
Expand Down Expand Up @@ -224,12 +225,14 @@ def update_styles(self):

self.lblProtxSummary1.setStyleSheet(f'QLabel{{color:{green_color};font-weight: bold}}')

def strip_clipboard_contents(self, _):
def strip_clipboard_contents(self, mode):
""" Remove leading/trailing spaces and newline characters from a text copied do clipboard."""
try:
cl = QApplication.clipboard()
t = cl.text()
if t:
if t and t.strip() != t:
# QClipboard.blockSignals not working with QT 5.15 on Windows, so we need the above additional
# protection to avoid infinite loop when setting a new clipboard value
cl.blockSignals(True)
try:
cl.setText(t.strip())
Expand Down
6 changes: 4 additions & 2 deletions src/revoke_mn_dlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ def onThemeChanged(self):
def update_styles(self):
self.update_manual_cmd_info()

def strip_clipboard_contents(self, _):
def strip_clipboard_contents(self, mode):
""" Remove leading/trailing spaces and newline characters from a text copied do clipboard."""
try:
cl = QApplication.clipboard()
t = cl.text()
if t:
if t and t.strip() != t:
# QClipboard.blockSignals not working with QT 5.15 on Windows, so we need the above additional
# protection to avoid infinite loop when setting a new clipboard value
cl.blockSignals(True)
try:
cl.setText(t.strip())
Expand Down
6 changes: 4 additions & 2 deletions src/upd_mn_registrar_dlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ def onThemeChanged(self):
def update_styles(self):
self.update_manual_cmd_info()

def strip_clipboard_contents(self, _):
def strip_clipboard_contents(self, mode):
""" Remove leading/trailing spaces and newline characters from a text copied do clipboard."""
try:
cl = QApplication.clipboard()
t = cl.text()
if t:
if t and t.strip() != t:
# QClipboard.blockSignals not working with QT 5.15 on Windows, so we need the above additional
# protection to avoid infinite loop when setting a new clipboard value
cl.blockSignals(True)
try:
cl.setText(t.strip())
Expand Down
6 changes: 4 additions & 2 deletions src/upd_mn_service_dlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@ def onThemeChanged(self):
def update_styles(self):
self.update_manual_cmd_info()

def strip_clipboard_contents(self, _):
def strip_clipboard_contents(self, mode):
""" Remove leading/trailing spaces and newline characters from a text copied do clipboard."""
try:
cl = QApplication.clipboard()
t = cl.text()
if t:
if t and t.strip() != t:
# QClipboard.blockSignals not working with QT 5.15 on Windows, so we need the above additional
# protection to avoid infinite loop when setting a new clipboard value
cl.blockSignals(True)
try:
cl.setText(t.strip())
Expand Down

0 comments on commit ee41c91

Please sign in to comment.