View Issue Details

IDProjectCategoryView StatusLast Update
0017319ScribusImport / Exportpublic2024-11-22 14:16
Reportertropion Assigned To 
PrioritynormalSeverityminorReproducibilitysometimes
Status newResolutionopen 
Product Version1.7.0.svn 
Summary0017319: Scribuses working in parallel overwrite each others temp files
DescriptionI tried to use several scribuses in parallel to convert .sla files to .pdf files.
Sometimes the resulting .pdfs contain corrupt images.
This happens, because the different scribuses all use the same temp file names and sometimes they overwrite each others temp files.

I suggest adding something like QString::number(QCoreApplication::applicationPid()) as a subdir to the path in ScPaths::tempFileDir().

And though I am really not sure if this is the right place to clean that up I suggest adding
  QDir tmpDir (ScPaths::tempFileDir());
  tmpDir.rmdir (ScPaths::tempFileDir());
to ScribusQApp::~ScribusQApp()
TagsNo tags attached.
PatchYes

Activities

tropion

2024-11-22 14:16

reporter  

tempDir.diff (1,334 bytes)   
diff --git a/scribus/scpaths.cpp b/scribus/scpaths.cpp
index 74b8fdf14..d17fb3e0f 100644
--- a/scribus/scpaths.cpp
+++ b/scribus/scpaths.cpp
@@ -656,11 +656,16 @@ QString ScPaths::tempFileDir()
 		// GetTempPath may return Windows directory, better not use this one
 		// for temporary files
 		if (QDir(tempPath).exists() && tempPath != windowsSpecialDir(CSIDL_WINDOWS))
-			return tempPath;
+		{
+			QDir tempAppDirectory(tempPath + QString::number(QCoreApplication::applicationPid()));
+			if (!tempAppDirectory.exists())
+				tempAppDirectory.mkpath(tempAppDirectory.absolutePath());
+			return tempAppDirectory.absolutePath() + "/";
+		}
 	}
 #endif
 
-	QDir tempAppDirectory(applicationDataDir() + "temp/");
+	QDir tempAppDirectory(applicationDataDir() + "temp/" + QString::number(QCoreApplication::applicationPid()));
 	if (!tempAppDirectory.exists())
 		tempAppDirectory.mkpath(tempAppDirectory.absolutePath());
 	return tempAppDirectory.absolutePath() + "/";
diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
index 159ac2f0e..330e1c993 100644
--- a/scribus/scribusapp.cpp
+++ b/scribus/scribusapp.cpp
@@ -110,6 +110,8 @@ ScribusQApp::~ScribusQApp()
 {
 	delete m_ScCore;
 	delete m_scDLMgr;
+	QDir tmpDir (ScPaths::tempFileDir());
+	tmpDir.rmdir (ScPaths::tempFileDir());
 	LanguageManager::deleteInstance();
 }
 
tempDir.diff (1,334 bytes)   

Issue History

Date Modified Username Field Change
2024-11-22 14:16 tropion New Issue
2024-11-22 14:16 tropion File Added: tempDir.diff