diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 6 | ||||
| -rw-r--r-- | src/nexusinterface.cpp | 5 | ||||
| -rw-r--r-- | src/selfupdater.cpp | 42 | ||||
| -rw-r--r-- | src/shared/util.cpp | 46 | ||||
| -rw-r--r-- | src/shared/util.h | 3 |
5 files changed, 52 insertions, 50 deletions
diff --git a/src/main.cpp b/src/main.cpp index 9c30a1c6..bfc3b926 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -446,11 +446,7 @@ static void preloadSsl() static QString getVersionDisplayString()
{
- VS_FIXEDFILEINFO version = GetFileVersion(ToWString(QApplication::applicationFilePath()));
- return VersionInfo(version.dwFileVersionMS >> 16,
- version.dwFileVersionMS & 0xFFFF,
- version.dwFileVersionLS >> 16,
- version.dwFileVersionLS & 0xFFFF).displayString();
+ return createVersionInfo().displayString();
}
int runApplication(MOApplication &application, SingleInstance &instance,
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index d2a52c7b..e97e9800 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -147,10 +147,7 @@ QAtomicInt NexusInterface::NXMRequestInfo::s_NextID(0); NexusInterface::NexusInterface(PluginContainer *pluginContainer)
: m_NMMVersion(), m_PluginContainer(pluginContainer)
{
- VS_FIXEDFILEINFO version = GetFileVersion(ToWString(QApplication::applicationFilePath()));
- m_MOVersion = VersionInfo(version.dwFileVersionMS >> 16,
- version.dwFileVersionMS & 0xFFFF,
- version.dwFileVersionLS >> 16);
+ m_MOVersion = createVersionInfo();
m_AccessManager = new NXMAccessManager(this, m_MOVersion.displayString());
m_DiskCache = new QNetworkDiskCache(this);
diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index a57b7962..2b051b09 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -102,47 +102,7 @@ SelfUpdater::SelfUpdater(NexusInterface *nexusInterface) throw MyException(InstallationManager::getErrorString(m_ArchiveHandler->getLastError()));
}
- VS_FIXEDFILEINFO version = GetFileVersion(ToWString(QApplication::applicationFilePath()));
-
- if (version.dwFileFlags | VS_FF_PRERELEASE)
- {
- // Pre-release builds need annotating
- QString versionString = QString::fromStdWString(GetFileVersionString(ToWString(QApplication::applicationFilePath())));
-
- // The pre-release flag can be set without the string specifying what type of pre-release
- bool noLetters = true;
- for (QChar character : versionString)
- {
- if (character.isLetter())
- {
- noLetters = false;
- break;
- }
- }
-
- if (noLetters)
- {
- // Default to pre-alpha when release type is unspecified
- m_MOVersion = VersionInfo(version.dwFileVersionMS >> 16,
- version.dwFileVersionMS & 0xFFFF,
- version.dwFileVersionLS >> 16,
- version.dwFileVersionLS & 0xFFFF,
- VersionInfo::RELEASE_PREALPHA);
- }
- else
- {
- // Trust the string to make sense
- m_MOVersion = VersionInfo(versionString);
- }
- }
- else
- {
- // Non-pre-release builds just need their version numbers reading
- m_MOVersion = VersionInfo(version.dwFileVersionMS >> 16,
- version.dwFileVersionMS & 0xFFFF,
- version.dwFileVersionLS >> 16,
- version.dwFileVersionLS & 0xFFFF);
- }
+ m_MOVersion = createVersionInfo();
}
diff --git a/src/shared/util.cpp b/src/shared/util.cpp index 008c5050..102565f5 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -27,6 +27,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <DbgHelp.h>
#include <set>
#include <boost/scoped_array.hpp>
+#include <QApplication>
namespace MOShared {
@@ -202,5 +203,50 @@ std::wstring GetFileVersionString(const std::wstring &fileName) }
}
+MOBase::VersionInfo createVersionInfo()
+{
+ VS_FIXEDFILEINFO version = GetFileVersion(QApplication::applicationFilePath().toStdWString());
+
+ if (version.dwFileFlags | VS_FF_PRERELEASE)
+ {
+ // Pre-release builds need annotating
+ QString versionString = QString::fromStdWString(GetFileVersionString(QApplication::applicationFilePath().toStdWString()));
+
+ // The pre-release flag can be set without the string specifying what type of pre-release
+ bool noLetters = true;
+ for (QChar character : versionString)
+ {
+ if (character.isLetter())
+ {
+ noLetters = false;
+ break;
+ }
+ }
+
+ if (noLetters)
+ {
+ // Default to pre-alpha when release type is unspecified
+ return MOBase::VersionInfo(version.dwFileVersionMS >> 16,
+ version.dwFileVersionMS & 0xFFFF,
+ version.dwFileVersionLS >> 16,
+ version.dwFileVersionLS & 0xFFFF,
+ MOBase::VersionInfo::RELEASE_PREALPHA);
+ }
+ else
+ {
+ // Trust the string to make sense
+ return MOBase::VersionInfo(versionString);
+ }
+ }
+ else
+ {
+ // Non-pre-release builds just need their version numbers reading
+ return MOBase::VersionInfo(version.dwFileVersionMS >> 16,
+ version.dwFileVersionMS & 0xFFFF,
+ version.dwFileVersionLS >> 16,
+ version.dwFileVersionLS & 0xFFFF);
+ }
+}
+
} // namespace MOShared
diff --git a/src/shared/util.h b/src/shared/util.h index 75c382a7..1fdfb089 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -25,6 +25,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #define WIN32_LEAN_AND_MEAN
#include <Windows.h>
+#include <versioninfo.h>
+
namespace MOShared {
/// Test if a file (or directory) by the specified name exists
@@ -46,6 +48,7 @@ bool CaseInsensitiveEqual(const std::wstring &lhs, const std::wstring &rhs); VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName);
std::wstring GetFileVersionString(const std::wstring &fileName);
+MOBase::VersionInfo createVersionInfo();
} // namespace MOShared
|
