Skip to content

Commit

Permalink
Fix exception when running an algorithm which has no parameters
Browse files Browse the repository at this point in the history
through the toolbox

We were passing a float to a PyQt method requiring int in newer
Python versions, which raises an exception instead of silently
truncating.
  • Loading branch information
nyalldawson committed Jul 24, 2023
1 parent 037997a commit 9afb68f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/plugins/processing/gui/MessageBarProgress.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,20 @@ def __init__(self, algname=None):
self.progressMessageBar = \
iface.messageBar().createMessage(self.tr('Executing algorithm <i>{}</i>'.format(algname if algname else '')))
self.progress = QProgressBar()
self.progressChanged.connect(self.progress.setValue)
self.progressChanged.connect(self.set_progress_bar_value)
self.progress.setMaximum(100)
self.progress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
self.progressMessageBar.layout().addWidget(self.progress)
self.message_bar_item = iface.messageBar().pushWidget(self.progressMessageBar,
Qgis.Info)

def set_progress_bar_value(self, progress: float):
"""
Sets the progress bar value to a rounded int of the algorithm's
progress
"""
self.progress.setValue(int(progress))

def reportError(self, msg, fatalError=False):
self.msg.append(msg)

Expand Down

0 comments on commit 9afb68f

Please sign in to comment.