# HG changeset patch # User Chris Cannam # Date 1410276981 -3600 # Node ID 4a5d144bd5d0820a418e64d954d0ea3b0e0eeee4 # Parent 8432d2551fb2261a43506c3a24432270910e7b0d# Parent d282967236d54945432cdfe5dbce0763d26488cc Merge from default branch diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/Colour3DPlotLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -109,7 +109,7 @@ void Colour3DPlotLayer::cacheInvalid(int startFrame, int endFrame) { - if (!m_cache) return; + if (!m_cache || !m_model) return; int modelResolution = m_model->getResolution(); int start = startFrame / modelResolution; @@ -1529,7 +1529,9 @@ int sx0i = int(sx0 + epsilon); if (sx0i >= sw) break; - float a, b, value; + float a = float(sourceLine[sx0i]); + float b = a; + float value; float sx1 = sxa[x*2+1]; if (sx1 > sx0 + 1.f) { diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/FlexiNoteLayer.cpp --- a/layer/FlexiNoteLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/FlexiNoteLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -62,8 +62,14 @@ m_model(0), m_editing(false), m_intelligentActions(true), + m_dragPointX(0), + m_dragPointY(0), + m_dragStartX(0), + m_dragStartY(0), m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), + m_greatestLeftNeighbourFrame(0), + m_smallestRightNeighbourFrame(0), m_editingCommand(0), m_verticalScale(AutoAlignScale), m_editMode(DragNote), diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/NoteLayer.cpp --- a/layer/NoteLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/NoteLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -49,6 +49,10 @@ SingleColourLayer(), m_model(0), m_editing(false), + m_dragPointX(0), + m_dragPointY(0), + m_dragStartX(0), + m_dragStartY(0), m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), m_editingCommand(0), diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/RegionLayer.cpp --- a/layer/RegionLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/RegionLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -47,6 +47,10 @@ SingleColourLayer(), m_model(0), m_editing(false), + m_dragPointX(0), + m_dragPointY(0), + m_dragStartX(0), + m_dragStartY(0), m_originalPoint(0, 0.0, 0, tr("New Region")), m_editingPoint(0, 0.0, 0, tr("New Region")), m_editingCommand(0), @@ -564,13 +568,21 @@ i = close.begin(); // Scan through the close points first, then the more distant ones - // if no suitable close one is found + // if no suitable close one is found. So the while-termination + // condition here can only happen once i has passed through the + // whole of the close container and then the whole of the separate + // points container. The two iterators are totally distinct, but + // have the same type so we cheekily use the same variable and a + // single loop for both. while (i != points.end()) { - if (i == close.end()) { - i = points.begin(); - distant = true; + if (!distant) { + if (i == close.end()) { + // switch from the close container to the points container + i = points.begin(); + distant = true; + } } if (snap == SnapRight) { diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/SliceLayer.cpp --- a/layer/SliceLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/SliceLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -396,7 +396,9 @@ float max = 0.f; for (int bin = 0; bin < mh; ++bin) { - if (m_samplingMode == SampleMean) m_values[bin] /= divisor; + if (m_samplingMode == SampleMean && divisor > 0) { + m_values[bin] /= divisor; + } if (m_values[bin] > max) max = m_values[bin]; } if (max != 0.f && m_normalize) { diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/SpectrogramLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -1445,7 +1445,7 @@ if (!fft->isColumnAvailable(s)) continue; - float binfreq = (sr * q) / m_windowSize; + float binfreq = (float(sr) * q) / m_windowSize; if (q == q0i) freqMin = binfreq; if (q == q1i) freqMax = binfreq; @@ -2479,7 +2479,7 @@ FFTModel::PeakSet peakfreqs; - int px = -1, psx = -1; + int psx = -1; #ifdef __GNUC__ float values[maxbin - minbin + 1]; @@ -2500,7 +2500,6 @@ for (int sx = sx0; sx < sx1; ++sx) { - if (x == px && sx == psx) continue; if (sx < 0 || sx >= int(fft->getWidth())) continue; if (!m_synchronous) { @@ -2931,7 +2930,7 @@ // SVDEBUG << "SpectrogramLayer::setDisplayExtents: " << min << "->" << max << endl; if (min < 0) min = 0; - if (max > m_model->getSampleRate()/2) max = m_model->getSampleRate()/2; + if (max > m_model->getSampleRate()/2.f) max = m_model->getSampleRate()/2.f; int minf = lrintf(min); int maxf = lrintf(max); diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/TextLayer.cpp --- a/layer/TextLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/TextLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -336,7 +336,7 @@ QPoint localPos; TextModel::Point illuminatePoint(0); - bool shouldIlluminate; + bool shouldIlluminate = false; if (v->shouldIlluminateLocalFeatures(this, localPos)) { shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/TimeValueLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -733,13 +733,21 @@ i = close.begin(); // Scan through the close points first, then the more distant ones - // if no suitable close one is found + // if no suitable close one is found. So the while-termination + // condition here can only happen once i has passed through the + // whole of the close container and then the whole of the separate + // points container. The two iterators are totally distinct, but + // have the same type so we cheekily use the same variable and a + // single loop for both. while (i != points.end()) { - if (i == close.end()) { - i = points.begin(); - distant = true; + if (!distant) { + if (i == close.end()) { + // switch from the close container to the points container + i = points.begin(); + distant = true; + } } if (snap == SnapRight) { @@ -1788,7 +1796,10 @@ (0, tr("Choose value calculation"), text, options, prevSelection, &ok); - if (!ok) return false; + if (!ok) { + delete command; + return false; + } int selection = 0; generation = Labeller::ValueNone; diff -r 8432d2551fb2 -r 4a5d144bd5d0 layer/WaveformLayer.cpp --- a/layer/WaveformLayer.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/layer/WaveformLayer.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -46,7 +46,8 @@ m_middleLineHeight(0.5), m_aggressive(false), m_cache(0), - m_cacheValid(false) + m_cacheValid(false), + m_cacheZoomLevel(0) { } @@ -457,8 +458,8 @@ int minChannel = 0, maxChannel = 0; bool mergingChannels = false, mixingChannels = false; - getChannelArrangement(minChannel, maxChannel, - mergingChannels, mixingChannels); + (void)getChannelArrangement(minChannel, maxChannel, + mergingChannels, mixingChannels); if (mergingChannels || mixingChannels) { RangeSummarisableTimeValueModel::Range otherRange = @@ -1042,7 +1043,7 @@ channels = getChannelArrangement(minChannel, maxChannel, mergingChannels, mixingChannels); - + if (channels == 0) return 0; if (maxChannel < minChannel || channel < minChannel) return 0; int h = v->height(); @@ -1085,7 +1086,7 @@ channels = getChannelArrangement(minChannel, maxChannel, mergingChannels, mixingChannels); - + if (channels == 0) return 0; if (maxChannel < minChannel) return 0; int h = v->height(); diff -r 8432d2551fb2 -r 4a5d144bd5d0 view/Overview.cpp --- a/view/Overview.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/view/Overview.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -27,7 +27,8 @@ Overview::Overview(QWidget *w) : View(w, false), - m_clickedInRange(false) + m_clickedInRange(false), + m_dragCentreFrame(0) { setObjectName(tr("Overview")); m_followPan = false; diff -r 8432d2551fb2 -r 4a5d144bd5d0 view/Pane.cpp --- a/view/Pane.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/view/Pane.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -419,10 +419,10 @@ if (e) paint.setClipRect(r); - ViewManager::ToolMode toolMode = m_manager->getToolModeFor(this); + ViewManager::ToolMode toolMode = ViewManager::NavigateMode; + if (m_manager) toolMode = m_manager->getToolModeFor(this); if (m_manager && -// !m_manager->isPlaying() && m_mouseInWidget && toolMode == ViewManager::MeasureMode) { @@ -495,6 +495,7 @@ paint.setPen(QColor(50, 50, 50)); if (waveformModel && + sampleRate && m_manager && m_manager->shouldShowDuration()) { drawDurationAndRate(r, waveformModel, sampleRate, paint); @@ -1093,8 +1094,9 @@ if (m_scaleWidth > 0) { - for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { - --vi; + Layer *layer = getTopLayer(); + + if (layer) { paint.save(); @@ -1103,12 +1105,11 @@ paint.drawRect(xorigin, -1, m_scaleWidth, height()+1); paint.setBrush(Qt::NoBrush); - (*vi)->paintVerticalScale + layer->paintVerticalScale (this, m_manager->shouldShowVerticalColourScale(), paint, QRect(xorigin, 0, m_scaleWidth, height())); paint.restore(); - break; } } @@ -1127,12 +1128,11 @@ int formerScaleWidth = m_scaleWidth; if (m_manager && m_manager->shouldShowVerticalScale()) { - for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { - --vi; + Layer *layer = getTopLayer(); + if (layer) { QPainter paint(image); - m_scaleWidth = (*vi)->getVerticalScaleWidth + m_scaleWidth = layer->getVerticalScaleWidth (this, m_manager->shouldShowVerticalColourScale(), paint); - break; } } else { m_scaleWidth = 0; @@ -1164,11 +1164,10 @@ int sw = 0; if (m_manager && m_manager->shouldShowVerticalScale()) { - for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { - --vi; - sw = (*vi)->getVerticalScaleWidth + Layer *layer = getTopLayer(); + if (layer) { + sw = layer->getVerticalScaleWidth (this, m_manager->shouldShowVerticalColourScale(), paint); - break; } } @@ -1454,7 +1453,7 @@ void Pane::mouseReleaseEvent(QMouseEvent *e) { - if (e->buttons() & Qt::RightButton) { + if (e && (e->buttons() & Qt::RightButton)) { return; } @@ -1582,7 +1581,7 @@ void Pane::mouseMoveEvent(QMouseEvent *e) { - if (e->buttons() & Qt::RightButton) { + if (!e || (e->buttons() & Qt::RightButton)) { return; } @@ -1634,7 +1633,7 @@ } } - if (!m_manager->isPlaying()) { + if (m_manager && !m_manager->isPlaying()) { bool updating = false; @@ -1651,8 +1650,7 @@ } } - if (!updating && mode == ViewManager::MeasureMode && - m_manager && !m_manager->isPlaying()) { + if (!updating && mode == ViewManager::MeasureMode) { Layer *layer = getTopLayer(); if (layer && layer->nearestMeasurementRectChanged @@ -2127,7 +2125,8 @@ bool doScroll = false; if (!m_manager) doScroll = true; - if (!m_manager->isPlaying()) doScroll = true; + else if (!m_manager->isPlaying()) doScroll = true; + if (m_followPlay != PlaybackScrollContinuous) doScroll = true; if (doScroll) { @@ -2173,7 +2172,7 @@ if (mode == ViewManager::SelectMode) { m_clickedInRange = false; - m_manager->clearInProgressSelection(); + if (m_manager) m_manager->clearInProgressSelection(); emit doubleClickSelectInvoked(getFrameForX(e->x())); return; } diff -r 8432d2551fb2 -r 4a5d144bd5d0 view/PaneStack.cpp --- a/view/PaneStack.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/view/PaneStack.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -99,10 +99,8 @@ currentIndicator->setVisible(m_showAccessories); int initialCentreFrame = -1; - for (int i = 0; i < (int)m_panes.size(); ++i) { - int f = m_panes[i].pane->getCentreFrame(); - initialCentreFrame = f; - break; + if (!m_panes.empty()) { + initialCentreFrame = m_panes[0].pane->getCentreFrame(); } Pane *pane = new Pane(frame); diff -r 8432d2551fb2 -r 4a5d144bd5d0 view/View.cpp --- a/view/View.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/view/View.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -1312,7 +1312,7 @@ int View::alignFromReference(int f) const { - if (!m_manager->getAlignMode()) return f; + if (!m_manager || !m_manager->getAlignMode()) return f; Model *aligningModel = getAligningModel(); if (!aligningModel) return f; return aligningModel->alignFromReference(f); @@ -1330,6 +1330,7 @@ int View::getAlignedPlaybackFrame() const { + if (!m_manager) return 0; int pf = m_manager->getPlaybackFrame(); if (!m_manager->getAlignMode()) return pf; diff -r 8432d2551fb2 -r 4a5d144bd5d0 widgets/Fader.cpp --- a/widgets/Fader.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/widgets/Fader.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -48,7 +48,9 @@ m_value(1.0), m_peakLeft(0.0), m_peakRight(0.0), - m_mousePressed(false) + m_mousePressed(false), + m_mousePressX(0), + m_mousePressValue(0) { setMinimumSize(116, 23); setMaximumSize(116, 23); diff -r 8432d2551fb2 -r 4a5d144bd5d0 widgets/ItemEditDialog.cpp --- a/widgets/ItemEditDialog.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/widgets/ItemEditDialog.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -32,6 +32,9 @@ QString valueUnits, QWidget *parent) : QDialog(parent), m_sampleRate(sampleRate), + m_defaultFrame(0), + m_defaultDuration(0), + m_defaultValue(0), m_frameTimeSpinBox(0), m_realTimeSecsSpinBox(0), m_realTimeUSecsSpinBox(0), diff -r 8432d2551fb2 -r 4a5d144bd5d0 widgets/KeyReference.cpp --- a/widgets/KeyReference.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/widgets/KeyReference.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -24,6 +24,7 @@ #include KeyReference::KeyReference() : + m_text(0), m_dialog(0) { } diff -r 8432d2551fb2 -r 4a5d144bd5d0 widgets/Panner.cpp --- a/widgets/Panner.cpp Tue Sep 02 16:23:48 2014 +0100 +++ b/widgets/Panner.cpp Tue Sep 09 16:36:21 2014 +0100 @@ -36,7 +36,9 @@ m_thumbColour(palette().highlightedText().color()), m_backgroundAlpha(255), m_thumbAlpha(255), - m_clicked(false) + m_clicked(false), + m_dragStartX(0), + m_dragStartY(0) { }