summaryrefslogtreecommitdiff
path: root/media-sound/flacon/files/flacon-1.2.0-fix-disks-or-tracks-number-change-crash.patch
blob: 1e9a3369671acbe983975bdb9bc5f7438c718b3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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();
 }