Avoid crashing when clicking reload#2283
Conversation
|
Hi @abdelq, thanks for the PR, but I think it's not the right place to catch exceptions. "reload layout" is part of the script API and it should really throw an exception in case of an error. I tried to reproduce the problem on Linux, and there is no crash as the exception is caught higher up in the call stack - namely in
So there is a no systematic issue. When you see a crash on MacOS it's likely because there may be an ABI incompatibility between the Qt shared objects and the application code and that prevents throwing exceptions over Qt library boundaries. I had such cases, when the Qt library is built with a different compiler than the application. This is a general issue and will cause problems in many other places. If the is absolutely no other solution, you can basically put the Matthias |
|
Hello Matthias, I should've uploaded the crash log in the original description: klayout_crash.log
I have an unusual setup, in that, I'm using a Nix-packaged version of KLayout on macOS. It's more likely that it's a case of exceptions escaping a Qt-managed callback on macOS. I haven't touched Qt code in a long time, but I've looked at the docs and they do claim that: "Throwing an exception from a slot invoked by Qt's signal-slot connection mechanism is considered undefined behaviour" I've changed the approach to use I wish I could dig deeper, but the macOS machine is a work one. |
|
The reason why signal/slot exceptions are undefined is that Qt offers to move signals between threads or delay execution. Both cases don't handle exceptions, that's why. Single-threaded direct signal/slot calls just get routed over C++ code generated by MOC and unless they have changed that significantly in Qt 6.11, I can't see why that should lead to lost exceptions. The change you propose is okay and I will merge it, but I still think the reason sits deeper. So I'd expect that you see more crashes in other cases not related to signals and slots. Matthias |

For context, this was happening to me on macOS with files being written to a temporary directory and no longer existing there. I would attempt to reload with the notification and KLayout would crash instead of giving an error message.