From 00c9d16925762b3ce2d0967ca7725beafd500a4d Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 25 Sep 2015 18:03:57 +0300 Subject: [PATCH] linux crash on diacritics enter should be fixed --- Telegram/SourceFiles/gui/contextmenu.cpp | 5 +++++ Telegram/SourceFiles/main.cpp | 3 +++ Telegram/SourceFiles/pspecific_linux.cpp | 15 +++++++++++++++ Telegram/SourceFiles/pspecific_linux.h | 6 ++++++ Telegram/SourceFiles/pspecific_wnd.h | 2 +- Telegram/SourceFiles/stdafx.h | 2 ++ Telegram/SourceFiles/window.cpp | 9 ++++++++- 7 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/gui/contextmenu.cpp b/Telegram/SourceFiles/gui/contextmenu.cpp index 964c4b1b4..07eb5279a 100644 --- a/Telegram/SourceFiles/gui/contextmenu.cpp +++ b/Telegram/SourceFiles/gui/contextmenu.cpp @@ -269,4 +269,9 @@ void ContextMenu::popup(const QPoint &p) { ContextMenu::~ContextMenu() { clearActions(); +#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64 + if (App::wnd()) { + App::wnd()->activateWindow(); + } +#endif } diff --git a/Telegram/SourceFiles/main.cpp b/Telegram/SourceFiles/main.cpp index 99c7e7787..7ac4e739f 100644 --- a/Telegram/SourceFiles/main.cpp +++ b/Telegram/SourceFiles/main.cpp @@ -25,6 +25,9 @@ int main(int argc, char *argv[]) { #ifdef _NEED_WIN_GENERATE_DUMP _oldWndExceptionFilter = SetUnhandledExceptionFilter(_exceptionFilter); #endif +#ifdef _NEED_LINUX_GENERATE_DUMP + //signal(SIGSEGV, _sigsegvHandler); +#endif InitOpenSSL _init; diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index cf0ff373c..68f613bdd 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -1365,3 +1365,18 @@ bool linuxMoveFile(const char *from, const char *to) { return true; } + +#ifdef _NEED_LINUX_GENERATE_DUMP +void _sigsegvHandler(int sig) { + void *array[50] = {0}; + size_t size; + + // get void*'s for all entries on the stack + size = backtrace(array, 50); + + // print out all the frames to stderr + fprintf(stderr, "Error: signal %d:\n", sig); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} +#endif diff --git a/Telegram/SourceFiles/pspecific_linux.h b/Telegram/SourceFiles/pspecific_linux.h index 3c2c2bd8d..52e071102 100644 --- a/Telegram/SourceFiles/pspecific_linux.h +++ b/Telegram/SourceFiles/pspecific_linux.h @@ -17,6 +17,9 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org */ #pragma once +#include +#include + inline QString psServerPrefix() { return qsl("/tmp/"); } @@ -110,6 +113,9 @@ private: uint64 _psLastIndicatorUpdate; }; +#ifdef _NEED_LINUX_GENERATE_DUMP +void _sigsegvHandler(int sig); +#endif class PsApplication : public QApplication { Q_OBJECT diff --git a/Telegram/SourceFiles/pspecific_wnd.h b/Telegram/SourceFiles/pspecific_wnd.h index 3cb01cd2c..98ee2cc40 100644 --- a/Telegram/SourceFiles/pspecific_wnd.h +++ b/Telegram/SourceFiles/pspecific_wnd.h @@ -113,7 +113,7 @@ private: #ifdef _NEED_WIN_GENERATE_DUMP extern LPTOP_LEVEL_EXCEPTION_FILTER _oldWndExceptionFilter; LONG CALLBACK _exceptionFilter(EXCEPTION_POINTERS* pExceptionPointers); -#endif _NEED_WIN_GENERATE_DUMP +#endif class PsApplication : public QApplication { Q_OBJECT diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 6a17ea088..e4e137875 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -44,6 +44,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org #if defined Q_OS_WIN #define _NEED_WIN_GENERATE_DUMP +#elif defined Q_OS_LINUX32 || defined Q_OS_LINUX64 +#define _NEED_LINUX_GENERATE_DUMP #endif #include "types.h" diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 3ef20b7f6..91f7737aa 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -852,7 +852,14 @@ void Window::layerHidden() { } void Window::hideMediaview() { - if (_mediaView && !_mediaView->isHidden()) _mediaView->hide(); + if (_mediaView && !_mediaView->isHidden()) { + _mediaView->hide(); +#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64 + if (App::wnd()) { + App::wnd()->activateWindow(); + } +#endif + } } void Window::setInnerFocus() {