You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/media-sound/flacon/files/flacon-1.2.0-fix-disks-or-t...

86 lines
2.3 KiB

From bf2dc4aa42e91bda2d41e129f7fe6597b9f86673 Mon Sep 17 00:00:00 2001
From: "sokoloff (Alexander)" <sokoloff.a@gmail.com>
Date: Sun, 27 Sep 2015 09:24:35 +0300
Subject: [PATCH] Fix: the program sometimes crash when you change the number
of disks or tracks
---
disk.cpp | 3 +++
project.cpp | 9 +++++----
tests/testflacon.cpp | 6 +++---
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/disk.cpp b/disk.cpp
index 969cb71..3b624de 100644
--- a/disk.cpp
+++ b/disk.cpp
@@ -433,6 +433,9 @@ void Disk::loadFromCue(const CueTagSet &cueTags, bool activate)
for (int i=mTracks.count(); i<mCount; ++i)
mTracks.append(new Track(this, i));
+ while (mTracks.count() > mCount)
+ mTracks.takeLast()->deleteLater();
+
for (int t=0; t<cueTags.tracksCount(); ++t)
{
for (int idx=0; idx<100; ++idx)
diff --git a/project.cpp b/project.cpp
index 00486e4..38710ae 100644
--- a/project.cpp
+++ b/project.cpp
@@ -169,7 +169,8 @@ void Project::removeDisk(const QList<Disk*> *disks)
Disk *disk = disks->at(i);
emit beforeRemoveDisk(disk);
if (mDisks.removeAll(disk))
- delete disk;
+ disk->deleteLater();
+
emit afterRemoveDisk();
}
@@ -274,10 +275,10 @@ DiskList Project::addCueFile(const QString &fileName, bool showErrors)
}
else
{
- foreach(Disk *d, res)
+ foreach(Disk *disk, res)
{
- mDisks.removeAll(d);
- delete d;
+ mDisks.removeAll(disk);
+ disk->deleteLater();
}
emit layoutChanged();
diff --git a/tests/testflacon.cpp b/tests/testflacon.cpp
index bcd7c46..571b425 100644
--- a/tests/testflacon.cpp
+++ b/tests/testflacon.cpp
@@ -830,7 +830,7 @@ void TestFlacon::testTrackResultFileName()
expected);
QFAIL(msg.toLocal8Bit());
}
- delete disk;
+ disk->deleteLater();
}
@@ -983,7 +983,7 @@ void TestFlacon::testTrackResultFilePath()
QFAIL(msg.toLocal8Bit());
}
//QCOMPARE(result, expected);
- delete disk;
+ disk->deleteLater();
}
@@ -1117,7 +1117,7 @@ void TestFlacon::testTrackSetCodepages()
QFAIL((msg + "\n " + cmd).toLocal8Bit());
}
- delete disk;
+ disk->deleteLater();
}