• R/O
  • HTTP
  • SSH
  • HTTPS

MUtilities: 提交

MUtilities development repository


Commit MetaInfo

修订版7605972d020e6ce1f388921baa0663de5af12063 (tree)
时间2021-12-25 08:40:13
作者LoRd_MuldeR <mulder2@gmx....>
CommiterLoRd_MuldeR

Log Message

Small code simplification in OS detection code.

更改概述

差异

--- a/include/MUtils/OSSupport.h
+++ b/include/MUtils/OSSupport.h
@@ -75,7 +75,6 @@ namespace MUtils
7575 unsigned int versionMinor; ///< The *minor* version of the underlaying operating system
7676 unsigned int versionBuild; ///< The *build* number of the underlaying operating system
7777 unsigned int versionSPack; ///< The *service pack* version of the underlaying operating system
78- bool overrideFlag;
7978
8079 MUTILS_API bool operator> (const _os_version_t &rhs) const;
8180 MUTILS_API bool operator>= (const _os_version_t &rhs) const;
--- a/src/OSSupport_Win32.cpp
+++ b/src/OSSupport_Win32.cpp
@@ -277,21 +277,20 @@ static QReadWriteLock g_os_version_lock;
277277 static const struct
278278 {
279279 MUtils::OS::Version::os_version_t version;
280- bool checkBuildNo;
281280 const char friendlyName[64];
282281 }
283282 g_os_version_lut[] =
284283 {
285- { MUtils::OS::Version::WINDOWS_WIN2K, 0, "Windows 2000" }, //2000
286- { MUtils::OS::Version::WINDOWS_WINXP, 0, "Windows XP or Windows XP Media Center Edition" }, //XP
287- { MUtils::OS::Version::WINDOWS_XPX64, 0, "Windows Server 2003 or Windows XP x64" }, //XP_x64
288- { MUtils::OS::Version::WINDOWS_VISTA, 0, "Windows Vista or Windows Server 2008" }, //Vista
289- { MUtils::OS::Version::WINDOWS_WIN70, 0, "Windows 7 or Windows Server 2008 R2" }, //7
290- { MUtils::OS::Version::WINDOWS_WIN80, 0, "Windows 8 or Windows Server 2012" }, //8
291- { MUtils::OS::Version::WINDOWS_WIN81, 0, "Windows 8.1 or Windows Server 2012 R2" }, //8.1
292- { MUtils::OS::Version::WINDOWS_WIN10, 0, "Windows 10 or Windows Server 2016" }, //10
293- { MUtils::OS::Version::WINDOWS_WIN11, 1, "Windows 11 or Windows Server 2022" }, //11
294- { MUtils::OS::Version::UNKNOWN_OPSYS, 0, "N/A" }
284+ { MUtils::OS::Version::WINDOWS_WIN2K, "Windows 2000" }, //2000
285+ { MUtils::OS::Version::WINDOWS_WINXP, "Windows XP or Windows XP Media Center Edition" }, //XP
286+ { MUtils::OS::Version::WINDOWS_XPX64, "Windows Server 2003 or Windows XP x64" }, //XP_x64
287+ { MUtils::OS::Version::WINDOWS_VISTA, "Windows Vista or Windows Server 2008" }, //Vista
288+ { MUtils::OS::Version::WINDOWS_WIN70, "Windows 7 or Windows Server 2008 R2" }, //7
289+ { MUtils::OS::Version::WINDOWS_WIN80, "Windows 8 or Windows Server 2012" }, //8
290+ { MUtils::OS::Version::WINDOWS_WIN81, "Windows 8.1 or Windows Server 2012 R2" }, //8.1
291+ { MUtils::OS::Version::WINDOWS_WIN10, "Windows 10 or Windows Server 2016" }, //10
292+ { MUtils::OS::Version::WINDOWS_WIN11, "Windows 11 or Windows Server 2022" }, //11
293+ { MUtils::OS::Version::UNKNOWN_OPSYS, "N/A" }
295294 };
296295
297296 //OS version data dtructures
@@ -308,15 +307,15 @@ namespace MUtils
308307 bool os_version_t::operator<= (const os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor)) || ((versionMajor == rhs.versionMajor) && (versionMinor == rhs.versionMinor) && (versionBuild <= rhs.versionBuild)); }
309308
310309 //Known Windows NT versions
311- const os_version_t WINDOWS_WIN2K = { OS_WINDOWS, 5, 0, 2195, 0 }; // 2000
312- const os_version_t WINDOWS_WINXP = { OS_WINDOWS, 5, 1, 2600, 0 }; // XP
313- const os_version_t WINDOWS_XPX64 = { OS_WINDOWS, 5, 2, 3790, 0 }; // XP_x64
314- const os_version_t WINDOWS_VISTA = { OS_WINDOWS, 6, 0, 6000, 0 }; // Vista
315- const os_version_t WINDOWS_WIN70 = { OS_WINDOWS, 6, 1, 7600, 0 }; // 7
316- const os_version_t WINDOWS_WIN80 = { OS_WINDOWS, 6, 2, 9200, 0 }; // 8
317- const os_version_t WINDOWS_WIN81 = { OS_WINDOWS, 6, 3, 9600, 0 }; // 8.1
318- const os_version_t WINDOWS_WIN10 = { OS_WINDOWS, 10, 0, 10240, 0 }; // 10
319- const os_version_t WINDOWS_WIN11 = { OS_WINDOWS, 10, 0, 22000, 0 }; // 11
310+ const os_version_t WINDOWS_WIN2K = { OS_WINDOWS, 5U, 0U, 0U, 0U }; // 2000
311+ const os_version_t WINDOWS_WINXP = { OS_WINDOWS, 5U, 1U, 0U, 0U }; // XP
312+ const os_version_t WINDOWS_XPX64 = { OS_WINDOWS, 5U, 2U, 0U, 0U }; // XP_x64
313+ const os_version_t WINDOWS_VISTA = { OS_WINDOWS, 6U, 0U, 0U, 0U }; // Vista
314+ const os_version_t WINDOWS_WIN70 = { OS_WINDOWS, 6U, 1U, 0U, 0U }; // 7
315+ const os_version_t WINDOWS_WIN80 = { OS_WINDOWS, 6U, 2U, 0U, 0U }; // 8
316+ const os_version_t WINDOWS_WIN81 = { OS_WINDOWS, 6U, 3U, 0U, 0U }; // 8.1
317+ const os_version_t WINDOWS_WIN10 = { OS_WINDOWS, 10U, 0U, 0U, 0U }; // 10
318+ const os_version_t WINDOWS_WIN11 = { OS_WINDOWS, 10U, 0U, 22000U, 0U }; // 11
320319
321320 //Unknown OS
322321 const os_version_t UNKNOWN_OPSYS = { OS_UNKNOWN, 0, 0, 0, 0 }; // N/A
@@ -370,16 +369,14 @@ static bool rtl_get_version(OSVERSIONINFOEXW *const osInfo)
370369
371370 #pragma warning(pop)
372371
373-static bool get_real_os_version(unsigned int *const major, unsigned int *const minor, unsigned int *const build, unsigned int *const spack, bool *const pbOverride)
372+static bool get_real_os_version(unsigned int *const major, unsigned int *const minor, unsigned int *const build, unsigned int *const spack)
374373 {
375374 static const DWORD MAX_VERSION = MAXWORD;
376375 static const DWORD MAX_BUILDNO = MAXINT;
377376 static const DWORD MAX_SRVCPCK = MAXWORD;
378-
379- *major = *minor = *build = *spack = 0U;
380- *pbOverride = false;
381377
382378 //Initialize local variables
379+ *major = *minor = *build = *spack = 0U;
383380 OSVERSIONINFOEXW osvi;
384381 memset(&osvi, 0, sizeof(OSVERSIONINFOEXW));
385382 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
@@ -428,15 +425,14 @@ const MUtils::OS::Version::os_version_t &MUtils::OS::os_version(void)
428425 }
429426
430427 //Detect OS version
431- unsigned int major, minor, build, spack; bool overrideFlg;
432- if(get_real_os_version(&major, &minor, &build, &spack, &overrideFlg))
428+ unsigned int major, minor, build, spack;
429+ if(get_real_os_version(&major, &minor, &build, &spack))
433430 {
434431 g_os_version_info.type = Version::OS_WINDOWS;
435432 g_os_version_info.versionMajor = major;
436433 g_os_version_info.versionMinor = minor;
437434 g_os_version_info.versionBuild = build;
438435 g_os_version_info.versionSPack = spack;
439- g_os_version_info.overrideFlag = overrideFlg;
440436 }
441437 else
442438 {
@@ -454,7 +450,7 @@ const char *MUtils::OS::os_friendly_name(const MUtils::OS::Version::os_version_t
454450 for (size_t i = 0; g_os_version_lut[i].version.type != MUtils::OS::Version::OS_UNKNOWN; i++)
455451 {
456452 const MUtils::OS::Version::os_version_t &version = g_os_version_lut[i].version;
457- if ((os_version.versionMajor == version.versionMajor) && (os_version.versionMinor == version.versionMinor) && ((!g_os_version_lut[i].checkBuildNo) || (os_version.versionBuild >= version.versionBuild)))
453+ if ((os_version.versionMajor == version.versionMajor) && (os_version.versionMinor == version.versionMinor) && (os_version.versionBuild >= version.versionBuild))
458454 {
459455 friendly_name = g_os_version_lut[i].friendlyName;
460456 }
--- a/src/Startup.cpp
+++ b/src/Startup.cpp
@@ -359,17 +359,6 @@ QApplication *MUtils::Startup::create_qt(int &argc, char **argv, const QString &
359359 qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Windows 8.1 or later.").arg(executableName)));
360360 }
361361
362- //Check for compat mode
363- if(osVersion.overrideFlag && (osVersion <= MUtils::OS::Version::WINDOWS_WIN10))
364- {
365- qWarning("Windows compatibility mode detected!");
366- if(!arguments.contains("ignore-compat-mode"))
367- {
368- qFatal("%s", QApplication::tr("Executable '%1' doesn't support Windows compatibility mode.").arg(executableName).toLatin1().constData());
369- return NULL;
370- }
371- }
372-
373362 //Check for Wine
374363 if(MUtils::OS::running_on_wine())
375364 {
Show on old repository browser