chat: better handle case where network reachability is unknown

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
Jared Van Bortel 2024-02-27 13:14:24 -05:00 committed by AT
parent c19b763e03
commit 0fc071d228

View File

@ -42,8 +42,11 @@ LLM::LLM()
m_compatHardware = minimal; m_compatHardware = minimal;
QNetworkInformation::loadDefaultBackend(); QNetworkInformation::loadDefaultBackend();
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, auto * netinfo = QNetworkInformation::instance();
this, &LLM::isNetworkOnlineChanged); if (netinfo) {
connect(netinfo, &QNetworkInformation::reachabilityChanged,
this, &LLM::isNetworkOnlineChanged);
}
} }
bool LLM::hasSettingsAccess() const bool LLM::hasSettingsAccess() const
@ -108,8 +111,6 @@ QString LLM::systemTotalRAMInGBString() const
bool LLM::isNetworkOnline() const bool LLM::isNetworkOnline() const
{ {
if (!QNetworkInformation::instance()) auto * netinfo = QNetworkInformation::instance();
return false; return !netinfo || netinfo->reachability() == QNetworkInformation::Reachability::Online;
return QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online;
} }