From 7d3d01a1175895d753b16621dfe6f42ac16c1a87 Mon Sep 17 00:00:00 2001 From: Stanislav Ershov Date: Mon, 27 Nov 2017 13:16:11 +0300 Subject: [PATCH] Tons of compilation bugs fixed --- Telegram/SourceFiles/autoupdater.cpp | 34 +++++++++---------- .../SourceFiles/codegen/emoji/generator.cpp | 10 +++--- Telegram/SourceFiles/main.cpp | 4 +-- .../SourceFiles/platform/win/audio_win.cpp | 8 ++--- .../platform/win/file_utilities_win.cpp | 12 +++---- .../platform/win/main_window_win.cpp | 26 +++++--------- .../win/notifications_manager_win.cpp | 9 +---- .../SourceFiles/platform/win/specific_win.cpp | 22 +----------- .../platform/win/window_title_win.cpp | 1 + .../win/windows_app_user_model_id.cpp | 6 +--- .../SourceFiles/platform/win/windows_dlls.cpp | 1 + .../SourceFiles/platform/win/windows_dlls.h | 3 -- .../platform/win/windows_event_filter.cpp | 1 + Telegram/SourceFiles/stdafx.h | 30 ++++++++++++++++ Telegram/SourceFiles/ui/special_buttons.cpp | 6 ++-- .../emoji_suggestions/emoji_suggestions.cpp | 12 +++---- .../emoji_suggestions/emoji_suggestions.h | 2 +- 17 files changed, 88 insertions(+), 99 deletions(-) diff --git a/Telegram/SourceFiles/autoupdater.cpp b/Telegram/SourceFiles/autoupdater.cpp index a6aa4c296..36ae2d53b 100644 --- a/Telegram/SourceFiles/autoupdater.cpp +++ b/Telegram/SourceFiles/autoupdater.cpp @@ -26,11 +26,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include #include -#ifdef Q_OS_WIN // use Lzma SDK for win -#include -#else // Q_OS_WIN +//#ifdef Q_OS_WIN // use Lzma SDK for win +//#include +//#else // Q_OS_WIN #include -#endif // else of Q_OS_WIN +//#endif // else of Q_OS_WIN #include "application.h" #include "platform/platform_specific.h" @@ -244,11 +244,11 @@ void UpdateChecker::unpackUpdate() { return fatalFail(); } -#ifdef Q_OS_WIN // use Lzma SDK for win - const int32 hSigLen = 128, hShaLen = 20, hPropsLen = LZMA_PROPS_SIZE, hOriginalSizeLen = sizeof(int32), hSize = hSigLen + hShaLen + hPropsLen + hOriginalSizeLen; // header -#else // Q_OS_WIN +//#ifdef Q_OS_WIN // use Lzma SDK for win +// const int32 hSigLen = 128, hShaLen = 20, hPropsLen = LZMA_PROPS_SIZE, hOriginalSizeLen = sizeof(int32), hSize = hSigLen + hShaLen + hPropsLen + hOriginalSizeLen; // header +//#else // Q_OS_WIN const int32 hSigLen = 128, hShaLen = 20, hPropsLen = 0, hOriginalSizeLen = sizeof(int32), hSize = hSigLen + hShaLen + hOriginalSizeLen; // header -#endif // Q_OS_WIN +//#endif // Q_OS_WIN QByteArray compressed = outputFile.readAll(); int32 compressedLen = compressed.size() - hSize; @@ -306,14 +306,14 @@ void UpdateChecker::unpackUpdate() { uncompressed.resize(uncompressedLen); size_t resultLen = uncompressed.size(); -#ifdef Q_OS_WIN // use Lzma SDK for win - SizeT srcLen = compressedLen; - int uncompressRes = LzmaUncompress((uchar*)uncompressed.data(), &resultLen, (const uchar*)(compressed.constData() + hSize), &srcLen, (const uchar*)(compressed.constData() + hSigLen + hShaLen), LZMA_PROPS_SIZE); - if (uncompressRes != SZ_OK) { - LOG(("Update Error: could not uncompress lzma, code: %1").arg(uncompressRes)); - return fatalFail(); - } -#else // Q_OS_WIN +//#ifdef Q_OS_WIN // use Lzma SDK for win +// SizeT srcLen = compressedLen; +// int uncompressRes = LzmaUncompress((uchar*)uncompressed.data(), &resultLen, (const uchar*)(compressed.constData() + hSize), &srcLen, (const uchar*)(compressed.constData() + hSigLen + hShaLen), LZMA_PROPS_SIZE); +// if (uncompressRes != SZ_OK) { +// LOG(("Update Error: could not uncompress lzma, code: %1").arg(uncompressRes)); +// return fatalFail(); +// } +//#else // Q_OS_WIN lzma_stream stream = LZMA_STREAM_INIT; lzma_ret ret = lzma_stream_decoder(&stream, UINT64_MAX, LZMA_CONCATENATED); @@ -356,7 +356,7 @@ void UpdateChecker::unpackUpdate() { LOG(("Error in decompression: %1 (error code %2)").arg(msg).arg(res)); return fatalFail(); } -#endif // Q_OS_WIN +//#endif // Q_OS_WIN tempDir.mkdir(tempDir.absolutePath()); diff --git a/Telegram/SourceFiles/codegen/emoji/generator.cpp b/Telegram/SourceFiles/codegen/emoji/generator.cpp index 55c0f3a1f..d8da1d038 100644 --- a/Telegram/SourceFiles/codegen/emoji/generator.cpp +++ b/Telegram/SourceFiles/codegen/emoji/generator.cpp @@ -806,9 +806,9 @@ bool Generator::writeReplacements() { QMap> byCharIndices; suggestionsSource_->stream() << "\ struct ReplacementStruct {\n\ - small emojiSize;\n\ - small replacementSize;\n\ - small wordsCount;\n\ + smallchar emojiSize;\n\ + smallchar replacementSize;\n\ + smallchar wordsCount;\n\ };\n\ \n\ const utf16char ReplacementData[] = {"; @@ -833,7 +833,7 @@ const utf16char ReplacementData[] = {"; } suggestionsSource_->stream() << " };\n\ \n\ -const small ReplacementWordLengths[] = {"; +const smallchar ReplacementWordLengths[] = {"; startBinary(); for (auto &replace : replaces_.list) { auto wordLengths = QStringList(); @@ -846,7 +846,7 @@ const small ReplacementWordLengths[] = {"; const ReplacementStruct ReplacementInitData[] = {\n"; for (auto &replace : replaces_.list) { suggestionsSource_->stream() << "\ - { small(" << replace.id.size() << "), small(" << replace.replacement.size() << "), small(" << replace.words.size() << ") },\n"; + { smallchar(" << replace.id.size() << "), smallchar(" << replace.replacement.size() << "), smallchar(" << replace.words.size() << ") },\n"; } suggestionsSource_->stream() << "};\n\ \n\ diff --git a/Telegram/SourceFiles/main.cpp b/Telegram/SourceFiles/main.cpp index 5b29d3f11..bbe88475b 100644 --- a/Telegram/SourceFiles/main.cpp +++ b/Telegram/SourceFiles/main.cpp @@ -44,8 +44,8 @@ int main(int argc, char *argv[]) { #else QCoreApplication::addLibraryPath("/usr/lib/qt5/plugins"); #endif - setenv("QT_STYLE_OVERRIDE", "qwerty", false); - unsetenv("QT_QPA_PLATFORMTHEME"); + qputenv("QT_STYLE_OVERRIDE", "qwerty"); + qunsetenv("QT_QPA_PLATFORMTHEME"); int result = 0; { diff --git a/Telegram/SourceFiles/platform/win/audio_win.cpp b/Telegram/SourceFiles/platform/win/audio_win.cpp index 1d9dfab40..41455768a 100644 --- a/Telegram/SourceFiles/platform/win/audio_win.cpp +++ b/Telegram/SourceFiles/platform/win/audio_win.cpp @@ -18,20 +18,20 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" + #include "platform/win/audio_win.h" #include "platform/win/windows_dlls.h" #include "media/media_audio.h" -#include -#include - -#include using namespace Microsoft::WRL; namespace Platform { namespace Audio { namespace { +const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator); +const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator); // Inspired by Chromium. class DeviceListener : public IMMNotificationClient { diff --git a/Telegram/SourceFiles/platform/win/file_utilities_win.cpp b/Telegram/SourceFiles/platform/win/file_utilities_win.cpp index bf0806351..9f0d420af 100644 --- a/Telegram/SourceFiles/platform/win/file_utilities_win.cpp +++ b/Telegram/SourceFiles/platform/win/file_utilities_win.cpp @@ -18,6 +18,8 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" +#include #include "platform/win/file_utilities_win.h" #include "mainwindow.h" @@ -26,8 +28,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "lang/lang_keys.h" #include "messenger.h" -#include -#include HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &, int hbitmapFormat); @@ -420,9 +420,9 @@ bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, } else { files = dialog.selectedFiles().mid(0, 1); } - if (type == Type::ReadFile || type == Type::ReadFiles) { - remoteContent = dialog.selectedRemoteContent(); - } +// if (type == Type::ReadFile || type == Type::ReadFiles) { +// remoteContent = dialog.selectedRemoteContent(); +// } return true; } @@ -432,4 +432,4 @@ bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, } } // namespace FileDialog -} // namespace Platform \ No newline at end of file +} // namespace Platform diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 33f6b5ae6..b90a499aa 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -18,6 +18,7 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" #include "platform/win/main_window_win.h" #include "styles/style_window.h" @@ -34,17 +35,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include -#include -#include -#include - -#include -#include -#include -#include - -#include - #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) < (b) ? (b) : (a)) #include @@ -229,7 +219,7 @@ public: destroy(); return false; } - SetWindowLong(hwnds[i], GWL_HWNDPARENT, (LONG)hwnd); + SetWindowLong(hwnds[i], GWLP_HWNDPARENT, (LONG)hwnd); dcs[i] = CreateCompatibleDC(screenDC); if (!dcs[i]) { @@ -705,18 +695,18 @@ void MainWindow::workmodeUpdated(DBIWorkMode mode) { switch (mode) { case dbiwmWindowAndTray: { psSetupTrayIcon(); - HWND psOwner = (HWND)GetWindowLong(ps_hWnd, GWL_HWNDPARENT); + HWND psOwner = (HWND)GetWindowLong(ps_hWnd, GWLP_HWNDPARENT); if (psOwner) { - SetWindowLong(ps_hWnd, GWL_HWNDPARENT, 0); + SetWindowLong(ps_hWnd, GWLP_HWNDPARENT, 0); psRefreshTaskbarIcon(); } } break; case dbiwmTrayOnly: { psSetupTrayIcon(); - HWND psOwner = (HWND)GetWindowLong(ps_hWnd, GWL_HWNDPARENT); + HWND psOwner = (HWND)GetWindowLong(ps_hWnd, GWLP_HWNDPARENT); if (!psOwner) { - SetWindowLong(ps_hWnd, GWL_HWNDPARENT, (LONG)ps_tbHider_hWnd); + SetWindowLong(ps_hWnd, GWLP_HWNDPARENT, (LONG)ps_tbHider_hWnd); } } break; @@ -727,9 +717,9 @@ void MainWindow::workmodeUpdated(DBIWorkMode mode) { } trayIcon = 0; - HWND psOwner = (HWND)GetWindowLong(ps_hWnd, GWL_HWNDPARENT); + HWND psOwner = (HWND)GetWindowLong(ps_hWnd, GWLP_HWNDPARENT); if (psOwner) { - SetWindowLong(ps_hWnd, GWL_HWNDPARENT, 0); + SetWindowLong(ps_hWnd, GWLP_HWNDPARENT, 0); psRefreshTaskbarIcon(); } } break; diff --git a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp index 1c67bf299..0c4f0eb02 100644 --- a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp +++ b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp @@ -18,6 +18,7 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" #include "platform/win/notifications_manager_win.h" #include "window/notifications_utilities.h" @@ -27,14 +28,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "mainwindow.h" #include "base/task_queue.h" -#include -#include - -#include -#include -#include -#include - #include #include diff --git a/Telegram/SourceFiles/platform/win/specific_win.cpp b/Telegram/SourceFiles/platform/win/specific_win.cpp index 9d04deaaf..c3cb9dcbb 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.cpp +++ b/Telegram/SourceFiles/platform/win/specific_win.cpp @@ -18,6 +18,7 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" #include "platform/win/specific_win.h" #include "platform/win/main_window_win.h" @@ -33,35 +34,14 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "passcodewidget.h" #include "base/task_queue.h" -#include -#include - -#include -#include -#include -#include - #pragma warning(push) #pragma warning(disable:4091) #include #include #pragma warning(pop) -#include -#include -#include -#include -#include - -#include -#include #include -#include -#include -#include -#include -#include #include diff --git a/Telegram/SourceFiles/platform/win/window_title_win.cpp b/Telegram/SourceFiles/platform/win/window_title_win.cpp index 57d0bf200..51cd75d8c 100644 --- a/Telegram/SourceFiles/platform/win/window_title_win.cpp +++ b/Telegram/SourceFiles/platform/win/window_title_win.cpp @@ -18,6 +18,7 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" #include "platform/win/window_title_win.h" #include "ui/widgets/buttons.h" diff --git a/Telegram/SourceFiles/platform/win/windows_app_user_model_id.cpp b/Telegram/SourceFiles/platform/win/windows_app_user_model_id.cpp index 8eef2a47c..b208018a0 100644 --- a/Telegram/SourceFiles/platform/win/windows_app_user_model_id.cpp +++ b/Telegram/SourceFiles/platform/win/windows_app_user_model_id.cpp @@ -18,17 +18,13 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" #include "platform/win/windows_app_user_model_id.h" #include "platform/win/windows_dlls.h" #include #include -#include -#include -#include -#include - using namespace Microsoft::WRL; namespace Platform { diff --git a/Telegram/SourceFiles/platform/win/windows_dlls.cpp b/Telegram/SourceFiles/platform/win/windows_dlls.cpp index 2f6ffb272..44e0f4259 100644 --- a/Telegram/SourceFiles/platform/win/windows_dlls.cpp +++ b/Telegram/SourceFiles/platform/win/windows_dlls.cpp @@ -18,6 +18,7 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" #include "platform/win/windows_dlls.h" namespace Platform { diff --git a/Telegram/SourceFiles/platform/win/windows_dlls.h b/Telegram/SourceFiles/platform/win/windows_dlls.h index ae0c8b3c7..867bbc3cb 100644 --- a/Telegram/SourceFiles/platform/win/windows_dlls.h +++ b/Telegram/SourceFiles/platform/win/windows_dlls.h @@ -20,9 +20,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #pragma once -#include -#include -#include namespace Platform { namespace Dlls { diff --git a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp index a28f40b57..fc4d488df 100644 --- a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp +++ b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp @@ -18,6 +18,7 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "stdafx.h" #include "platform/win/windows_event_filter.h" #include "mainwindow.h" diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 9c1d5f5e3..f39f36f65 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -53,6 +53,36 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #define MAC_USE_BREAKPAD #endif // OS_MAC_STORE +#ifdef Q_OS_WIN +#include + +// Windows Header Files: +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#endif + #include #include diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index 3799c807d..f4540e28e 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -337,9 +337,9 @@ void NewAvatarButton::paintEvent(QPaintEvent *e) { } void NewAvatarButton::setImage(const QImage &image) { - auto small = image.scaled(size() * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - Images::prepareCircle(small); - _image = App::pixmapFromImageInPlace(std::move(small)); + auto smallImg = image.scaled(size() * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + Images::prepareCircle(smallImg); + _image = App::pixmapFromImageInPlace(std::move(smallImg)); _image.setDevicePixelRatio(cRetinaFactor()); update(); } diff --git a/Telegram/ThirdParty/emoji_suggestions/emoji_suggestions.cpp b/Telegram/ThirdParty/emoji_suggestions/emoji_suggestions.cpp index ebe23cbd5..5d3220d7e 100644 --- a/Telegram/ThirdParty/emoji_suggestions/emoji_suggestions.cpp +++ b/Telegram/ThirdParty/emoji_suggestions/emoji_suggestions.cpp @@ -159,7 +159,7 @@ private: class UsedWordGuard { public: - UsedWordGuard(std::vector &map, int index); + UsedWordGuard(std::vector &map, int index); UsedWordGuard(const UsedWordGuard &other) = delete; UsedWordGuard(UsedWordGuard &&other); UsedWordGuard &operator=(const UsedWordGuard &other) = delete; @@ -168,16 +168,16 @@ private: ~UsedWordGuard(); private: - std::vector &_map; + std::vector &_map; int _index = 0; - small _guarded = 0; + smallchar _guarded = 0; }; - std::vector _currentItemWordsUsedMap; + std::vector _currentItemWordsUsedMap; }; -Completer::UsedWordGuard::UsedWordGuard(std::vector &map, int index) : _map(map), _index(index) { +Completer::UsedWordGuard::UsedWordGuard(std::vector &map, int index) : _map(map), _index(index) { Expects(_map.size() > _index); if (!_map[_index]) { _guarded = _map[_index] = 1; @@ -297,7 +297,7 @@ void Completer::initWordsTracking() { maxWordsCount = wordsCount; } } - _currentItemWordsUsedMap = std::vector(maxWordsCount, 0); + _currentItemWordsUsedMap = std::vector(maxWordsCount, 0); } void Completer::filterInitialList() { diff --git a/Telegram/ThirdParty/emoji_suggestions/emoji_suggestions.h b/Telegram/ThirdParty/emoji_suggestions/emoji_suggestions.h index 8a593d1d9..d99bd0d1c 100644 --- a/Telegram/ThirdParty/emoji_suggestions/emoji_suggestions.h +++ b/Telegram/ThirdParty/emoji_suggestions/emoji_suggestions.h @@ -25,7 +25,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace Ui { namespace Emoji { -using small = unsigned char; +using smallchar = unsigned char; using medium = unsigned short; using utf16char = unsigned short;