• R/O
  • HTTP
  • SSH
  • HTTPS

MUtilities: Commit

MUtilities development repository


Commit MetaInfo

Revisiondb0ed92823e15df98f7c376e5cf8d7ce754b2bb4 (tree)
Time2018-10-24 04:48:24
AuthorLoRd_MuldeR <mulder2@gmx....>
CommiterLoRd_MuldeR

Log Message

Fixed a regression in 8fa44842.

Change Summary

Incremental Difference

--- a/MUtilities_VS2017.vcxproj
+++ b/MUtilities_VS2017.vcxproj
@@ -64,6 +64,7 @@
6464 <ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" />
6565 <ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" />
6666 <ClInclude Include="src\DirLocker.h" />
67+ <ClInclude Include="src\Internal.h" />
6768 <ClInclude Include="src\Mirrors.h" />
6869 <ClInclude Include="src\Utils_Win32.h" />
6970 <CustomBuild Include="include\Mutils\UpdateChecker.h">
--- a/MUtilities_VS2017.vcxproj.filters
+++ b/MUtilities_VS2017.vcxproj.filters
@@ -182,6 +182,9 @@
182182 <ClInclude Include="src\Mirrors.h">
183183 <Filter>Header Files</Filter>
184184 </ClInclude>
185+ <ClInclude Include="src\Internal.h">
186+ <Filter>Header Files</Filter>
187+ </ClInclude>
185188 </ItemGroup>
186189 <ItemGroup>
187190 <CustomBuild Include="include\Mutils\UpdateChecker.h">
--- a/src/Global.cpp
+++ b/src/Global.cpp
@@ -27,6 +27,7 @@
2727 #include <MUtils/Global.h>
2828 #include <MUtils/OSSupport.h>
2929 #include <MUtils/Version.h>
30+#include "Internal.h"
3031
3132 //Internal
3233 #include "DirLocker.h"
@@ -53,6 +54,9 @@
5354 #include <vld.h>
5455 #endif
5556
57+//Global
58+const QString MUtils::Internal::g_empty;
59+
5660 ///////////////////////////////////////////////////////////////////////////////
5761 // Random Support
5862 ///////////////////////////////////////////////////////////////////////////////
--- /dev/null
+++ b/src/Internal.h
@@ -0,0 +1,30 @@
1+///////////////////////////////////////////////////////////////////////////////
2+// MuldeR's Utilities for Qt
3+// Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
4+//
5+// This library is free software; you can redistribute it and/or
6+// modify it under the terms of the GNU Lesser General Public
7+// License as published by the Free Software Foundation; either
8+// version 2.1 of the License, or (at your option) any later version.
9+//
10+// This library is distributed in the hope that it will be useful,
11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+// Lesser General Public License for more details.
14+//
15+// You should have received a copy of the GNU Lesser General Public
16+// License along with this library; if not, write to the Free Software
17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+//
19+// http://www.gnu.org/licenses/lgpl-2.1.txt
20+//////////////////////////////////////////////////////////////////////////////////
21+
22+#include <QString>
23+
24+namespace MUtils
25+{
26+ namespace Internal
27+ {
28+ extern const QString g_empty;
29+ }
30+}
--- a/src/OSSupport_Win32.cpp
+++ b/src/OSSupport_Win32.cpp
@@ -40,6 +40,7 @@
4040 #include <MUtils/Global.h>
4141 #include <MUtils/OSSupport.h>
4242 #include <MUtils/GUI.h>
43+#include "Internal.h"
4344 #include "CriticalSection_Win32.h"
4445 #include "Utils_Win32.h"
4546
@@ -681,13 +682,12 @@ const bool &MUtils::OS::running_on_wine(void)
681682 // KNWON FOLDERS
682683 ///////////////////////////////////////////////////////////////////////////////
683684
684-typedef QMap<size_t, QString> KFMap;
685+static QReadWriteLock g_known_folders_lock;
686+static QScopedPointer<QHash<size_t, QString>> g_known_folders_data;
687+
685688 typedef HRESULT (WINAPI *SHGetKnownFolderPath_t)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
686689 typedef HRESULT (WINAPI *SHGetFolderPath_t) (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
687690
688-static QScopedPointer<KFMap> g_known_folders_map;
689-static QReadWriteLock g_known_folders_lock;
690-
691691 const QString &MUtils::OS::known_folder(known_folder_t folder_id)
692692 {
693693 typedef enum { KF_FLAG_CREATE = 0x00008000 } kf_flags_t;
@@ -724,11 +724,11 @@ const QString &MUtils::OS::known_folder(known_folder_t folder_id)
724724 QReadLocker readLock(&g_known_folders_lock);
725725
726726 //Already in cache?
727- if(!g_known_folders_map.isNull())
727+ if(!g_known_folders_data.isNull())
728728 {
729- if(g_known_folders_map->contains(folderId))
729+ if(g_known_folders_data->contains(folderId))
730730 {
731- return (*g_known_folders_map)[folderId];
731+ return (*g_known_folders_data)[folderId];
732732 }
733733 }
734734
@@ -737,18 +737,18 @@ const QString &MUtils::OS::known_folder(known_folder_t folder_id)
737737 QWriteLocker writeLock(&g_known_folders_lock);
738738
739739 //Still not in cache?
740- if(!g_known_folders_map.isNull())
740+ if(!g_known_folders_data.isNull())
741741 {
742- if(g_known_folders_map->contains(folderId))
742+ if(g_known_folders_data->contains(folderId))
743743 {
744- return (*g_known_folders_map)[folderId];
744+ return (*g_known_folders_data)[folderId];
745745 }
746746 }
747747
748748 //Initialize on first call
749- if(g_known_folders_map.isNull())
749+ if(g_known_folders_data.isNull())
750750 {
751- g_known_folders_map.reset(new QMap<size_t, QString>());
751+ g_known_folders_data.reset(new QHash<size_t, QString>());
752752 }
753753
754754 QString folderPath;
@@ -790,10 +790,11 @@ const QString &MUtils::OS::known_folder(known_folder_t folder_id)
790790 //Update cache
791791 if (!folderPath.isEmpty())
792792 {
793- g_known_folders_map->insert(folderId, folderPath);
793+ g_known_folders_data->insert(folderId, folderPath);
794+ return (*g_known_folders_data)[folderId];
794795 }
795796
796- return folderPath;
797+ return Internal::g_empty;
797798 }
798799
799800 ///////////////////////////////////////////////////////////////////////////////
Show on old repository browser