Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[console] Allow breaking execution of scripts via Ctrl-C #6213

Merged
merged 1 commit into from
Feb 2, 2018

Conversation

nyalldawson
Copy link
Collaborator

This allows (in some circumstances) scripts running in the console to be halted via the Ctrl (or Meta) + C shortcut.

(It's only possible to catch and abort when the script is printing outputs to the console - because this triggers QCoreApplication.processEvents() calls. Without these calls the whole QGIS application is unresponsive during script execution and there's no ability to even catch a shortcut in order to halt the execution.

Still, even with this limitation it's handy to be able to break out of lengthy:

for f in iface.activeLayer().getFeatures():
print(f.attributes())

loops!)

This allows (in some circumstances) scripts running in the console
to be halted via the Ctrl (or Meta) + C shortcut.

(It's only possible to catch and abort when the script is printing
outputs to the console - because this triggers
QCoreApplication.processEvents() calls. Without these calls the
whole QGIS application is unresponsive during script execution
and there's no ability to even catch a shortcut in order to
halt the execution.

Still, even with this limitation it's handy to be able to
break out of lengthy:

for f in iface.activeLayer().getFeatures():
    print(f.attributes())

loops!)
@nyalldawson
Copy link
Collaborator Author

On a hack level of 0 (not a hack) to 10 (gross hack) this is a 7.

@3nids
Copy link
Member

3nids commented Feb 2, 2018

I'm fine with this hack, it brings a nice feature and it's not a ton of code. Merge?

@NathanW2
Copy link
Member

NathanW2 commented Feb 2, 2018 via email

@jef-n jef-n merged commit ad21d37 into qgis:master Feb 2, 2018
@jef-n
Copy link
Member

jef-n commented Feb 2, 2018

too much noise... ;)

@nyalldawson nyalldawson deleted the interrupt_console branch February 28, 2018 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants