settings: Reset Network SASL status on load
authorShane Synan <digitalcircuit36939@gmail.com>
Tue, 7 Aug 2018 22:25:16 +0000 (17:25 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 23 Aug 2018 00:19:07 +0000 (02:19 +0200)
Explicitly reset IRCv3 capability-based network settings whenever
loading network IDs.  This should help guard against situations where
setNetworkCapStates() does not get called with a NetworkId when
loading, resulting in the template text being left visible.

src/qtui/settingspages/networkssettingspage.cpp
src/qtui/settingspages/networkssettingspage.h

index d8309ad..c1ee10a 100644 (file)
@@ -207,6 +207,9 @@ void NetworksSettingsPage::load()
     sslUpdated();
 #endif
 
     sslUpdated();
 #endif
 
+    // Reset network capability status in case no valid networks get selected (a rare situation)
+    resetNetworkCapStates();
+
     foreach(NetworkId netid, Client::networkIds()) {
         clientNetworkAdded(netid);
     }
     foreach(NetworkId netid, Client::networkIds()) {
         clientNetworkAdded(netid);
     }
@@ -355,10 +358,17 @@ void NetworksSettingsPage::setItemState(NetworkId id, QListWidgetItem *item)
 }
 
 
 }
 
 
+void NetworksSettingsPage::resetNetworkCapStates()
+{
+    // Set the status to a blank (invalid) network ID, reseting all UI
+    setNetworkCapStates(NetworkId());
+}
+
+
 void NetworksSettingsPage::setNetworkCapStates(NetworkId id)
 {
     const Network *net = Client::network(id);
 void NetworksSettingsPage::setNetworkCapStates(NetworkId id)
 {
     const Network *net = Client::network(id);
-    if (Client::isCoreFeatureEnabled(Quassel::Feature::CapNegotiation) && net) {
+    if (net && Client::isCoreFeatureEnabled(Quassel::Feature::CapNegotiation)) {
         // Capability negotiation is supported, network exists.
         // Check if the network is connected.  Don't use net->isConnected() as that won't be true
         // during capability negotiation when capabilities are added and removed.
         // Capability negotiation is supported, network exists.
         // Check if the network is connected.  Don't use net->isConnected() as that won't be true
         // during capability negotiation when capabilities are added and removed.
index 3ce0190..1e32ccd 100644 (file)
@@ -59,6 +59,16 @@ private slots:
     void displayNetwork(NetworkId);
     void setItemState(NetworkId, QListWidgetItem *item = 0);
 
     void displayNetwork(NetworkId);
     void setItemState(NetworkId, QListWidgetItem *item = 0);
 
+    /**
+     * Reset the capability-dependent settings to the default unknown states
+     *
+     * For example, this updates the SASL text to indicate the status is unknown.  Any actual
+     * information should be set by setNetworkCapStates()
+     *
+     * @see NetworksSettingsPage::setNetworkCapStates()
+     */
+    void resetNetworkCapStates();
+
     /**
      * Update the capability-dependent settings according to what the server supports
      *
     /**
      * Update the capability-dependent settings according to what the server supports
      *