From 23140b3d6a112de46029c9f5cbb3743971ff7438 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Thu, 21 Jun 2018 23:35:28 +0100
Subject: [PATCH] Fix build for old OS X.

---
 Telegram/SourceFiles/export/output/export_output_file.cpp | 5 ++---
 Telegram/SourceFiles/stdafx.h                             | 1 -
 Telegram/gyp/settings_mac.gypi                            | 3 +++
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Telegram/SourceFiles/export/output/export_output_file.cpp b/Telegram/SourceFiles/export/output/export_output_file.cpp
index c90cdf558..77b76706f 100644
--- a/Telegram/SourceFiles/export/output/export_output_file.cpp
+++ b/Telegram/SourceFiles/export/output/export_output_file.cpp
@@ -102,13 +102,12 @@ QString File::PrepareRelativePath(
 
 	// Not lastIndexOf('.') so that "file.tar.xz" won't be messed up.
 	const auto position = suggested.indexOf('.');
-	const auto base = suggested.midRef(0, position);
+	const auto base = suggested.midRef(0, position).toString();
 	const auto extension = (position >= 0)
 		? suggested.midRef(position)
 		: QStringRef();
 	const auto relativePart = [&](int attempt) {
-		auto result = QString(" (%1)").arg(attempt);
-		result.prepend(base);
+		auto result = base + QString(" (%1)").arg(attempt);
 		result.append(extension);
 		return result;
 	};
diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h
index f118305b3..20ca3c079 100644
--- a/Telegram/SourceFiles/stdafx.h
+++ b/Telegram/SourceFiles/stdafx.h
@@ -39,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 
 #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
 #define OS_MAC_OLD
-#define RANGES_CXX_THREAD_LOCAL 0
 #endif // QT_VERSION < 5.5.0
 
 #ifdef OS_MAC_STORE
diff --git a/Telegram/gyp/settings_mac.gypi b/Telegram/gyp/settings_mac.gypi
index 7bb67036c..c572c543a 100644
--- a/Telegram/gyp/settings_mac.gypi
+++ b/Telegram/gyp/settings_mac.gypi
@@ -85,6 +85,9 @@
           '-w', # Suppress 'libstdc++ is deprecated' warning.
         ],
       },
+      'defines': [
+        'RANGES_CXX_THREAD_LOCAL=0',
+      ],
     }, {
       'xcode_settings': {
         'CLANG_CXX_LIBRARY': 'libc++',