From b3f11e7dffe40e4d4a7a4a5129f0c57dab2d9745 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 16 Mar 2016 00:13:32 +0300 Subject: [PATCH] crash in pinnedbar fix, assertion info added to crash report, onViewsIncrement() and updateCounter() checks added, returned style fake qt args for Xubuntu 15.10, 0.9.33 stable (Linux only) --- Telegram/SourceFiles/config.h | 4 ++-- Telegram/SourceFiles/historywidget.cpp | 17 +++++++++-------- Telegram/SourceFiles/historywidget.h | 1 + Telegram/SourceFiles/logs.cpp | 4 ++++ Telegram/SourceFiles/logs.h | 1 + Telegram/SourceFiles/main.cpp | 17 ++++++++++++----- Telegram/SourceFiles/mainwidget.cpp | 2 ++ Telegram/SourceFiles/types.h | 10 ++++++---- Telegram/SourceFiles/window.cpp | 2 ++ Telegram/Version | 6 +++--- 10 files changed, 42 insertions(+), 22 deletions(-) diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index d8b4814f5b..fd7b7f1f03 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -20,8 +20,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -static const int32 AppVersion = 9032; -static const wchar_t *AppVersionStr = L"0.9.32"; +static const int32 AppVersion = 9033; +static const wchar_t *AppVersionStr = L"0.9.33"; static const bool DevVersion = false; //#define BETA_VERSION (9030002ULL) // just comment this line to build public version diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 07dc36bc75..1b4f4c4ed9 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -3606,9 +3606,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re _migrated->unreadBar->destroy(); } if (_pinnedBar) { - delete _pinnedBar; - _pinnedBar = nullptr; - _inPinnedMsg = false; + destroyPinnedBar(); } _history = _migrated = 0; updateBotKeyboard(); @@ -6842,9 +6840,7 @@ void HistoryWidget::updatePinnedBar(bool force) { if (_peer && _peer->isMegagroup()) { _peer->asChannel()->mgInfo->pinnedMsgId = 0; } - delete _pinnedBar; - _pinnedBar = nullptr; - _inPinnedMsg = false; + destroyPinnedBar(); resizeEvent(0); update(); } @@ -6892,8 +6888,7 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() { App::api()->requestMessageData(_peer->asChannel(), _pinnedBar->msgId, new ReplyEditMessageDataCallback()); } } else if (_pinnedBar) { - delete _pinnedBar; - _pinnedBar = nullptr; + destroyPinnedBar(); result = true; _scroll.scrollToY(_scroll.scrollTop() - st::replyHeight); resizeEvent(0); @@ -6901,6 +6896,12 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() { return result; } +void HistoryWidget::destroyPinnedBar() { + delete _pinnedBar; + _pinnedBar = nullptr; + _inPinnedMsg = false; +} + void HistoryWidget::ReplyEditMessageDataCallback::call(ChannelData *channel, MsgId msgId) const { if (App::main()) { App::main()->messageDataReceived(channel, msgId); diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 917eb73018..1ee9fc014b 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -736,6 +736,7 @@ private: PinnedBar *_pinnedBar; void updatePinnedBar(bool force = false); bool pinnedMsgVisibilityUpdated(); + void destroyPinnedBar(); void unpinDone(const MTPUpdates &updates); class ReplyEditMessageDataCallback : public SharedCallback2 { diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp index 4cc7edd41f..5a1e5d5200 100644 --- a/Telegram/SourceFiles/logs.cpp +++ b/Telegram/SourceFiles/logs.cpp @@ -1021,4 +1021,8 @@ namespace SignalHandlers { } } + void setAssertionInfo(const QString &info) { + ProcessAnnotations["Assertion"] = info.toUtf8().constData(); + } + } diff --git a/Telegram/SourceFiles/logs.h b/Telegram/SourceFiles/logs.h index 1599ee408a..6e997e4cf7 100644 --- a/Telegram/SourceFiles/logs.h +++ b/Telegram/SourceFiles/logs.h @@ -108,5 +108,6 @@ namespace SignalHandlers { void finish(); void setSelfUsername(const QString &username); + void setAssertionInfo(const QString &info); } diff --git a/Telegram/SourceFiles/main.cpp b/Telegram/SourceFiles/main.cpp index 571ef6f72a..b79c0f7adb 100644 --- a/Telegram/SourceFiles/main.cpp +++ b/Telegram/SourceFiles/main.cpp @@ -38,14 +38,21 @@ int main(int argc, char *argv[]) { Logs::start(); // must be started before PlatformSpecific is started PlatformSpecific::start(); // must be started before QApplication is created - //QByteArray args[] = { "-style=0" }; // prepare fake args to disable QT_STYLE_OVERRIDE env variable - //static const int a_cnt = sizeof(args) / sizeof(args[0]); - //int a_argc = a_cnt + 1; - //char *a_argv[a_cnt + 1] = { argv[0], args[0].data() }; + // prepare fake args to disable QT_STYLE_OVERRIDE env variable + // currently this is required in some desktop environments, including Xubuntu 15.10 + // when we don't default style to "none" Qt dynamically loads GTK somehow internally and + // our own GTK dynamic load and usage leads GTK errors and freeze of the current main thread + // we can't disable our own GTK loading because it is required by libappindicator, which + // provides the tray icon for this system, because Qt tray icon is broken there + // see https://github.com/telegramdesktop/tdesktop/issues/1774 + QByteArray args[] = { "-style=0" }; + static const int a_cnt = sizeof(args) / sizeof(args[0]); + int a_argc = a_cnt + 1; + char *a_argv[a_cnt + 1] = { argv[0], args[0].data() }; int result = 0; { - Application app(argc, argv); + Application app(a_argc, a_argv); result = app.exec(); } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 6b51634d3b..1687823598 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2166,6 +2166,8 @@ void MainWidget::scheduleViewIncrement(HistoryItem *item) { } void MainWidget::onViewsIncrement() { + if (!App::main() || !MTP::authedId()) return; + for (ViewsIncrement::iterator i = _viewsToIncrement.begin(); i != _viewsToIncrement.cend();) { if (_viewsIncrementRequests.contains(i.key())) { ++i; diff --git a/Telegram/SourceFiles/types.h b/Telegram/SourceFiles/types.h index ed7f9deff1..9adbd6b08a 100644 --- a/Telegram/SourceFiles/types.h +++ b/Telegram/SourceFiles/types.h @@ -46,6 +46,9 @@ public: }; +#define qsl(s) QStringLiteral(s) +#define qstr(s) QLatin1String(s, sizeof(s) - 1) + // using for_const instead of plain range-based for loop to ensure usage of const_iterator // it is important for the copy-on-write Qt containers // if you have "QVector v" then "for (T * const p : v)" will still call QVector::detach(), @@ -97,7 +100,9 @@ using std::swap; static volatile int *t_assert_nullptr = 0; inline void t_noop() {} inline void t_assert_fail(const char *message, const char *file, int32 line) { - LOG(("Assertion Failed! %1 %2:%3").arg(message).arg(file).arg(line)); + QString info(qsl("%1 %2:%3").arg(message).arg(file).arg(line)); + LOG(("Assertion Failed! %1 %2:%3").arg(info)); + SignalHandlers::setAssertionInfo(info); *t_assert_nullptr = 0; } #define t_assert_full(condition, message, file, line) ((!(condition)) ? t_assert_fail(message, file, line) : t_noop()) @@ -265,9 +270,6 @@ private: }; -#define qsl(s) QStringLiteral(s) -#define qstr(s) QLatin1String(s, sizeof(s) - 1) - inline QString fromUtf8Safe(const char *str, int32 size = -1) { if (!str || !size) return QString(); if (size < 0) size = int32(strlen(str)); diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 66a3a02a11..aef78db088 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -697,6 +697,8 @@ void Window::setupMain(bool anim, const MTPUser *self) { } void Window::updateCounter() { + if (App::quitting()) return; + psUpdateCounter(); title->updateCounter(); } diff --git a/Telegram/Version b/Telegram/Version index 1ad348a09f..f6b6466c7f 100644 --- a/Telegram/Version +++ b/Telegram/Version @@ -1,6 +1,6 @@ -AppVersion 9032 +AppVersion 9033 AppVersionStrMajor 0.9 -AppVersionStrSmall 0.9.32 -AppVersionStr 0.9.32 +AppVersionStrSmall 0.9.33 +AppVersionStr 0.9.33 DevChannel 0 BetaVersion 0 9030002