jgrulich added a comment.

  That sounds like a bug in NetworkManager, because ActivatingConnection should 
be the one which will become PrimaryConnection, that's what the documentation 
says, that's the reason why we use it. If it's a NM bug, we still need a 
workaround.
  
  In your code, you can simplify it with:
  
    if (connection && !UiUtils::isConnectionTypeSupported(connection->type()) {
        connection = NetworkManager::primaryConnection();
    }
  
  Problem is that isConnectionTypeSupported() will return true if you have 
virtual connections enabled. We should maybe add additional method to to 
UiUtils to identify virtual connections (this new one can be then used inside 
isConnectionTypeSupported())
  
  I would suggest.
  
    bool 
UiUtils::isConnectionTypeVirtual(NetworkManager::ConnectionSettings::ConnectionType
 type)
    {
        if (type == NetworkManager::ConnectionSettings::Bond ||
            type == NetworkManager::ConnectionSettings::Bridge ||
            type == NetworkManager::ConnectionSettings::Infiniband ||
            type == NetworkManager::ConnectionSettings::Team ||
            type == NetworkManager::ConnectionSettings::Vlan) {
            return true
        }
      
       return false;
    }
  
  With this you can simply use
  
    if (connection && isConnectionTypeVirtual(connection->type()) {
        connection = NetworkManager::primaryConnection;
    }

REPOSITORY
  R116 Plasma Network Management Applet

REVISION DETAIL
  https://phabricator.kde.org/D18689

To: rthomas, jgrulich, #plasma
Cc: plasma-devel, jraleigh, GB_2, ragreen, Pitel, ZrenBot, lesliezhai, 
ali-mohamed, jensreuterberg, abetts, sebas, apol, mart

Reply via email to