fix index
c3a75968 changed initialization from -1 to 0, this adjusts the rest of the code to work with that.
Without this fix, when compiled in Debug configuration, Kwave aborts when loading a file, with message: ASSERT failure in QList<T>::insert: "index out of range", file /usr/include/qt6/QtCore/qlist.h, line 857
Backtrace:
Thread 1 (Thread 0x7f49fcc006c0 (LWP 217264)):
[KCrash Handler]
#4 0x00007f4a3b894c5c in __pthread_kill_implementation () at /lib64/libc.so.6
#5 0x00007f4a3b8411c6 in raise () at /lib64/libc.so.6
#6 0x00007f4a3b828917 in abort () at /lib64/libc.so.6
#7 0x00007f4a3c0e073d in qAbort() () at /lib64/libQt6Core.so.6
#8 0x00007f4a3c130bfe in ??? () at /lib64/libQt6Core.so.6
#9 0x00007f4a3c0e1df3 in QMessageLogger::fatal(char const*, ...) const () at /lib64/libQt6Core.so.6
#10 0x00007f4a3c0e0e14 in qt_assert_x(char const*, char const*, char const*, int) () at /lib64/libQt6Core.so.6
#11 0x00007f4a3ec8b5a8 in QList<Kwave::Stripe>::emplace<Kwave::Stripe const&> (this=0x3cae9040, i=1) at /usr/include/qt6/QtCore/qlist.h:857
#12 0x00007f4a3ec8ad4b in QList<Kwave::Stripe>::insert (this=0x3cae9040, i=1, t=...) at /usr/include/qt6/QtCore/qlist.h:475
#13 0x00007f4a3ec89658 in Kwave::Track::appendAfter (this=0x3cae9010, stripe=0x0, offset=0, buffer=..., buf_offset=0, length=524288) at /home/mark/kde/src/kwave/libkwave/Track.cpp:533
#14 0x00007f4a3ec89897 in Kwave::Track::writeSamples (this=0x3cae9010, mode=Kwave::Append, offset=0, buffer=..., buf_offset=0, length=524288) at /home/mark/kde/src/kwave/libkwave/Track.cpp:579
#15 0x00007f4a3ec8dee0 in Kwave::TrackWriter::write (this=0x3c9544a0, buffer=..., count=@0x7f49fcbff59c: 524288) at /home/mark/kde/src/kwave/libkwave/TrackWriter.cpp:67
#16 0x00007f4a3ec965b8 in Kwave::Writer::operator<< (this=0x3c9544a0, samples=...) at /home/mark/kde/src/kwave/libkwave/Writer.cpp:88
#17 0x00007f4a3ec9690d in Kwave::Writer::input (this=0x3c9544a0, data=...) at /home/mark/kde/src/kwave/libkwave/Writer.cpp:154
#18 0x00007f4a3ec969ba in Kwave::Writer::qt_static_metacall (_o=0x3c9544a0, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7f49fcbff760) at /home/mark/kde/build/kwave/libkwave/libkwave_autogen/include/moc_Writer.cpp:111
#19 0x00007f4a3c1e80af in ??? () at /lib64/libQt6Core.so.6
#20 0x00007f4a3eca66ad in Kwave::SampleBuffer::output (this=0x3cf9d5f0, _t1=...) at /home/mark/kde/build/kwave/libkwave/libkwave_autogen/include/moc_SampleBuffer.cpp:153
#21 0x00007f4a3eca63c8 in Kwave::SampleBuffer::emitData (this=0x3cf9d5f0, data=...) at /home/mark/kde/src/kwave/libkwave/modules/SampleBuffer.cpp:143
#22 0x00007f4a3eca71b7 in std::__invoke_impl<void, void (Kwave::SampleBuffer::*&)(Kwave::SampleArray), Kwave::SampleBuffer*&, Kwave::SampleArray&> (__f=@0x7f49fcbff890: (void (Kwave::SampleBuffer::*)(Kwave::SampleBuffer * const, Kwave::SampleArray)) 0x7f4a3eca6392 <Kwave::SampleBuffer::emitData(Kwave::SampleArray)>, __t=@0x7f49fcbff8a0: 0x3cf9d5f0) at /usr/include/c++/14/bits/invoke.h:74
#23 0x00007f4a3eca7034 in std::__invoke<void (Kwave::SampleBuffer::*&)(Kwave::SampleArray), Kwave::SampleBuffer*&, Kwave::SampleArray&> (__fn=@0x7f49fcbff890: (void (Kwave::SampleBuffer::*)(Kwave::SampleBuffer * const, Kwave::SampleArray)) 0x7f4a3eca6392 <Kwave::SampleBuffer::emitData(Kwave::SampleArray)>) at /usr/include/c++/14/bits/invoke.h:96
#24 0x00007f4a3eca6eca in std::invoke<void (Kwave::SampleBuffer::*&)(Kwave::SampleArray), Kwave::SampleBuffer*&, Kwave::SampleArray&> (__fn=@0x7f49fcbff890: (void (Kwave::SampleBuffer::*)(Kwave::SampleBuffer * const, Kwave::SampleArray)) 0x7f4a3eca6392 <Kwave::SampleBuffer::emitData(Kwave::SampleArray)>) at /usr/include/c++/14/functional:120
#25 0x00007f4a3eca6d86 in QtConcurrent::StoredFunctionCall<void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>::runFunctor()::{lambda(void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray)#1}::operator()(void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray) const (__closure=0x7f49fcbff9ef, function=(void (Kwave::SampleBuffer::*)(Kwave::SampleBuffer * const, Kwave::SampleArray)) 0x7f4a3eca6392 <Kwave::SampleBuffer::emitData(Kwave::SampleArray)>, args#0=0x3cf9d5f0, args#1=...) at /usr/include/qt6/QtConcurrent/qtconcurrentstoredfunctioncall.h:116
#26 0x00007f4a3eca710e in std::__invoke_impl<void, QtConcurrent::StoredFunctionCall<void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>::runFunctor()::{lambda(void (Kwave::SampleBuffer::* const&)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray)#1}, void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>(std::__invoke_other, QtConcurrent::StoredFunctionCall<void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>::runFunctor()::{lambda(void (Kwave::SampleBuffer::* const&)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray)#1}, void (Kwave::SampleBuffer::*&&)(Kwave::SampleArray), Kwave::SampleBuffer*&&, Kwave::SampleArray&&) (__f=...) at /usr/include/c++/14/bits/invoke.h:61
#27 0x00007f4a3eca6fbd in std::__invoke<QtConcurrent::StoredFunctionCall<void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>::runFunctor()::{lambda(void (Kwave::SampleBuffer::* const&)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray)#1}, void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>(QtConcurrent::StoredFunctionCall<void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>::runFunctor()::{lambda(void (Kwave::SampleBuffer::* const&)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray)#1}, void (Kwave::SampleBuffer::*&&)(Kwave::SampleArray), Kwave::SampleBuffer*&&, Kwave::SampleArray&&) (__fn=...) at /usr/include/c++/14/bits/invoke.h:96
#28 0x00007f4a3eca6e00 in std::__apply_impl<QtConcurrent::StoredFunctionCall<void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>::runFunctor()::{lambda(void (Kwave::SampleBuffer::* const&)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray)#1}, std::tuple<void (Kwave::SampleBuffer::*)(Kwave::SampleArray), Kwave::SampleBuffer*, Kwave::SampleArray>, 0ul, 1ul, 2ul>(QtConcurrent::StoredFunctionCall<void
Edited by Mark Penner