File: tmpfile-race.diff

package info (click to toggle)
musescore3 3.2.3%2Bdfsg2-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 218,192 kB
  • sloc: cpp: 291,369; xml: 200,226; sh: 3,779; ansic: 1,447; python: 393; makefile: 249; perl: 82; pascal: 79
file content (35 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download
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
Origin: upstream, commit:c041e7b111c41266e0be3494c96854e8945e3b38
Author: Roman Pudashkin <r.pudashkin@gmail.com>
Description: replaced QFile with QTemporaryFile

--- a/mscore/file.cpp
+++ b/mscore/file.cpp
@@ -3263,17 +3263,19 @@ bool MuseScore::exportMp3AsJSON(const QS
 
 QByteArray MuseScore::exportPdfAsJSON(Score* score)
       {
+      QTemporaryFile tempPdfFile;
+      bool ok = tempPdfFile.open();
+
+      if (!ok) {
+          return QByteArray();
+      }
+
       QPrinter printer;
-      auto tempPdfFileName = "/tmp/MUTempPdf.pdf";
-      printer.setOutputFileName(tempPdfFileName);
+      printer.setOutputFileName(tempPdfFile.fileName());
       mscore->savePdf(score, printer);
-      QFile tempPdfFile(tempPdfFileName);
-      QByteArray pdfData;
-      if (tempPdfFile.open(QIODevice::ReadWrite)) {
-            pdfData = tempPdfFile.readAll();
-            tempPdfFile.close();
-            tempPdfFile.remove();
-            }
+
+      QByteArray pdfData = tempPdfFile.readAll();
+      tempPdfFile.close();
 
       return pdfData.toBase64();
       }