@@ -61,62 +61,56 @@ void AnalysisRunner::run()
61
61
62
62
QFileInfo fileInfo (mFilename );
63
63
64
- QIODevice * file = nullptr ;
65
64
QFile rawFile (mFilename );
65
+ QScopedPointer<QIODevice> uncompressFile;
66
66
67
67
if (is_gz (&rawFile))
68
68
{
69
- file = new KCompressionDevice (&rawFile,true ,KCompressionDevice::GZip);
70
- if (!is_fastq (file))
71
- {
72
- delete file;
73
- file = nullptr ;
74
- }
69
+ uncompressFile.reset (new KCompressionDevice (&rawFile,false ,KCompressionDevice::GZip));
70
+ if (!is_fastq (uncompressFile.data ()))
71
+ return ;
72
+
75
73
}
76
74
else if (is_bz2 (&rawFile))
77
75
{
78
- file = new KCompressionDevice (&rawFile, true , KCompressionDevice::BZip2);
79
- if (!is_fastq (file))
80
- {
81
- delete file;
82
- file = nullptr ;
83
- }
76
+ uncompressFile.reset (new KCompressionDevice (&rawFile, false , KCompressionDevice::BZip2));
77
+ if (!is_fastq (uncompressFile.data ()))
78
+ return ;
84
79
}
85
80
else if (is_xz (&rawFile))
86
81
{
87
- file = new KCompressionDevice (&rawFile,true , KCompressionDevice::Xz);
88
- if (!is_fastq (file))
89
- {
90
- delete file;
91
- file = nullptr ;
92
- }
82
+ uncompressFile.reset (new KCompressionDevice (&rawFile,false , KCompressionDevice::Xz));
83
+ if (!is_fastq (uncompressFile.data ()))
84
+ return ;
93
85
}
94
86
else if (is_fastq (&rawFile))
95
87
{
96
- file = &rawFile;
88
+ uncompressFile.reset (new KCompressionDevice (&rawFile,false , KCompressionDevice::None));
89
+ if (!is_fastq (uncompressFile.data ()))
90
+ return ;
91
+
97
92
}
98
93
99
- if (file == nullptr )
94
+ if (uncompressFile. isNull () )
100
95
{
101
96
qDebug ()<<Q_FUNC_INFO<<fileInfo.suffix ()<< " file is not supported" ;
102
97
setStatus (Canceled);
103
- delete file;
104
98
return ;
105
99
}
106
100
107
101
if (fileInfo.size () == 0 )
108
102
{
109
103
setStatus (Canceled);
110
- delete file;
111
104
return ;
112
105
}
113
106
114
- if (file->open (QIODevice::ReadOnly))
107
+
108
+ if (uncompressFile.data ()->open (QIODevice::ReadOnly))
115
109
{
116
110
mSequenceCount = 0 ;
117
111
mProgression = 0 ;
118
112
119
- FastqReader reader (file );
113
+ FastqReader reader (uncompressFile. data () );
120
114
mStartTime .start ();
121
115
122
116
@@ -134,7 +128,6 @@ void AnalysisRunner::run()
134
128
{
135
129
qCritical ()<<Q_FUNC_INFO<<" Cannot read sequence. Are you sure it's a Fastq file ?" ;
136
130
setStatus (Canceled);
137
- delete file;
138
131
return ;
139
132
}
140
133
}
@@ -177,8 +170,6 @@ void AnalysisRunner::run()
177
170
qDebug ()<<Q_FUNC_INFO<<" Cannot open file" ;
178
171
}
179
172
180
- file->close ();
181
- file->deleteLater ();
182
173
183
174
184
175
}
0 commit comments