Summary: | K3B crashes after Splitting | ||
---|---|---|---|
Product: | [Applications] k3b | Reporter: | Torsten <thorsten> |
Component: | general | Assignee: | Michał Małek <michalm> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | kde, trueg |
Priority: | NOR | ||
Version: | 2.0.1 | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 2.0.2 |
Description
Torsten
2010-12-25 00:29:23 UTC
*** This bug has been marked as a duplicate of bug 247588 *** this is strange that you still reproduce this bug. Confirmed, I've managed to repeat it commit 06d21ce5e4992ceee78b720bc977812752d870c3 branch 2.0 Author: Michal Malek <michalm@jabster.pl> Date: Wed Jan 5 19:26:28 2011 +0100 Fixed crash after track splitting. The crash was caused by improper sorting of ranges. They need to be sorted by times, not by identifiers. BUG: 261188 diff --git a/ChangeLog b/ChangeLog index 7b8a80b..6758c0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ Bugfixes: * Fixed playlist sort order (249395) * Show K3b also in "System" category in KDE launch menus (250749) * Crash when multiple instances start at the same time (253794) + * Crash after track splitting (261188) 2.0.1 ===== diff --git a/src/projects/k3baudioeditorwidget.cpp b/src/projects/k3baudioeditorwidget.cpp index f847d01..c0d8e33 100644 --- a/src/projects/k3baudioeditorwidget.cpp +++ b/src/projects/k3baudioeditorwidget.cpp @@ -1,7 +1,7 @@ /* * * Copyright (C) 2004-2008 Sebastian Trueg <trueg@k3b.org> - * Copyright (C) 2010 Michal Malek <michalm@jabster.pl> + * Copyright (C) 2010-2011 Michal Malek <michalm@jabster.pl> * * This file is part of the K3b project. * Copyright (C) 1998-2008 Sebastian Trueg <trueg@k3b.org> @@ -101,6 +101,15 @@ public: }; +struct K3b::AudioEditorWidget::SortByStart +{ + bool operator()( Range const* lhs, Range const* rhs ) + { + return lhs->start < rhs->start; + } +}; + + class K3b::AudioEditorWidget::Private { public: @@ -361,11 +370,20 @@ K3b::Msf K3b::AudioEditorWidget::rangeEnd( int identifier ) const QList<int> K3b::AudioEditorWidget::allRanges() const { + // First collect all ranges to one random-access container... + QList<Range const*> ranges; + Q_FOREACH( Range const& range, d->ranges ) { + ranges.push_back( &range ); + } + + // ...then sort it... + qSort( ranges.begin(), ranges.end(), SortByStart() ); + + // ...finally collect its identifiers and return the collection. QList<int> identifiers; - for( Range::List::const_iterator it = d->ranges.constBegin(); it != d->ranges.constEnd(); ++it ) { - identifiers.append( it->id ); + Q_FOREACH( Range const* range, ranges ) { + identifiers.push_back( range->id ); } - qSort( identifiers ); return identifiers; } @@ -567,16 +585,16 @@ void K3b::AudioEditorWidget::fixupOverlappingRanges( int rangeId ) { Range* r = getRange( rangeId ); Range::List::iterator range = d->ranges.begin(); - + while( r != 0 && range != d->ranges.end() ) { if( range->id != rangeId ) { - + // remove the range if it is covered completely if( range->start >= r->start && range->end <= r->end ) { if( d->selectedRangeId == range->id ) setSelectedRange( 0 ); - + range = d->ranges.erase( range ); emit rangeRemoved( rangeId ); // "r" may be invalid at this point, let's find it once again @@ -733,24 +751,24 @@ bool K3b::AudioEditorWidget::event( QEvent* e ) if( e->type() == QEvent::ToolTip ) { QHelpEvent* helpEvent = dynamic_cast<QHelpEvent*>( e ); const QPoint pos = mapFromGlobal( helpEvent->globalPos() ); - + if( Marker* m = findMarker( pos ) ) { QToolTip::showText( helpEvent->globalPos(), m->toolTip.isEmpty() ? m->pos.toString() : QString("%1 (%2)").arg(m->toolTip).arg(m->pos.toString()), this ); } else if( Range* range = findRange( pos ) ) { - QToolTip::showText( helpEvent->globalPos(), + QToolTip::showText( helpEvent->globalPos(), range->toolTip.isEmpty() ? QString("%1 - %2").arg(range->start.toString()).arg(range->end.toString()) : QString("%1 (%2 - %3)").arg(range->toolTip).arg(range->start.toString()).arg(range->end.toString()), this ); - + } else { QToolTip::hideText(); } - + e->accept(); return true; } diff --git a/src/projects/k3baudioeditorwidget.h b/src/projects/k3baudioeditorwidget.h index f007ec3..1a8b2c3 100644 --- a/src/projects/k3baudioeditorwidget.h +++ b/src/projects/k3baudioeditorwidget.h @@ -1,7 +1,7 @@ -/* +/* * * Copyright (C) 2004-2008 Sebastian Trueg <trueg@k3b.org> - * Copyright (C) 2010 Michal Malek <michalm@jabster.pl> + * Copyright (C) 2010-2011 Michal Malek <michalm@jabster.pl> * * This file is part of the K3b project. * Copyright (C) 1998-2008 Sebastian Trueg <trueg@k3b.org> @@ -52,7 +52,7 @@ public: * * @return -1 on error or an identifier on success (be aware that the highest value for end is length-1) */ - int addRange( const K3b::Msf& start, const K3b::Msf& end, + int addRange( const K3b::Msf& start, const K3b::Msf& end, bool startFixed = false, bool endFixed = false, const QString& toolTip = QString(), const QBrush& brush = QBrush() ); @@ -95,7 +95,7 @@ public: * @param fixed if true the marker cannot be changed by the user, only with moveMarker * @return -1 on error or an identifier on success. */ - int addMarker( const K3b::Msf& pos, bool fixed = false, + int addMarker( const K3b::Msf& pos, bool fixed = false, const QString& toolTip = QString(), const QColor& color = QColor() ); /** @@ -168,7 +168,7 @@ Q_SIGNALS: void markerMoved( int identifier, const K3b::Msf& pos ); void markerAdded( int identifier, const K3b::Msf& pos ); void markerRemoved( int identifier ); - + protected: virtual void paintEvent( QPaintEvent* e ); virtual void mousePressEvent( QMouseEvent* e ); @@ -180,6 +180,7 @@ protected: private: class Range; class Marker; + struct SortByStart; class Private; Private* d; commit 694ba7e28159e9efbf2df1e01976a65eed321c61 branch master Author: Michal Malek <michalm@jabster.pl> Date: Wed Jan 5 19:26:28 2011 +0100 Fixed crash after track splitting. The crash was caused by improper sorting of ranges. They need to be sorted by times, not by identifiers. BUG: 261188 diff --git a/ChangeLog b/ChangeLog index a9f6443..bae0fb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ Bugfixes: * Fixed playlist sort order (249395) * Show K3b also in "System" category in KDE launch menus (250749) * Crash when multiple instances start at the same time (253794) + * Crash after track splitting (261188) 2.0.1 ===== diff --git a/src/projects/k3baudioeditorwidget.cpp b/src/projects/k3baudioeditorwidget.cpp index f847d01..c0d8e33 100644 --- a/src/projects/k3baudioeditorwidget.cpp +++ b/src/projects/k3baudioeditorwidget.cpp @@ -1,7 +1,7 @@ /* * * Copyright (C) 2004-2008 Sebastian Trueg <trueg@k3b.org> - * Copyright (C) 2010 Michal Malek <michalm@jabster.pl> + * Copyright (C) 2010-2011 Michal Malek <michalm@jabster.pl> * * This file is part of the K3b project. * Copyright (C) 1998-2008 Sebastian Trueg <trueg@k3b.org> @@ -101,6 +101,15 @@ public: }; +struct K3b::AudioEditorWidget::SortByStart +{ + bool operator()( Range const* lhs, Range const* rhs ) + { + return lhs->start < rhs->start; + } +}; + + class K3b::AudioEditorWidget::Private { public: @@ -361,11 +370,20 @@ K3b::Msf K3b::AudioEditorWidget::rangeEnd( int identifier ) const QList<int> K3b::AudioEditorWidget::allRanges() const { + // First collect all ranges to one random-access container... + QList<Range const*> ranges; + Q_FOREACH( Range const& range, d->ranges ) { + ranges.push_back( &range ); + } + + // ...then sort it... + qSort( ranges.begin(), ranges.end(), SortByStart() ); + + // ...finally collect its identifiers and return the collection. QList<int> identifiers; - for( Range::List::const_iterator it = d->ranges.constBegin(); it != d->ranges.constEnd(); ++it ) { - identifiers.append( it->id ); + Q_FOREACH( Range const* range, ranges ) { + identifiers.push_back( range->id ); } - qSort( identifiers ); return identifiers; } @@ -567,16 +585,16 @@ void K3b::AudioEditorWidget::fixupOverlappingRanges( int rangeId ) { Range* r = getRange( rangeId ); Range::List::iterator range = d->ranges.begin(); - + while( r != 0 && range != d->ranges.end() ) { if( range->id != rangeId ) { - + // remove the range if it is covered completely if( range->start >= r->start && range->end <= r->end ) { if( d->selectedRangeId == range->id ) setSelectedRange( 0 ); - + range = d->ranges.erase( range ); emit rangeRemoved( rangeId ); // "r" may be invalid at this point, let's find it once again @@ -733,24 +751,24 @@ bool K3b::AudioEditorWidget::event( QEvent* e ) if( e->type() == QEvent::ToolTip ) { QHelpEvent* helpEvent = dynamic_cast<QHelpEvent*>( e ); const QPoint pos = mapFromGlobal( helpEvent->globalPos() ); - + if( Marker* m = findMarker( pos ) ) { QToolTip::showText( helpEvent->globalPos(), m->toolTip.isEmpty() ? m->pos.toString() : QString("%1 (%2)").arg(m->toolTip).arg(m->pos.toString()), this ); } else if( Range* range = findRange( pos ) ) { - QToolTip::showText( helpEvent->globalPos(), + QToolTip::showText( helpEvent->globalPos(), range->toolTip.isEmpty() ? QString("%1 - %2").arg(range->start.toString()).arg(range->end.toString()) : QString("%1 (%2 - %3)").arg(range->toolTip).arg(range->start.toString()).arg(range->end.toString()), this ); - + } else { QToolTip::hideText(); } - + e->accept(); return true; } diff --git a/src/projects/k3baudioeditorwidget.h b/src/projects/k3baudioeditorwidget.h index f007ec3..1a8b2c3 100644 --- a/src/projects/k3baudioeditorwidget.h +++ b/src/projects/k3baudioeditorwidget.h @@ -1,7 +1,7 @@ -/* +/* * * Copyright (C) 2004-2008 Sebastian Trueg <trueg@k3b.org> - * Copyright (C) 2010 Michal Malek <michalm@jabster.pl> + * Copyright (C) 2010-2011 Michal Malek <michalm@jabster.pl> * * This file is part of the K3b project. * Copyright (C) 1998-2008 Sebastian Trueg <trueg@k3b.org> @@ -52,7 +52,7 @@ public: * * @return -1 on error or an identifier on success (be aware that the highest value for end is length-1) */ - int addRange( const K3b::Msf& start, const K3b::Msf& end, + int addRange( const K3b::Msf& start, const K3b::Msf& end, bool startFixed = false, bool endFixed = false, const QString& toolTip = QString(), const QBrush& brush = QBrush() ); @@ -95,7 +95,7 @@ public: * @param fixed if true the marker cannot be changed by the user, only with moveMarker * @return -1 on error or an identifier on success. */ - int addMarker( const K3b::Msf& pos, bool fixed = false, + int addMarker( const K3b::Msf& pos, bool fixed = false, const QString& toolTip = QString(), const QColor& color = QColor() ); /** @@ -168,7 +168,7 @@ Q_SIGNALS: void markerMoved( int identifier, const K3b::Msf& pos ); void markerAdded( int identifier, const K3b::Msf& pos ); void markerRemoved( int identifier ); - + protected: virtual void paintEvent( QPaintEvent* e ); virtual void mousePressEvent( QMouseEvent* e ); @@ -180,6 +180,7 @@ protected: private: class Range; class Marker; + struct SortByStart; class Private; Private* d; |