mirror of https://github.com/procxx/kepka.git
started signal handlers, shadow fixed in sticker-by-emoji, via @bot resize fixed
This commit is contained in:
parent
5531f49c3e
commit
71f588a4fe
|
@ -333,9 +333,8 @@ void updateRegistry() {
|
||||||
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdParamarg, int cmdShow) {
|
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdParamarg, int cmdShow) {
|
||||||
openLog();
|
openLog();
|
||||||
|
|
||||||
#ifdef _NEED_WIN_GENERATE_DUMP
|
|
||||||
_oldWndExceptionFilter = SetUnhandledExceptionFilter(_exceptionFilter);
|
_oldWndExceptionFilter = SetUnhandledExceptionFilter(_exceptionFilter);
|
||||||
#endif
|
// CAPIHook apiHook("kernel32.dll", "SetUnhandledExceptionFilter", (PROC)RedirectedSetUnhandledExceptionFilter);
|
||||||
|
|
||||||
writeLog(L"Updaters started..");
|
writeLog(L"Updaters started..");
|
||||||
|
|
||||||
|
@ -465,7 +464,6 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _NEED_WIN_GENERATE_DUMP
|
|
||||||
static const WCHAR *_programName = L"Telegram Desktop"; // folder in APPDATA, if current path is unavailable for writing
|
static const WCHAR *_programName = L"Telegram Desktop"; // folder in APPDATA, if current path is unavailable for writing
|
||||||
static const WCHAR *_exeName = L"Updater.exe";
|
static const WCHAR *_exeName = L"Updater.exe";
|
||||||
|
|
||||||
|
@ -564,4 +562,10 @@ LONG CALLBACK _exceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) {
|
||||||
return _oldWndExceptionFilter ? (*_oldWndExceptionFilter)(pExceptionPointers) : EXCEPTION_CONTINUE_SEARCH;
|
return _oldWndExceptionFilter ? (*_oldWndExceptionFilter)(pExceptionPointers) : EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
// see http://www.codeproject.com/Articles/154686/SetUnhandledExceptionFilter-and-the-C-C-Runtime-Li
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI RedirectedSetUnhandledExceptionFilter(_In_opt_ LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) {
|
||||||
|
// When the CRT calls SetUnhandledExceptionFilter with NULL parameter
|
||||||
|
// our handler will not get removed.
|
||||||
|
_oldWndExceptionFilter = lpTopLevelExceptionFilter;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -32,12 +32,9 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||||
using std::deque;
|
using std::deque;
|
||||||
using std::wstring;
|
using std::wstring;
|
||||||
|
|
||||||
#define _NEED_WIN_GENERATE_DUMP
|
|
||||||
|
|
||||||
#ifdef _NEED_WIN_GENERATE_DUMP
|
|
||||||
extern LPTOP_LEVEL_EXCEPTION_FILTER _oldWndExceptionFilter;
|
extern LPTOP_LEVEL_EXCEPTION_FILTER _oldWndExceptionFilter;
|
||||||
LONG CALLBACK _exceptionFilter(EXCEPTION_POINTERS* pExceptionPointers);
|
LONG CALLBACK _exceptionFilter(EXCEPTION_POINTERS* pExceptionPointers);
|
||||||
#endif _NEED_WIN_GENERATE_DUMP
|
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI RedirectedSetUnhandledExceptionFilter(_In_opt_ LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
||||||
|
|
||||||
static int updaterVersion = 1000;
|
static int updaterVersion = 1000;
|
||||||
static const WCHAR *updaterVersionStr = L"0.1.0";
|
static const WCHAR *updaterVersionStr = L"0.1.0";
|
||||||
|
|
|
@ -935,7 +935,7 @@ namespace App {
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkSavedGif(HistoryItem *item) {
|
void checkSavedGif(HistoryItem *item) {
|
||||||
if (!item->toHistoryForwarded() && item->out()) {
|
if (!item->toHistoryForwarded() && (item->out() || item->history()->peer == App::self())) {
|
||||||
if (HistoryMedia *media = item->getMedia()) {
|
if (HistoryMedia *media = item->getMedia()) {
|
||||||
if (DocumentData *doc = media->getDocument()) {
|
if (DocumentData *doc = media->getDocument()) {
|
||||||
if (doc->isGifv()) {
|
if (doc->isGifv()) {
|
||||||
|
|
|
@ -208,7 +208,7 @@ void Application::updateGotCurrent() {
|
||||||
if (!updateReply || updateThread) return;
|
if (!updateReply || updateThread) return;
|
||||||
|
|
||||||
cSetLastUpdateCheck(unixtime());
|
cSetLastUpdateCheck(unixtime());
|
||||||
QRegularExpressionMatch m = QRegularExpression(qsl("^\\s*(\\d+)\\s*:\\s*([\\x21-\\x7f]+)\\s*$")).match(QString::fromUtf8(updateReply->readAll()));
|
QRegularExpressionMatch m = QRegularExpression(qsl("^\\s*(\\d+)\\s*:\\s*([\\x21-\\x7f]+)\\s*$")).match(QString::fromLatin1(updateReply->readAll()));
|
||||||
if (m.hasMatch()) {
|
if (m.hasMatch()) {
|
||||||
uint64 currentVersion = m.captured(1).toULongLong();
|
uint64 currentVersion = m.captured(1).toULongLong();
|
||||||
QString url = m.captured(2);
|
QString url = m.captured(2);
|
||||||
|
@ -642,7 +642,7 @@ void Application::socketConnected() {
|
||||||
}
|
}
|
||||||
commands += qsl("CMD:show;");
|
commands += qsl("CMD:show;");
|
||||||
DEBUG_LOG(("Application Info: writing commands %1").arg(commands));
|
DEBUG_LOG(("Application Info: writing commands %1").arg(commands));
|
||||||
socket.write(commands.toLocal8Bit());
|
socket.write(commands.toLatin1());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::socketWritten(qint64/* bytes*/) {
|
void Application::socketWritten(qint64/* bytes*/) {
|
||||||
|
@ -799,13 +799,13 @@ void Application::readClients() {
|
||||||
for (ClientSockets::iterator i = clients.begin(), e = clients.end(); i != e; ++i) {
|
for (ClientSockets::iterator i = clients.begin(), e = clients.end(); i != e; ++i) {
|
||||||
i->second.append(i->first->readAll());
|
i->second.append(i->first->readAll());
|
||||||
if (i->second.size()) {
|
if (i->second.size()) {
|
||||||
QString cmds(QString::fromLocal8Bit(i->second));
|
QString cmds(QString::fromLatin1(i->second));
|
||||||
int32 from = 0, l = cmds.length();
|
int32 from = 0, l = cmds.length();
|
||||||
for (int32 to = cmds.indexOf(QChar(';'), from); to >= from; to = (from < l) ? cmds.indexOf(QChar(';'), from) : -1) {
|
for (int32 to = cmds.indexOf(QChar(';'), from); to >= from; to = (from < l) ? cmds.indexOf(QChar(';'), from) : -1) {
|
||||||
QStringRef cmd(&cmds, from, to - from);
|
QStringRef cmd(&cmds, from, to - from);
|
||||||
if (cmd.startsWith(qsl("CMD:"))) {
|
if (cmd.startsWith(qsl("CMD:"))) {
|
||||||
execExternal(cmds.mid(from + 4, to - from - 4));
|
execExternal(cmds.mid(from + 4, to - from - 4));
|
||||||
QByteArray response(qsl("RES:%1;").arg(QCoreApplication::applicationPid()).toUtf8());
|
QByteArray response(qsl("RES:%1;").arg(QCoreApplication::applicationPid()).toLatin1());
|
||||||
i->first->write(response.data(), response.size());
|
i->first->write(response.data(), response.size());
|
||||||
} else if (cmd.startsWith(qsl("SEND:"))) {
|
} else if (cmd.startsWith(qsl("SEND:"))) {
|
||||||
if (cSendPaths().isEmpty()) {
|
if (cSendPaths().isEmpty()) {
|
||||||
|
|
|
@ -3906,9 +3906,7 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
int32 from = qFloor(e->rect().top() / st::mentionHeight), to = qFloor(e->rect().bottom() / st::mentionHeight) + 1;
|
int32 from = qFloor(e->rect().top() / st::mentionHeight), to = qFloor(e->rect().bottom() / st::mentionHeight) + 1;
|
||||||
int32 last = _mrows->isEmpty() ? (_hrows->isEmpty() ? _brows->size() : _hrows->size()) : _mrows->size();
|
int32 last = _mrows->isEmpty() ? (_hrows->isEmpty() ? _brows->size() : _hrows->size()) : _mrows->size();
|
||||||
bool hasUsername = _parent->filter().indexOf('@') > 1;
|
bool hasUsername = _parent->filter().indexOf('@') > 1;
|
||||||
|
@ -4015,13 +4013,13 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p.fillRect(cWideMode() ? st::lineWidth : 0, _parent->innerTop(), width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b);
|
|
||||||
p.fillRect(cWideMode() ? st::lineWidth : 0, _parent->innerBottom() - st::lineWidth, width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b);
|
p.fillRect(cWideMode() ? st::lineWidth : 0, _parent->innerBottom() - st::lineWidth, width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b);
|
||||||
|
}
|
||||||
|
p.fillRect(cWideMode() ? st::lineWidth : 0, _parent->innerTop(), width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MentionsInner::resizeEvent(QResizeEvent *e) {
|
void MentionsInner::resizeEvent(QResizeEvent *e) {
|
||||||
_stickersPerRow = int32(width() - 2 * st::stickerPanPadding) / int32(st::stickerPanSize.width());
|
_stickersPerRow = qMax(1, int32(width() - 2 * st::stickerPanPadding) / int32(st::stickerPanSize.width()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MentionsInner::mouseMoveEvent(QMouseEvent *e) {
|
void MentionsInner::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
@ -4514,7 +4512,7 @@ void MentionsDropdown::setBoundings(QRect boundings) {
|
||||||
void MentionsDropdown::recount(bool resetScroll) {
|
void MentionsDropdown::recount(bool resetScroll) {
|
||||||
int32 h = 0, oldst = _scroll.scrollTop(), st = oldst, maxh = 4.5 * st::mentionHeight;
|
int32 h = 0, oldst = _scroll.scrollTop(), st = oldst, maxh = 4.5 * st::mentionHeight;
|
||||||
if (!_srows.isEmpty()) {
|
if (!_srows.isEmpty()) {
|
||||||
int32 stickersPerRow = int32(_boundings.width() - 2 * st::stickerPanPadding) / int32(st::stickerPanSize.width());
|
int32 stickersPerRow = qMax(1, int32(_boundings.width() - 2 * st::stickerPanPadding) / int32(st::stickerPanSize.width()));
|
||||||
int32 rows = rowscount(_srows.size(), stickersPerRow);
|
int32 rows = rowscount(_srows.size(), stickersPerRow);
|
||||||
h = st::stickerPanPadding + rows * st::stickerPanSize.height();
|
h = st::stickerPanPadding + rows * st::stickerPanSize.height();
|
||||||
} else if (!_mrows.isEmpty()) {
|
} else if (!_mrows.isEmpty()) {
|
||||||
|
|
|
@ -178,7 +178,7 @@ namespace Notify {
|
||||||
namespace Global {
|
namespace Global {
|
||||||
|
|
||||||
struct Data {
|
struct Data {
|
||||||
uint64 LaunchId;
|
uint64 LaunchId = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Data *_data = 0;
|
Data *_data = 0;
|
||||||
|
|
|
@ -2499,6 +2499,7 @@ MsgId History::msgIdForRead() const {
|
||||||
int32 History::geomResize(int32 newWidth, int32 *ytransform, const HistoryItem *resizedItem) {
|
int32 History::geomResize(int32 newWidth, int32 *ytransform, const HistoryItem *resizedItem) {
|
||||||
if (width != newWidth) resizedItem = 0; // recount all items
|
if (width != newWidth) resizedItem = 0; // recount all items
|
||||||
if (width != newWidth || resizedItem) {
|
if (width != newWidth || resizedItem) {
|
||||||
|
width = newWidth;
|
||||||
int32 y = 0;
|
int32 y = 0;
|
||||||
for (Blocks::iterator i = blocks.begin(), e = blocks.end(); i != e; ++i) {
|
for (Blocks::iterator i = blocks.begin(), e = blocks.end(); i != e; ++i) {
|
||||||
HistoryBlock *block = *i;
|
HistoryBlock *block = *i;
|
||||||
|
@ -2513,7 +2514,6 @@ int32 History::geomResize(int32 newWidth, int32 *ytransform, const HistoryItem *
|
||||||
ytransform = 0;
|
ytransform = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
width = newWidth;
|
|
||||||
height = y;
|
height = y;
|
||||||
}
|
}
|
||||||
return height;
|
return height;
|
||||||
|
|
|
@ -30,13 +30,6 @@ namespace {
|
||||||
|
|
||||||
QMutex debugLogMutex, mainLogMutex;
|
QMutex debugLogMutex, mainLogMutex;
|
||||||
|
|
||||||
class _StreamCreator {
|
|
||||||
public:
|
|
||||||
~_StreamCreator() {
|
|
||||||
logsClose();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
QString debugLogEntryStart() {
|
QString debugLogEntryStart() {
|
||||||
static uint32 logEntry = 0;
|
static uint32 logEntry = 0;
|
||||||
|
|
||||||
|
@ -179,9 +172,8 @@ void moveOldDataFiles(const QString &wasDir) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void logsInit() {
|
bool logsInit() {
|
||||||
static _StreamCreator streamCreator;
|
t_assert(mainLogStream == 0);
|
||||||
if (mainLogStream) return;
|
|
||||||
|
|
||||||
QFile beta(cExeDir() + qsl("TelegramBeta_data/tdata/beta"));
|
QFile beta(cExeDir() + qsl("TelegramBeta_data/tdata/beta"));
|
||||||
if (cBetaVersion()) {
|
if (cBetaVersion()) {
|
||||||
|
@ -283,6 +275,7 @@ void logsInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir().setCurrent(cWorkingDir());
|
QDir().setCurrent(cWorkingDir());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void logsInitDebug() {
|
void logsInitDebug() {
|
||||||
|
@ -398,7 +391,7 @@ void logsClose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString logVectorLong(const QVector<MTPlong> &ids) {
|
QString logVectorLong(const QVector<MTPlong> &ids) {
|
||||||
if (!ids.size()) return "[void list]";
|
if (!ids.size()) return "[]";
|
||||||
QString idsStr = QString("[%1").arg(ids.cbegin()->v);
|
QString idsStr = QString("[%1").arg(ids.cbegin()->v);
|
||||||
for (QVector<MTPlong>::const_iterator i = ids.cbegin() + 1, e = ids.cend(); i != e; ++i) {
|
for (QVector<MTPlong>::const_iterator i = ids.cbegin() + 1, e = ids.cend(); i != e; ++i) {
|
||||||
idsStr += QString(", %2").arg(i->v);
|
idsStr += QString(", %2").arg(i->v);
|
||||||
|
@ -407,7 +400,7 @@ QString logVectorLong(const QVector<MTPlong> &ids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString logVectorLong(const QVector<uint64> &ids) {
|
QString logVectorLong(const QVector<uint64> &ids) {
|
||||||
if (!ids.size()) return "[void list]";
|
if (!ids.size()) return "[]";
|
||||||
QString idsStr = QString("[%1").arg(*ids.cbegin());
|
QString idsStr = QString("[%1").arg(*ids.cbegin());
|
||||||
for (QVector<uint64>::const_iterator i = ids.cbegin() + 1, e = ids.cend(); i != e; ++i) {
|
for (QVector<uint64>::const_iterator i = ids.cbegin() + 1, e = ids.cend(); i != e; ++i) {
|
||||||
idsStr += QString(", %2").arg(*i);
|
idsStr += QString(", %2").arg(*i);
|
||||||
|
|
|
@ -92,6 +92,6 @@ inline void t_assert_fail(const char *message, const char *file, int32 line) {
|
||||||
#define t_assert_c(condition, comment) t_assert_full(condition, "\"" #condition "\" (" comment ")", __FILE__, __LINE__)
|
#define t_assert_c(condition, comment) t_assert_full(condition, "\"" #condition "\" (" comment ")", __FILE__, __LINE__)
|
||||||
#define t_assert(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
|
#define t_assert(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
|
||||||
|
|
||||||
void logsInit();
|
bool logsInit();
|
||||||
void logsInitDebug();
|
void logsInitDebug();
|
||||||
void logsClose();
|
void logsClose();
|
||||||
|
|
|
@ -25,11 +25,9 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||||
#include "localstorage.h"
|
#include "localstorage.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
#ifdef _NEED_WIN_GENERATE_DUMP
|
#ifdef Q_OS_WIN
|
||||||
_oldWndExceptionFilter = SetUnhandledExceptionFilter(_exceptionFilter);
|
_oldWndExceptionFilter = SetUnhandledExceptionFilter(_exceptionFilter);
|
||||||
#endif
|
// CAPIHook apiHook("kernel32.dll", "SetUnhandledExceptionFilter", (PROC)RedirectedSetUnhandledExceptionFilter);
|
||||||
#ifdef _NEED_LINUX_GENERATE_DUMP
|
|
||||||
//signal(SIGSEGV, _sigsegvHandler);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
settingsParseArgs(argc, argv);
|
settingsParseArgs(argc, argv);
|
||||||
|
@ -40,7 +38,11 @@ int main(int argc, char *argv[]) {
|
||||||
return psCleanup();
|
return psCleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logsInit();
|
if (!logsInit()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
installSignalHandlers();
|
||||||
|
|
||||||
Global::Initializer _init;
|
Global::Initializer _init;
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ int main(int argc, char *argv[]) {
|
||||||
if (cDebug()) {
|
if (cDebug()) {
|
||||||
LOG(("Application Info: Telegram started in debug mode"));
|
LOG(("Application Info: Telegram started in debug mode"));
|
||||||
for (int32 i = 0; i < argc; ++i) {
|
for (int32 i = 0; i < argc; ++i) {
|
||||||
LOG(("Argument: %1").arg(QString::fromLocal8Bit(argv[i])));
|
LOG(("Argument: %1").arg(fromUtf8Safe(argv[i])));
|
||||||
}
|
}
|
||||||
QStringList logs = psInitLogs();
|
QStringList logs = psInitLogs();
|
||||||
for (int32 i = 0, l = logs.size(); i < l; ++i) {
|
for (int32 i = 0, l = logs.size(); i < l; ++i) {
|
||||||
|
|
|
@ -1072,7 +1072,7 @@ QString psCurrentLanguage() {
|
||||||
namespace {
|
namespace {
|
||||||
QString _psHomeDir() {
|
QString _psHomeDir() {
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
return (pw && pw->pw_dir && strlen(pw->pw_dir)) ? (QString::fromLocal8Bit(pw->pw_dir) + '/') : QString();
|
return (pw && pw->pw_dir && strlen(pw->pw_dir)) ? (fromUtf8Safe(pw->pw_dir) + '/') : QString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1086,7 +1086,7 @@ QString psDownloadPath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString psCurrentExeDirectory(int argc, char *argv[]) {
|
QString psCurrentExeDirectory(int argc, char *argv[]) {
|
||||||
QString first = argc ? QString::fromLocal8Bit(argv[0]) : QString();
|
QString first = argc ? fromUtf8Safe(argv[0]) : QString();
|
||||||
if (!first.isEmpty()) {
|
if (!first.isEmpty()) {
|
||||||
QFileInfo info(first);
|
QFileInfo info(first);
|
||||||
if (info.isSymLink()) {
|
if (info.isSymLink()) {
|
||||||
|
@ -1100,7 +1100,7 @@ QString psCurrentExeDirectory(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString psCurrentExeName(int argc, char *argv[]) {
|
QString psCurrentExeName(int argc, char *argv[]) {
|
||||||
QString first = argc ? QString::fromLocal8Bit(argv[0]) : QString();
|
QString first = argc ? fromUtf8Safe(argv[0]) : QString();
|
||||||
if (!first.isEmpty()) {
|
if (!first.isEmpty()) {
|
||||||
QFileInfo info(first);
|
QFileInfo info(first);
|
||||||
if (info.isSymLink()) {
|
if (info.isSymLink()) {
|
||||||
|
|
|
@ -592,7 +592,7 @@ QString psDownloadPath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString psCurrentExeDirectory(int argc, char *argv[]) {
|
QString psCurrentExeDirectory(int argc, char *argv[]) {
|
||||||
QString first = argc ? QString::fromLocal8Bit(argv[0]) : QString();
|
QString first = argc ? fromUtf8Safe(argv[0]) : QString();
|
||||||
if (!first.isEmpty()) {
|
if (!first.isEmpty()) {
|
||||||
QFileInfo info(first);
|
QFileInfo info(first);
|
||||||
if (info.exists()) {
|
if (info.exists()) {
|
||||||
|
@ -603,7 +603,7 @@ QString psCurrentExeDirectory(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString psCurrentExeName(int argc, char *argv[]) {
|
QString psCurrentExeName(int argc, char *argv[]) {
|
||||||
QString first = argc ? QString::fromLocal8Bit(argv[0]) : QString();
|
QString first = argc ? fromUtf8Safe(argv[0]) : QString();
|
||||||
if (!first.isEmpty()) {
|
if (!first.isEmpty()) {
|
||||||
QFileInfo info(first);
|
QFileInfo info(first);
|
||||||
if (info.exists()) {
|
if (info.exists()) {
|
||||||
|
|
|
@ -2352,7 +2352,6 @@ void psUpdateOverlayed(TWidget *widget) {
|
||||||
if (!wv) widget->setAttribute(Qt::WA_WState_Visible, false);
|
if (!wv) widget->setAttribute(Qt::WA_WState_Visible, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _NEED_WIN_GENERATE_DUMP
|
|
||||||
static const WCHAR *_programName = AppName; // folder in APPDATA, if current path is unavailable for writing
|
static const WCHAR *_programName = AppName; // folder in APPDATA, if current path is unavailable for writing
|
||||||
static const WCHAR *_exeName = L"Telegram.exe";
|
static const WCHAR *_exeName = L"Telegram.exe";
|
||||||
|
|
||||||
|
@ -2457,7 +2456,14 @@ LONG CALLBACK _exceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) {
|
||||||
_generateDump(pExceptionPointers);
|
_generateDump(pExceptionPointers);
|
||||||
return _oldWndExceptionFilter ? (*_oldWndExceptionFilter)(pExceptionPointers) : EXCEPTION_CONTINUE_SEARCH;
|
return _oldWndExceptionFilter ? (*_oldWndExceptionFilter)(pExceptionPointers) : EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
// see http://www.codeproject.com/Articles/154686/SetUnhandledExceptionFilter-and-the-C-C-Runtime-Li
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI RedirectedSetUnhandledExceptionFilter(_In_opt_ LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) {
|
||||||
|
// When the CRT calls SetUnhandledExceptionFilter with NULL parameter
|
||||||
|
// our handler will not get removed.
|
||||||
|
_oldWndExceptionFilter = lpTopLevelExceptionFilter;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
class StringReferenceWrapper {
|
class StringReferenceWrapper {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -113,10 +113,9 @@ private:
|
||||||
void psDestroyIcons();
|
void psDestroyIcons();
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _NEED_WIN_GENERATE_DUMP
|
|
||||||
extern LPTOP_LEVEL_EXCEPTION_FILTER _oldWndExceptionFilter;
|
extern LPTOP_LEVEL_EXCEPTION_FILTER _oldWndExceptionFilter;
|
||||||
LONG CALLBACK _exceptionFilter(EXCEPTION_POINTERS* pExceptionPointers);
|
LONG CALLBACK _exceptionFilter(EXCEPTION_POINTERS* pExceptionPointers);
|
||||||
#endif
|
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI RedirectedSetUnhandledExceptionFilter(_In_opt_ LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
||||||
|
|
||||||
class PsApplication : public QApplication {
|
class PsApplication : public QApplication {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -199,7 +199,7 @@ void settingsParseArgs(int argc, char *argv[]) {
|
||||||
} else if (string("-many") == argv[i]) {
|
} else if (string("-many") == argv[i]) {
|
||||||
gManyInstance = true;
|
gManyInstance = true;
|
||||||
} else if (string("-key") == argv[i] && i + 1 < argc) {
|
} else if (string("-key") == argv[i] && i + 1 < argc) {
|
||||||
gKeyFile = QString::fromLocal8Bit(argv[++i]);
|
gKeyFile = fromUtf8Safe(argv[++i]);
|
||||||
} else if (string("-autostart") == argv[i]) {
|
} else if (string("-autostart") == argv[i]) {
|
||||||
gFromAutoStart = true;
|
gFromAutoStart = true;
|
||||||
} else if (string("-noupdate") == argv[i]) {
|
} else if (string("-noupdate") == argv[i]) {
|
||||||
|
@ -210,15 +210,15 @@ void settingsParseArgs(int argc, char *argv[]) {
|
||||||
gStartInTray = true;
|
gStartInTray = true;
|
||||||
} else if (string("-sendpath") == argv[i] && i + 1 < argc) {
|
} else if (string("-sendpath") == argv[i] && i + 1 < argc) {
|
||||||
for (++i; i < argc; ++i) {
|
for (++i; i < argc; ++i) {
|
||||||
gSendPaths.push_back(QString::fromLocal8Bit(argv[i]));
|
gSendPaths.push_back(fromUtf8Safe(argv[i]));
|
||||||
}
|
}
|
||||||
} else if (string("-workdir") == argv[i] && i + 1 < argc) {
|
} else if (string("-workdir") == argv[i] && i + 1 < argc) {
|
||||||
QString dir = QString::fromLocal8Bit(argv[++i]);
|
QString dir = fromUtf8Safe(argv[++i]);
|
||||||
if (QDir().exists(dir)) {
|
if (QDir().exists(dir)) {
|
||||||
gWorkingDir = dir;
|
gWorkingDir = dir;
|
||||||
}
|
}
|
||||||
} else if (string("--") == argv[i] && i + 1 < argc) {
|
} else if (string("--") == argv[i] && i + 1 < argc) {
|
||||||
gStartUrl = QString::fromLocal8Bit(argv[++i]);
|
gStartUrl = fromUtf8Safe(argv[++i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,6 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||||
#include <lzma.h>
|
#include <lzma.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
|
|
@ -22,6 +22,8 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
uint64 _SharedMemoryLocation[4] = { 0x00, 0x01, 0x02, 0x03 };
|
uint64 _SharedMemoryLocation[4] = { 0x00, 0x01, 0x02, 0x03 };
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -303,6 +305,47 @@ void deinitThirdParty() {
|
||||||
_sslLocks = 0;
|
_sslLocks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
FILE *_crashDump = 0;
|
||||||
|
int _crashDumpNo = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _signalHandler(int signum) {
|
||||||
|
const char* name = 0;
|
||||||
|
switch (signum) {
|
||||||
|
case SIGABRT: name = "SIGABRT"; break;
|
||||||
|
case SIGSEGV: name = "SIGSEGV"; break;
|
||||||
|
case SIGILL: name = "SIGILL"; break;
|
||||||
|
case SIGFPE: name = "SIGFPE"; break;
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
case SIGBUS: name = "SIGBUS"; break;
|
||||||
|
case SIGSYS: name = "SIGSYS"; break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
LOG(("Caught signal %1").arg(name));
|
||||||
|
if (name)
|
||||||
|
fprintf(stdout, "Caught signal %d (%s)\n", signum, name);
|
||||||
|
else
|
||||||
|
fprintf(stdout, "Caught signal %d\n", signum);
|
||||||
|
|
||||||
|
|
||||||
|
//printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
void installSignalHandlers() {
|
||||||
|
_crashDump = fopen((cWorkingDir() + qsl("tdata/working")).toUtf8().constData(), "wb");
|
||||||
|
if (_crashDump) _crashDumpNo = fileno(_crashDump);
|
||||||
|
|
||||||
|
signal(SIGABRT, _signalHandler);
|
||||||
|
signal(SIGSEGV, _signalHandler);
|
||||||
|
signal(SIGILL, _signalHandler);
|
||||||
|
signal(SIGFPE, _signalHandler);
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
signal(SIGBUS, _signalHandler);
|
||||||
|
signal(SIGSYS, _signalHandler);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool checkms() {
|
bool checkms() {
|
||||||
int64 unixms = (myunixtime() - _timeStart) * 1000LL + _msAddToUnixtime;
|
int64 unixms = (myunixtime() - _timeStart) * 1000LL + _msAddToUnixtime;
|
||||||
int64 ms = int64(getms(true));
|
int64 ms = int64(getms(true));
|
||||||
|
|
|
@ -133,6 +133,8 @@ inline void mylocaltime(struct tm * _Tm, const time_t * _Time) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void installSignalHandlers();
|
||||||
|
|
||||||
void initThirdParty(); // called by Global::Initializer
|
void initThirdParty(); // called by Global::Initializer
|
||||||
void deinitThirdParty();
|
void deinitThirdParty();
|
||||||
|
|
||||||
|
@ -233,6 +235,19 @@ private:
|
||||||
#define qsl(s) QStringLiteral(s)
|
#define qsl(s) QStringLiteral(s)
|
||||||
#define qstr(s) QLatin1String(s, sizeof(s) - 1)
|
#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));
|
||||||
|
QString result(QString::fromUtf8(str, size));
|
||||||
|
QByteArray back = result.toUtf8();
|
||||||
|
if (back.size() != size || memcmp(back.constData(), str, size)) return QString::fromLocal8Bit(str, size);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString fromUtf8Safe(const QByteArray &str) {
|
||||||
|
return fromUtf8Safe(str.constData(), str.size());
|
||||||
|
}
|
||||||
|
|
||||||
static const QRegularExpression::PatternOptions reMultiline(QRegularExpression::DotMatchesEverythingOption | QRegularExpression::MultilineOption);
|
static const QRegularExpression::PatternOptions reMultiline(QRegularExpression::DotMatchesEverythingOption | QRegularExpression::MultilineOption);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
Loading…
Reference in New Issue