Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2c0783bf5b6cf18383be4c12c72dc3ba > files > 4

fritzing-0.9.3b-6.git20181017.mga7.src.rpm

From a31df40b54435500a9806f8f1aa90a98131cb788 Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <bugs@vdm-design.de>
Date: Sat, 4 Feb 2017 10:05:05 +0100
Subject: [PATCH] folderutils.cpp: Fix getAppPartsSubFolder2 returns current
 working directory if fritzing-parts folder is not found

getApplicationSubFolder returns QDir() if the directory can not be found,
but QDir() returns the current working directory, which nearly always exists and probably is the wrong path.
As getAppPartsSubFolder2 only checks for existence of that directory we end up with the wrong directory if parts folder is used instead for fritzing-parts.
Therefore check if when we ask for fritzing-parts folder we really get a folder with that name.
---
 src/utils/folderutils.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/utils/folderutils.cpp b/src/utils/folderutils.cpp
index 96f10c7..3dfd966 100644
--- a/src/utils/folderutils.cpp
+++ b/src/utils/folderutils.cpp
@@ -121,12 +121,12 @@ QDir FolderUtils::getAppPartsSubFolder(QString search) {
 QDir FolderUtils::getAppPartsSubFolder2(QString search) {
     if (m_partsPath.isEmpty()) {
         QDir dir = getApplicationSubFolder("fritzing-parts");
-        if (dir.exists()) {
+        if (dir.exists() && dir.dirName().endsWith("fritzing-parts")) {
             m_partsPath = dir.absolutePath();
         }
         else {
             QDir dir = getApplicationSubFolder("parts");
-            if (dir.exists()) {
+            if (dir.exists() && dir.dirName().endsWith("parts")) {
                 m_partsPath = dir.absolutePath();
             }
         }
-- 
2.10.2