function res = isSimscapeBusDialogStale(blockHandle, dialog) 
%

%   Copyright 2018-2020 The MathWorks, Inc.
    
    res = false; 
    
    blockPortHandles = get_param(blockHandle,'PortHandles');
    numPorts = numel(blockPortHandles.LConn);
    
    lineInfo = dialog.getDialogSource.UserData1.LineInfo;
    for i = 1:numPorts
        blockLineHandle = get_param(blockPortHandles.LConn(i),'Line'); 
        
        dialogLineHandle = lineInfo(i).line;
        
        if blockLineHandle==dialogLineHandle 
            if blockLineHandle==-1
                continue;
            end
            isPortConnectedInBlock = get_param(blockLineHandle,'Connected');
            isPortConnectedInDialog = lineInfo(i).isConnected;
            
            if isPortConnectedInBlock~=isPortConnectedInDialog
                res = true;
                return;
            end
        else
            res = true; 
            return;
        end
        
    end
    dialog.getDialogSource.UserData1.LineInfo = lineInfo; 
end
