QNetworkInformation on RPI4b causing Segmentation Fault
-
Hey all, I am trying to use the QNetworkInformation class to do some basic checks about weather or not the current system is connected to a wifi network is able to reach the internet. It seems like a perfect solution to my use case except that whenever I try to call either networkInformation→supportedFeatures() or networkInformation→reachability(), I get a segmentation fault and my program exits. I am a little confused on why this is happening and if there is any way to fix it. I am currently working on a Raspberry pi4b with the default Raspbian OS on it. When I run program before the Seg fault occurs I get the following warning msgs which seems to be a part of this issue, but it is completely beyond me if there is a way to rectify/fix these msgs.
Has anyone run into something like this before?
Warning Messages:
qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "stateChanged" qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "connectivityChanged" qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "deviceTypeChanged" qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "meteredChanged"
Code Snippet:
void checkInternetConnectivity(){ QNetworkInformation *networkInformation = QNetworkInformation::instance(); qDebug() << networkInformation->availableBackends(); bool result = networkInformation->loadDefaultBackend(); qDebug() << "loaded backend: " << result; qDebug() << "Features:" << networkInformation->supportedFeatures(); // qDebug() << networkInformation->reachability(); }
Thanks for any help ahead of time
-
@WallPulse said in QNetworkInformation on RPI4b causing Segmentation Fault:
It seems like a perfect solution to my use case except that whenever I try to call either networkInformation→supportedFeatures() or networkInformation→reachability(), I get a segmentation fault and my program exits. I
Have you checked that
networkInformation
is not null?From the docs:
QNetworkInformation is a singleton and stays alive from the first successful load() until destruction of the QCoreApplication object.
Have you called QNetworkInformation::load(), or one of its replacements, before calling QNetworkInformation::instance()?
-