@@ -433,7 +433,10 @@ void QmlFilter::analyze(bool isAudio, bool deferJob)
433433 // get temp file for input xml
434434 QString filename (mltFilter.get (" filename" ));
435435 QScopedPointer<QTemporaryFile> tmp (Util::writableTemporaryFile (filename));
436- tmp->open ();
436+ if (!tmp->open ()) {
437+ LOG_ERROR () << " Failed to create temporary file" << tmp->fileName ();
438+ return ;
439+ }
437440
438441 mltFilter.clear (" results" );
439442 int disable = mltFilter.get_int (" disable" );
@@ -482,12 +485,18 @@ void QmlFilter::analyze(bool isAudio, bool deferJob)
482485
483486 // get temp filename for output xml
484487 QScopedPointer<QTemporaryFile> tmpTarget (Util::writableTemporaryFile (filename));
485- tmpTarget->open ();
488+ if (!tmpTarget->open ()) {
489+ LOG_ERROR () << " Failed to create temporary file" << tmpTarget->fileName ();
490+ return ;
491+ }
486492 tmpTarget->close ();
487493
488494 // parse xml
489495 QFile f1 (tmp->fileName ());
490- f1.open (QIODevice::ReadOnly);
496+ if (!f1.open (QIODevice::ReadOnly)) {
497+ LOG_ERROR () << " Failed to open temporary file for reading" << tmp->fileName ();
498+ return ;
499+ }
491500 QDomDocument dom (tmp->fileName ());
492501 dom.setContent (&f1);
493502 f1.close ();
@@ -522,8 +531,9 @@ void QmlFilter::analyze(bool isAudio, bool deferJob)
522531 if (!filename.isEmpty () && !QFile::exists (filename)) {
523532 job->setProperty (" filename" , filename);
524533 QFile file (filename);
525- file.open (QFile::WriteOnly);
526- file.write (" " );
534+ if (file.open (QFile::WriteOnly)) {
535+ file.write (" " );
536+ }
527537 }
528538 if (deferJob) {
529539 QTimer::singleShot (0 , this , [=]() { JOBS.add (job); });
@@ -1093,7 +1103,10 @@ void AnalyzeDelegate::updateJob(EncodeJob *job, const QString &results)
10931103
10941104 // parse the xml
10951105 QFile file (job->xmlPath ());
1096- file.open (QIODevice::ReadOnly);
1106+ if (!file.open (QIODevice::ReadOnly)) {
1107+ LOG_ERROR () << " Failed to open job XML for reading" << job->xmlPath ();
1108+ return ;
1109+ }
10971110 QDomDocument dom (job->xmlPath ());
10981111 dom.setContent (&file);
10991112 file.close ();
@@ -1136,10 +1149,13 @@ void AnalyzeDelegate::updateJob(EncodeJob *job, const QString &results)
11361149
11371150 if (isUpdated) {
11381151 // Save the new XML.
1139- file.open (QIODevice::WriteOnly);
1140- QTextStream textStream (&file);
1141- dom.save (textStream, 2 );
1142- file.close ();
1152+ if (file.open (QIODevice::WriteOnly)) {
1153+ QTextStream textStream (&file);
1154+ dom.save (textStream, 2 );
1155+ file.close ();
1156+ } else {
1157+ LOG_ERROR () << " Failed to open job XML for writing" << job->xmlPath ();
1158+ }
11431159 }
11441160}
11451161
@@ -1192,7 +1208,10 @@ QString AnalyzeDelegate::resultsFromXml(const QString &fileName)
11921208{
11931209 // parse the xml
11941210 QFile file (fileName);
1195- file.open (QIODevice::ReadOnly);
1211+ if (!file.open (QIODevice::ReadOnly)) {
1212+ LOG_ERROR () << " Failed to open job XML for reading" << fileName;
1213+ return QString ();
1214+ }
11961215 QDomDocument dom (fileName);
11971216 dom.setContent (&file);
11981217 file.close ();
0 commit comments