qiskit-community / qiskit-metal

Quantum Hardware Design. Open-source project for engineers and scientists to design superconducting quantum devices with ease.
https://qiskit-community.github.io/qiskit-metal/
Apache License 2.0
288 stars 208 forks source link

Can't cancel during saving file. #669

Closed ghost closed 2 years ago

ghost commented 3 years ago

Information

What is the current behavior?

Choose save as but instead of saving a file, click cancel. The app will crash.

Steps to reproduce the problem

Choose save as but instead of saving a file, click cancel. The app will crash.

What is the expected behavior?

Choose save as but instead of saving a file, click cancel. The app should close the file-name-choosing window and not save a copy of the chip

Suggested solutions

chauhan-shobhit commented 2 years ago

Observed this issue when saving the design from MetalGUI. App did not crash on my system but there were exceptions when using 'cancel' .

QFileDialog.getSaveFileName returns empty string as filename - ( https://github.com/Qiskit/qiskit-metal/blob/main/qiskit_metal/_gui/main_window.py#L163 ) This caused a FileNotFoundError during opening of file (https://github.com/Qiskit/qiskit-metal/blob/main/qiskit_metal/_gui/main_window.py#L171).

To fix the issue , an empty check was added. File will be opened and written to only if filename is non-empty (length of string is non-zero)