From d6f7cae02490869c217d0dbf7034ff4a06878319 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 1 Dec 2017 20:55:16 +0400 Subject: [PATCH] Fix two crashes in OS X 10.6. Disable rtl control chars (harfbuzz-ng crashes on them). Disable creating state of not yet created top level windows. --- Telegram/SourceFiles/settings.cpp | 4 ++++ Telegram/SourceFiles/settings.h | 1 + Telegram/SourceFiles/ui/text/text.cpp | 9 +++++++++ Telegram/SourceFiles/ui/text/text.h | 6 +++--- Telegram/SourceFiles/ui/twidget.cpp | 4 +++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index a8de70ed90..2268a6b0d0 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -104,6 +104,7 @@ DBIPlatform gPlatform = dbipLinux32; QString gPlatformString; QUrl gUpdateURL; bool gIsElCapitan = false; +bool gIsSnowLeopard = false; int gOtherOnline = 0; @@ -195,6 +196,9 @@ void InitFromCommandLine(int argc, char *argv[]) { gIsElCapitan = true; } #else // OS_MAC_OLD + if (QSysInfo::macVersion() < QSysInfo::MV_10_7) { + gIsSnowLeopard = true; + } gPlatform = dbipMacOld; #endif // OS_MAC_OLD #endif // Q_OS_MAC diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index 51dab5e1b6..9c024c9324 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -248,6 +248,7 @@ DeclareSetting(int32, IntRetinaFactor); DeclareReadSetting(DBIPlatform, Platform); DeclareReadSetting(QString, PlatformString); DeclareReadSetting(bool, IsElCapitan); +DeclareReadSetting(bool, IsSnowLeopard); DeclareReadSetting(QUrl, UpdateURL); DeclareSetting(int, OtherOnline); diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp index 3b655aa029..710277fe29 100644 --- a/Telegram/SourceFiles/ui/text/text.cpp +++ b/Telegram/SourceFiles/ui/text/text.cpp @@ -37,6 +37,15 @@ inline int32 countBlockHeight(const ITextBlock *b, const style::TextStyle *st) { } // namespace +bool chIsBad(QChar ch) { +#ifdef OS_MAC_OLD + if (cIsSnowLeopard() && (ch == 8207 || ch == 8206)) { + return true; + } +#endif // OS_MAC_OLD + return (ch == 0) || (ch >= 8232 && ch < 8237) || (ch >= 65024 && ch < 65040 && ch != 65039) || (ch >= 127 && ch < 160 && ch != 156) || (cPlatform() == dbipMac && ch >= 0x0B00 && ch <= 0x0B7F && chIsDiac(ch) && cIsElCapitan()); // tmp hack see https://bugreports.qt.io/browse/QTBUG-48910 +} + QString textcmdSkipBlock(ushort w, ushort h) { static QString cmd(5, TextCommand); cmd[1] = QChar(TextCommandSkipBlock); diff --git a/Telegram/SourceFiles/ui/text/text.h b/Telegram/SourceFiles/ui/text/text.h index 99d8fb6e5e..87a84c2267 100644 --- a/Telegram/SourceFiles/ui/text/text.h +++ b/Telegram/SourceFiles/ui/text/text.h @@ -275,9 +275,9 @@ inline bool chIsSpace(QChar ch, bool rich = false) { inline bool chIsDiac(QChar ch) { // diac and variation selectors return (ch.category() == QChar::Mark_NonSpacing) || (ch == 1652) || (ch >= 64606 && ch <= 64611); } -inline bool chIsBad(QChar ch) { - return (ch == 0) || (ch >= 8232 && ch < 8237) || (ch >= 65024 && ch < 65040 && ch != 65039) || (ch >= 127 && ch < 160 && ch != 156) || (cPlatform() == dbipMac && ch >= 0x0B00 && ch <= 0x0B7F && chIsDiac(ch) && cIsElCapitan()); // tmp hack see https://bugreports.qt.io/browse/QTBUG-48910 -} + +bool chIsBad(QChar ch); + inline bool chIsTrimmed(QChar ch, bool rich = false) { return (!rich || ch != TextCommand) && (chIsSpace(ch) || chIsBad(ch)); } diff --git a/Telegram/SourceFiles/ui/twidget.cpp b/Telegram/SourceFiles/ui/twidget.cpp index 8e2eff83e8..a78af59dd2 100644 --- a/Telegram/SourceFiles/ui/twidget.cpp +++ b/Telegram/SourceFiles/ui/twidget.cpp @@ -133,8 +133,10 @@ void CreateWidgetStateRecursive(not_null target) { if (!target->testAttribute(Qt::WA_WState_Created)) { if (!target->isWindow()) { CreateWidgetStateRecursive(target->parentWidget()); + WidgetCreator::Create(target); + } else if (!cIsSnowLeopard()) { + WidgetCreator::Create(target); } - WidgetCreator::Create(target); } }