comparison layer/WaveformLayer.cpp @ 853:99f96cacde36

Fix some potential divide by zeros (from coverity scan)
author Chris Cannam
date Wed, 03 Sep 2014 11:53:43 +0100
parents 4c8ca536b54f
children d282967236d5
comparison
equal deleted inserted replaced
852:6c6e34b09688 853:99f96cacde36
44 m_channel(-1), 44 m_channel(-1),
45 m_scale(LinearScale), 45 m_scale(LinearScale),
46 m_middleLineHeight(0.5), 46 m_middleLineHeight(0.5),
47 m_aggressive(false), 47 m_aggressive(false),
48 m_cache(0), 48 m_cache(0),
49 m_cacheValid(false) 49 m_cacheValid(false),
50 m_cacheZoomLevel(0)
50 { 51 {
51 52
52 } 53 }
53 54
54 WaveformLayer::~WaveformLayer() 55 WaveformLayer::~WaveformLayer()
1040 int channels = 0, minChannel = 0, maxChannel = 0; 1041 int channels = 0, minChannel = 0, maxChannel = 0;
1041 bool mergingChannels = false, mixingChannels = false; 1042 bool mergingChannels = false, mixingChannels = false;
1042 1043
1043 channels = getChannelArrangement(minChannel, maxChannel, 1044 channels = getChannelArrangement(minChannel, maxChannel,
1044 mergingChannels, mixingChannels); 1045 mergingChannels, mixingChannels);
1045 1046 if (channels == 0) return 0;
1046 if (maxChannel < minChannel || channel < minChannel) return 0; 1047 if (maxChannel < minChannel || channel < minChannel) return 0;
1047 1048
1048 int h = v->height(); 1049 int h = v->height();
1049 int m = (h / channels) / 2; 1050 int m = (h / channels) / 2;
1050 1051
1083 int channels = 0, minChannel = 0, maxChannel = 0; 1084 int channels = 0, minChannel = 0, maxChannel = 0;
1084 bool mergingChannels = false, mixingChannels = false; 1085 bool mergingChannels = false, mixingChannels = false;
1085 1086
1086 channels = getChannelArrangement(minChannel, maxChannel, 1087 channels = getChannelArrangement(minChannel, maxChannel,
1087 mergingChannels, mixingChannels); 1088 mergingChannels, mixingChannels);
1088 1089 if (channels == 0) return 0;
1089 if (maxChannel < minChannel) return 0; 1090 if (maxChannel < minChannel) return 0;
1090 1091
1091 int h = v->height(); 1092 int h = v->height();
1092 int m = (h / channels) / 2; 1093 int m = (h / channels) / 2;
1093 1094