From 05697374c573bdab151c8495c6ef75489dd0c712 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Mon, 15 Aug 2016 10:39:12 +0300
Subject: [PATCH] Crash fix for inline results clearing. Crash fix for GIF
 starting.

---
 Telegram/SourceFiles/dropdown.cpp              |  2 +-
 Telegram/SourceFiles/media/media_clip_ffmpeg.h |  2 +-
 Telegram/build/build.bat                       | 11 -----------
 3 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp
index 72c1cf737..9ba408f63 100644
--- a/Telegram/SourceFiles/dropdown.cpp
+++ b/Telegram/SourceFiles/dropdown.cpp
@@ -1725,7 +1725,6 @@ void StickerPanInner::refreshSavedGifs() {
 void StickerPanInner::inlineBotChanged() {
 	_setGifCommand = false;
 	refreshInlineRows(nullptr, nullptr, true);
-	deleteUnusedInlineLayouts();
 }
 
 void StickerPanInner::clearInlineRows(bool resultsDeleted) {
@@ -1942,6 +1941,7 @@ int StickerPanInner::refreshInlineRows(UserData *bot, const InlineCacheEntry *en
 	if (clearResults()) {
 		if (resultsDeleted) {
 			clearInlineRows(true);
+			deleteUnusedInlineLayouts();
 		}
 		emit emptyInlineRows();
 		return 0;
diff --git a/Telegram/SourceFiles/media/media_clip_ffmpeg.h b/Telegram/SourceFiles/media/media_clip_ffmpeg.h
index e805a099d..6d1ef3ea5 100644
--- a/Telegram/SourceFiles/media/media_clip_ffmpeg.h
+++ b/Telegram/SourceFiles/media/media_clip_ffmpeg.h
@@ -91,7 +91,7 @@ private:
 	bool _hadFrame = false;
 	bool _frameRead = false;
 
-	int _audioStreamId = 0;
+	int _audioStreamId = -1;
 	uint64 _playId = 0;
 	int64 _lastReadVideoMs = 0;
 	int64 _lastReadAudioMs = 0;
diff --git a/Telegram/build/build.bat b/Telegram/build/build.bat
index 7e7fd05da..993a9285d 100644
--- a/Telegram/build/build.bat
+++ b/Telegram/build/build.bat
@@ -177,29 +177,18 @@ echo .
 set "FinalReleasePath=Z:\TBuild\tother\tsetup"
 set "FinalDeployPath=%FinalReleasePath%\%AppVersionStrMajor%\%AppVersionStrFull%"
 
-echo 1
 if not exist "%DeployPath%\%UpdateFile%" goto error
-echo 2
 if not exist "%DeployPath%\%PortableFile%" goto error
-echo 3
 if %BetaVersion% equ 0 (
   if not exist "%DeployPath%\%SetupFile%" goto error
 )
-echo 4
 if not exist "%DeployPath%\%BinaryName%.pdb" goto error
-echo 5
 if not exist "%DeployPath%\%BinaryName%.exe.pdb" goto error
-echo 6
 if not exist "%DeployPath%\Updater.exe" goto error
-echo 7
 if not exist "%DeployPath%\Updater.pdb" goto error
-echo 8
 if not exist "%DeployPath%\Updater.exe.pdb" goto error
-echo 9
 if not exist "%FinalReleasePath%\%AppVersionStrMajor%" mkdir "%FinalReleasePath%\%AppVersionStrMajor%"
-echo 10
 if not exist "%FinalDeployPath%" mkdir "%FinalDeployPath%"
-echo 11
 
 xcopy "%DeployPath%\%UpdateFile%" "%FinalDeployPath%\"
 xcopy "%DeployPath%\%PortableFile%" "%FinalDeployPath%\"