Fixed a regression in 8fa44842
.
This commit is contained in:
parent
0cbf24d07f
commit
db0ed92823
@ -64,6 +64,7 @@
|
|||||||
<ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" />
|
<ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" />
|
||||||
<ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" />
|
<ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" />
|
||||||
<ClInclude Include="src\DirLocker.h" />
|
<ClInclude Include="src\DirLocker.h" />
|
||||||
|
<ClInclude Include="src\Internal.h" />
|
||||||
<ClInclude Include="src\Mirrors.h" />
|
<ClInclude Include="src\Mirrors.h" />
|
||||||
<ClInclude Include="src\Utils_Win32.h" />
|
<ClInclude Include="src\Utils_Win32.h" />
|
||||||
<CustomBuild Include="include\Mutils\UpdateChecker.h">
|
<CustomBuild Include="include\Mutils\UpdateChecker.h">
|
||||||
|
@ -182,6 +182,9 @@
|
|||||||
<ClInclude Include="src\Mirrors.h">
|
<ClInclude Include="src\Mirrors.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Internal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CustomBuild Include="include\Mutils\UpdateChecker.h">
|
<CustomBuild Include="include\Mutils\UpdateChecker.h">
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <MUtils/Global.h>
|
#include <MUtils/Global.h>
|
||||||
#include <MUtils/OSSupport.h>
|
#include <MUtils/OSSupport.h>
|
||||||
#include <MUtils/Version.h>
|
#include <MUtils/Version.h>
|
||||||
|
#include "Internal.h"
|
||||||
|
|
||||||
//Internal
|
//Internal
|
||||||
#include "DirLocker.h"
|
#include "DirLocker.h"
|
||||||
@ -53,6 +54,9 @@
|
|||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//Global
|
||||||
|
const QString MUtils::Internal::g_empty;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Random Support
|
// Random Support
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
30
src/Internal.h
Normal file
30
src/Internal.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// MuldeR's Utilities for Qt
|
||||||
|
// Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
//
|
||||||
|
// http://www.gnu.org/licenses/lgpl-2.1.txt
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace MUtils
|
||||||
|
{
|
||||||
|
namespace Internal
|
||||||
|
{
|
||||||
|
extern const QString g_empty;
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,7 @@
|
|||||||
#include <MUtils/Global.h>
|
#include <MUtils/Global.h>
|
||||||
#include <MUtils/OSSupport.h>
|
#include <MUtils/OSSupport.h>
|
||||||
#include <MUtils/GUI.h>
|
#include <MUtils/GUI.h>
|
||||||
|
#include "Internal.h"
|
||||||
#include "CriticalSection_Win32.h"
|
#include "CriticalSection_Win32.h"
|
||||||
#include "Utils_Win32.h"
|
#include "Utils_Win32.h"
|
||||||
|
|
||||||
@ -681,13 +682,12 @@ const bool &MUtils::OS::running_on_wine(void)
|
|||||||
// KNWON FOLDERS
|
// KNWON FOLDERS
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
typedef QMap<size_t, QString> KFMap;
|
static QReadWriteLock g_known_folders_lock;
|
||||||
|
static QScopedPointer<QHash<size_t, QString>> g_known_folders_data;
|
||||||
|
|
||||||
typedef HRESULT (WINAPI *SHGetKnownFolderPath_t)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
|
typedef HRESULT (WINAPI *SHGetKnownFolderPath_t)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
|
||||||
typedef HRESULT (WINAPI *SHGetFolderPath_t) (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
|
typedef HRESULT (WINAPI *SHGetFolderPath_t) (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
|
||||||
|
|
||||||
static QScopedPointer<KFMap> g_known_folders_map;
|
|
||||||
static QReadWriteLock g_known_folders_lock;
|
|
||||||
|
|
||||||
const QString &MUtils::OS::known_folder(known_folder_t folder_id)
|
const QString &MUtils::OS::known_folder(known_folder_t folder_id)
|
||||||
{
|
{
|
||||||
typedef enum { KF_FLAG_CREATE = 0x00008000 } kf_flags_t;
|
typedef enum { KF_FLAG_CREATE = 0x00008000 } kf_flags_t;
|
||||||
@ -724,11 +724,11 @@ const QString &MUtils::OS::known_folder(known_folder_t folder_id)
|
|||||||
QReadLocker readLock(&g_known_folders_lock);
|
QReadLocker readLock(&g_known_folders_lock);
|
||||||
|
|
||||||
//Already in cache?
|
//Already in cache?
|
||||||
if(!g_known_folders_map.isNull())
|
if(!g_known_folders_data.isNull())
|
||||||
{
|
{
|
||||||
if(g_known_folders_map->contains(folderId))
|
if(g_known_folders_data->contains(folderId))
|
||||||
{
|
{
|
||||||
return (*g_known_folders_map)[folderId];
|
return (*g_known_folders_data)[folderId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,18 +737,18 @@ const QString &MUtils::OS::known_folder(known_folder_t folder_id)
|
|||||||
QWriteLocker writeLock(&g_known_folders_lock);
|
QWriteLocker writeLock(&g_known_folders_lock);
|
||||||
|
|
||||||
//Still not in cache?
|
//Still not in cache?
|
||||||
if(!g_known_folders_map.isNull())
|
if(!g_known_folders_data.isNull())
|
||||||
{
|
{
|
||||||
if(g_known_folders_map->contains(folderId))
|
if(g_known_folders_data->contains(folderId))
|
||||||
{
|
{
|
||||||
return (*g_known_folders_map)[folderId];
|
return (*g_known_folders_data)[folderId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize on first call
|
//Initialize on first call
|
||||||
if(g_known_folders_map.isNull())
|
if(g_known_folders_data.isNull())
|
||||||
{
|
{
|
||||||
g_known_folders_map.reset(new QMap<size_t, QString>());
|
g_known_folders_data.reset(new QHash<size_t, QString>());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString folderPath;
|
QString folderPath;
|
||||||
@ -790,10 +790,11 @@ const QString &MUtils::OS::known_folder(known_folder_t folder_id)
|
|||||||
//Update cache
|
//Update cache
|
||||||
if (!folderPath.isEmpty())
|
if (!folderPath.isEmpty())
|
||||||
{
|
{
|
||||||
g_known_folders_map->insert(folderId, folderPath);
|
g_known_folders_data->insert(folderId, folderPath);
|
||||||
|
return (*g_known_folders_data)[folderId];
|
||||||
}
|
}
|
||||||
|
|
||||||
return folderPath;
|
return Internal::g_empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user