diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml
index c4150dfc9..a0a6cf891 100644
--- a/Telegram/Resources/uwp/AppX/AppxManifest.xml
+++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml
@@ -9,7 +9,7 @@
+ Version="1.0.16.0" />
Telegram Desktop
Telegram Messenger LLP
diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc
index 0c645f186..5aa0be04d 100644
--- a/Telegram/Resources/winrc/Telegram.rc
+++ b/Telegram/Resources/winrc/Telegram.rc
@@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,15,0
- PRODUCTVERSION 1,0,15,0
+ FILEVERSION 1,0,16,0
+ PRODUCTVERSION 1,0,16,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -52,10 +52,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Desktop"
- VALUE "FileVersion", "1.0.15.0"
+ VALUE "FileVersion", "1.0.16.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2017"
VALUE "ProductName", "Telegram Desktop"
- VALUE "ProductVersion", "1.0.15.0"
+ VALUE "ProductVersion", "1.0.16.0"
END
END
BLOCK "VarFileInfo"
diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc
index 2d14505ca..253d3d4a3 100644
--- a/Telegram/Resources/winrc/Updater.rc
+++ b/Telegram/Resources/winrc/Updater.rc
@@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,15,0
- PRODUCTVERSION 1,0,15,0
+ FILEVERSION 1,0,16,0
+ PRODUCTVERSION 1,0,16,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -43,10 +43,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Desktop Updater"
- VALUE "FileVersion", "1.0.15.0"
+ VALUE "FileVersion", "1.0.16.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2017"
VALUE "ProductName", "Telegram Desktop"
- VALUE "ProductVersion", "1.0.15.0"
+ VALUE "ProductVersion", "1.0.16.0"
END
END
BLOCK "VarFileInfo"
diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h
index 11711a4f0..621cd46e0 100644
--- a/Telegram/SourceFiles/core/version.h
+++ b/Telegram/SourceFiles/core/version.h
@@ -24,7 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#define BETA_VERSION_MACRO (0ULL)
-constexpr int AppVersion = 1000015;
-constexpr str_const AppVersionStr = "1.0.15";
+constexpr int AppVersion = 1000016;
+constexpr str_const AppVersionStr = "1.0.16";
constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;
diff --git a/Telegram/SourceFiles/mtproto/core_types.h b/Telegram/SourceFiles/mtproto/core_types.h
index 3effdb5e9..79c43f223 100644
--- a/Telegram/SourceFiles/mtproto/core_types.h
+++ b/Telegram/SourceFiles/mtproto/core_types.h
@@ -27,7 +27,7 @@ namespace MTP {
// type DcId represents actual data center id, while in most cases
// we use some shifted ids, like DcId() + X * DCShift
using DcId = int32;
-using ShiftedDcId = int32 ;
+using ShiftedDcId = int32;
}
diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp
index 1b4b40dfb..1da9d4ae2 100644
--- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp
+++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp
@@ -170,6 +170,9 @@ private:
SingleTimer _checkDelayedTimer;
+ // Debug flag to find out how we end up crashing.
+ bool MustNotCreateSessions = false;
+
};
Instance::Private::Private(Instance *instance, DcOptions *options, Instance::Mode mode) : _instance(instance)
@@ -210,12 +213,14 @@ void Instance::Private::start(Config &&config) {
if (isKeysDestroyer()) {
for (auto &dc : _dcenters) {
+ t_assert(!MustNotCreateSessions);
auto shiftedDcId = dc.first;
auto session = std::make_unique(_instance, shiftedDcId);
auto it = _sessions.emplace(shiftedDcId, std::move(session)).first;
it->second->start();
}
} else if (_mainDcId != Config::kNoneMainDc) {
+ t_assert(!MustNotCreateSessions);
auto main = std::make_unique(_instance, _mainDcId);
_mainSession = main.get();
_sessions.emplace(_mainDcId, std::move(main));
@@ -296,7 +301,9 @@ int32 Instance::Private::dcstate(ShiftedDcId shiftedDcId) {
}
auto it = _sessions.find(shiftedDcId);
- if (it != _sessions.cend()) return it->second->getState();
+ if (it != _sessions.cend()) {
+ return it->second->getState();
+ }
return DisconnectedState;
}
@@ -383,6 +390,7 @@ void Instance::Private::killSession(ShiftedDcId shiftedDcId) {
if (checkIfMainAndKill(shiftedDcId)) {
checkIfMainAndKill(_mainDcId);
+ t_assert(!MustNotCreateSessions);
auto main = std::make_unique(_instance, _mainDcId);
_mainSession = main.get();
_sessions.emplace(_mainDcId, std::move(main));
@@ -492,6 +500,7 @@ void Instance::Private::addKeysForDestroy(AuthKeysList &&keys) {
auto dc = std::make_shared(_instance, dcId, std::move(key));
_dcenters.emplace(shiftedDcId, std::move(dc));
+ t_assert(!MustNotCreateSessions);
auto session = std::make_unique(_instance, shiftedDcId);
auto it = _sessions.emplace(shiftedDcId, std::move(session)).first;
it->second->start();
@@ -1113,6 +1122,7 @@ internal::Session *Instance::Private::getSession(ShiftedDcId shiftedDcId) {
auto it = _sessions.find(shiftedDcId);
if (it == _sessions.cend()) {
+ t_assert(!MustNotCreateSessions);
it = _sessions.emplace(shiftedDcId, std::make_unique(_instance, shiftedDcId)).first;
it->second->start();
}
@@ -1189,12 +1199,15 @@ void Instance::Private::clearGlobalHandlers() {
}
void Instance::Private::prepareToDestroy() {
+ // It accesses Instance in destructor, so it should be destroyed first.
+ _configLoader.reset();
+
for (auto &session : base::take(_sessions)) {
session.second->kill();
}
+ _mainSession = nullptr;
- // It accesses Instance in destructor, so it should be destroyed first.
- _configLoader.reset();
+ MustNotCreateSessions = true;
}
Instance::Instance(DcOptions *options, Mode mode, Config &&config) : QObject()
diff --git a/Telegram/build/version b/Telegram/build/version
index f9d8ea2b3..c74cf0f10 100644
--- a/Telegram/build/version
+++ b/Telegram/build/version
@@ -1,6 +1,6 @@
-AppVersion 1000015
+AppVersion 1000016
AppVersionStrMajor 1.0
-AppVersionStrSmall 1.0.15
-AppVersionStr 1.0.15
+AppVersionStrSmall 1.0.16
+AppVersionStr 1.0.16
AlphaChannel 1
BetaVersion 0