This PR prevents a potential segfault in the populateDiagnostics function, when the driver disconnects the urg_ pointer is reset. If the diagnostics function is in the middle of execution (it runs in a separate thread) at the time it will try to call a function on an empty pointer. This happened more frequently before PR-102 but it still could potentially happen.
The populateDiagnostics function is accessing urg for things that are static or it already has access to via local variables so I've just refactored the function so it only accesses urg to check if it exists.
Really happy to have other opinions on the solution for this one I just didn't want to add another lock just for diagnostics.
This PR prevents a potential segfault in the populateDiagnostics function, when the driver disconnects the urg_ pointer is reset. If the diagnostics function is in the middle of execution (it runs in a separate thread) at the time it will try to call a function on an empty pointer. This happened more frequently before PR-102 but it still could potentially happen.
The populateDiagnostics function is accessing urg for things that are static or it already has access to via local variables so I've just refactored the function so it only accesses urg to check if it exists.
Really happy to have other opinions on the solution for this one I just didn't want to add another lock just for diagnostics.