From 12627bbc10d77c9a2ff1db34c56e96a4ef7522f7 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 27 Feb 2016 08:27:56 +0800 Subject: [PATCH] Create helper function to get boost version --- src/app/stacktrace_win_dlg.h | 14 ++++---------- src/base/utils/misc.cpp | 11 +++++++++++ src/base/utils/misc.h | 1 + src/gui/about_imp.h | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/app/stacktrace_win_dlg.h b/src/app/stacktrace_win_dlg.h index 72cf4715a..178213ad3 100644 --- a/src/app/stacktrace_win_dlg.h +++ b/src/app/stacktrace_win_dlg.h @@ -32,7 +32,6 @@ #include #include -#include "boost/version.hpp" #include "libtorrent/version.hpp" #include "base/utils/misc.h" #include "ui_stacktrace_win_dlg.h" @@ -51,9 +50,6 @@ public: void setStacktraceString(const QString& trace) { // try to call Qt function as less as possible - const int boostVerMajor = BOOST_VERSION / 100000; - const int boostVerMinor = ((BOOST_VERSION / 100) % 1000); - const int boostVerSubMin = BOOST_VERSION % 100; QString htmlStr = QString( "

" "qBittorrent has crashed" @@ -68,14 +64,12 @@ public: "qBittorrent version: " VERSION "
" "Libtorrent version: " LIBTORRENT_VERSION "
" "Qt version: " QT_VERSION_STR "
" - "Boost version: %1.%2.%3
" - "OS version: %4" + "Boost version: %1
" + "OS version: %2" "


" - "
%5
" + "
%3
" "



") - .arg(boostVerMajor) - .arg(boostVerMinor) - .arg(boostVerSubMin) + .arg(Utils::Misc::boostVersionString()) .arg(Utils::Misc::osName()) .arg(trace); diff --git a/src/base/utils/misc.cpp b/src/base/utils/misc.cpp index 2ee30c752..36149d09d 100644 --- a/src/base/utils/misc.cpp +++ b/src/base/utils/misc.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef DISABLE_GUI #include @@ -650,3 +651,13 @@ QString Utils::Misc::osName() #endif return name; } + +QString Utils::Misc::boostVersionString() +{ + // static initialization for usage in signal handler + static const QString ver = QString("%1.%2.%3") + .arg(BOOST_VERSION / 100000) + .arg((BOOST_VERSION / 100) % 1000) + .arg(BOOST_VERSION % 100); + return ver; +} diff --git a/src/base/utils/misc.h b/src/base/utils/misc.h index 3a2250e4b..3c61c5cca 100644 --- a/src/base/utils/misc.h +++ b/src/base/utils/misc.h @@ -57,6 +57,7 @@ namespace Utils QSize smallIconSize(); #endif QString osName(); + QString boostVersionString(); int pythonVersion(); QString pythonExecutable(); diff --git a/src/gui/about_imp.h b/src/gui/about_imp.h index c5a8fce65..e483911e7 100644 --- a/src/gui/about_imp.h +++ b/src/gui/about_imp.h @@ -34,7 +34,7 @@ #include "ui_about.h" #include #include -#include +#include "base/utils/misc.h" #include "base/unicodestrings.h" class about: public QDialog, private Ui::AboutDlg @@ -92,7 +92,7 @@ public: // Libraries label_11->setText(QT_VERSION_STR); label_12->setText(LIBTORRENT_VERSION); - label_13->setText(QString::number(BOOST_VERSION / 100000) + "." + QString::number((BOOST_VERSION / 100) % 1000) + "." + QString::number(BOOST_VERSION % 100)); + label_13->setText(Utils::Misc::boostVersionString()); show(); }