fixed two crashes, fixed elided text display

This commit is contained in:
John Preston 2014-06-12 15:20:14 +04:00
parent 30a07de8e7
commit 8a2ac6573f
17 changed files with 77 additions and 50 deletions

View File

@ -102,16 +102,16 @@
<_ProjectFileVersion>11.0.60610.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)IntermediateMeta\</IntDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)Meta\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)IntermediateStyle\</IntDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)Style\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)Meta\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)IntermediateMeta\</IntDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)Style\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)IntermediateStyle\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)Meta\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)IntermediateMeta\</IntDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)Style\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)IntermediateStyle\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>

View File

@ -377,3 +377,5 @@ lng_about_text: "Unofficial free messaging app based on [a href=\"https://core.t
This software is licensed under [a href=\"https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE\"]GNU GPL[/a] version 3,
source code is available on [a href=\"https://github.com/telegramdesktop/tdesktop\"]GitHub[/a].";
lng_about_done: "Done";
// Keys finished

View File

@ -3,9 +3,9 @@
#define MyAppShortName "Telegram"
#define MyAppName "Telegram Win (Unofficial)"
#define MyAppVersion "0.5.1"
#define MyAppVersionZero "0.5.1"
#define MyAppFullVersion "0.5.1.0"
#define MyAppVersion "0.5.2"
#define MyAppVersionZero "0.5.2"
#define MyAppFullVersion "0.5.2.0"
#define MyAppPublisher "Telegram (Unofficial)"
#define MyAppURL "https://tdesktop.com"
#define MyAppExeName "Telegram.exe"

View File

@ -587,7 +587,7 @@ namespace App {
break;
case mtpc_contacts_myLinkEmpty:
case mtpc_contacts_myLinkRequested:
if (myLink.c_contacts_myLinkRequested().vcontact.v) {
if (myLink.type() == mtpc_contacts_myLinkRequested && myLink.c_contacts_myLinkRequested().vcontact.v) {
user->contact = 1;
} else {
switch (foreignLink.type()) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View File

@ -17,8 +17,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
*/
#pragma once
static const int32 AppVersion = 5001;
static const wchar_t *AppVersionStr = L"0.5.1";
static const int32 AppVersion = 5002;
static const wchar_t *AppVersionStr = L"0.5.2";
static const wchar_t *AppName = L"Telegram Win (Unofficial)";
static const wchar_t *AppId = L"{53F49750-6209-4FBF-9CA8-7A333C87D1ED}";

View File

@ -1063,8 +1063,11 @@ public:
continue;
}
bool elidedLine = _elideLast && (_y + _lineHeight >= _yTo);
if (f != j && !elidedLine) {
int32 elidedLineHeight = qMax(_lineHeight, blockHeight);
bool elidedLine = _elideLast && (_y + elidedLineHeight >= _yTo);
if (elidedLine) {
_lineHeight = elidedLineHeight;
} else if (f != j) {
j = f;
_wLeft = f_wLeft;
_lineHeight = f_lineHeight;
@ -1088,7 +1091,11 @@ public:
continue;
}
bool elidedLine = _elideLast && (_y + _lineHeight >= _yTo);
int32 elidedLineHeight = qMax(_lineHeight, blockHeight);
bool elidedLine = _elideLast && (_y + elidedLineHeight >= _yTo);
if (elidedLine) {
_lineHeight = elidedLineHeight;
}
if (!drawLine(elidedLine ? _blockEnd(_t, i, e) : b->from(), i, e)) return;
_y += _lineHeight;
_lineHeight = qMax(0, blockHeight);
@ -1542,7 +1549,7 @@ public:
void elideSaveBlock(int32 blockIndex, ITextBlock *&_endBlock, int32 elideStart, int32 elideWidth) {
_elideSavedIndex = blockIndex;
_elideSavedBlock = _t->_blocks[blockIndex];
const_cast<Text*>(_t)->_blocks[blockIndex] = new SkipBlock(_t->_font, _t->_text, elideStart, elideWidth, _f->height, _elideSavedBlock->lnkIndex());
const_cast<Text*>(_t)->_blocks[blockIndex] = new TextBlock(_t->_font, _t->_text, QFIXED_MAX, elideStart, 0, _elideSavedBlock->flags(), _elideSavedBlock->color(), _elideSavedBlock->lnkIndex());
_blocksSize = blockIndex + 1;
_endBlock = (blockIndex + 1 < _t->_blocks.size() ? _t->_blocks[blockIndex + 1] : 0);
}
@ -1654,9 +1661,11 @@ public:
lineLength += _Elide.size();
if (!repeat) {
for (; _t->_blocks[blockIndex] != _endBlock && _t->_blocks[blockIndex]->from() < elideStart; ++blockIndex) {
for (; blockIndex < _blocksSize && _t->_blocks[blockIndex] != _endBlock && _t->_blocks[blockIndex]->from() < elideStart; ++blockIndex) {
}
if (blockIndex < _blocksSize) {
elideSaveBlock(blockIndex, _endBlock, elideStart, elideWidth);
}
elideSaveBlock(blockIndex, _endBlock, elideStart, elideWidth);
}
}

View File

@ -441,6 +441,8 @@ namespace MTP {
}
void start() {
unixtimeInit();
if (!localKey().created()) {
LOG(("App Error: trying to start MTP without local key!"));
return;

View File

@ -79,24 +79,54 @@ namespace {
QReadWriteLock unixtimeLock;
volatile int32 unixtimeDelta = 0;
volatile bool unixtimeWasSet = false;
volatile uint64 msgIdStart, msgIdLocal = 0;
volatile uint64 _msgIdStart, _msgIdLocal = 0, _msgIdMsStart;
uint32 _reqId = 0;
void _initMsgIdConstants() {
#ifdef Q_OS_WIN
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
_msgIdMsStart = li.QuadPart;
#elif defined Q_OS_MAC
_msgIdMsStart = mach_absolute_time();
#else
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
_msgIdMsStart = 1000000000 * uint64(ts.tv_sec) + uint64(ts.tv_nsec);
#endif
uint32 msgIdRand;
memset_rand(&msgIdRand, sizeof(uint32));
_msgIdStart = (((uint64)((uint32)unixtime()) << 32) | (uint64)msgIdRand);
}
}
int32 myunixtime() {
return (int32)time(NULL);
}
void unixtimeSet(int32 serverTime, bool force) {
QWriteLocker locker(&unixtimeLock);
if (force) {
DEBUG_LOG(("MTP Info: forced setting client unixtime to %1").arg(serverTime));
} else {
if (unixtimeWasSet) return;
DEBUG_LOG(("MTP Info: setting client unixtime to %1").arg(serverTime));
void unixtimeInit() {
{
QWriteLocker locker(&unixtimeLock);
unixtimeWasSet = false;
unixtimeDelta = 0;
}
unixtimeWasSet = true;
unixtimeDelta = serverTime + 1 - myunixtime();
_initMsgIdConstants();
}
void unixtimeSet(int32 serverTime, bool force) {
{
QWriteLocker locker(&unixtimeLock);
if (force) {
DEBUG_LOG(("MTP Info: forced setting client unixtime to %1").arg(serverTime));
} else {
if (unixtimeWasSet) return;
DEBUG_LOG(("MTP Info: setting client unixtime to %1").arg(serverTime));
}
unixtimeWasSet = true;
unixtimeDelta = serverTime + 1 - myunixtime();
}
_initMsgIdConstants();
}
int32 unixtime() {
@ -164,23 +194,10 @@ namespace {
}
};
class _MsgIdInitializer {
public:
_MsgIdInitializer() {
uint32 msgIdRand;
memset_rand(&msgIdRand, sizeof(uint32));
msgIdStart = (((uint64)((uint32)time(NULL)) << 32) | (uint64)msgIdRand);
}
};
void _msInitialize() {
static _MsInitializer _msInitializer;
}
void _msgIdInitialize() {
static _MsgIdInitializer _msgIdInitializer;
}
class _MsStarter {
public:
_MsStarter() {
@ -212,16 +229,13 @@ uint64 getms() {
}
uint64 msgid() {
_msInitialize();
_msgIdInitialize();
#ifdef Q_OS_WIN
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
uint64 result = msgIdStart + (uint64)floor((li.QuadPart - _msStart) * _msgIdCoef);
uint64 result = _msgIdStart + (uint64)floor((li.QuadPart - _msgIdMsStart) * _msgIdCoef);
#elif defined Q_OS_MAC
uint64 msCount = mach_absolute_time();
uint64 result = msgIdStart + (uint64)floor((msCount - _msStart) * _msgIdCoef);
uint64 result = _msgIdStart + (uint64)floor((msCount - _msgIdMsStart) * _msgIdCoef);
#else
uint64 result = 0;
//TODO
@ -229,8 +243,7 @@ uint64 msgid() {
result &= ~0x03L;
QWriteLocker locker(&unixtimeLock);
return result + ((uint64)unixtimeDelta << 32) + (msgIdLocal += 4);
return result + (_msgIdLocal += 4);
}
uint32 reqid() {

View File

@ -70,6 +70,7 @@ private:
class MTPint;
int32 myunixtime();
void unixtimeInit();
void unixtimeSet(int32 servertime, bool force = false);
int32 unixtime();
int32 fromServerTime(const MTPint &serverTime);

Binary file not shown.

View File

@ -793,11 +793,11 @@
</CustomBuild>
<CustomBuild Include="Resources\style_classes.txt">
<Outputs>.\GeneratedFiles\style_classes.h</Outputs>
<Command>"$(SolutionDir)$(Platform)\$(Configuration)Meta\MetaStyle.exe" -classes_in ".\Resources\style_classes.txt" -classes_out ".\GeneratedFiles\style_classes.h" -styles_in ".\Resources\style.txt" -styles_out ".\GeneratedFiles\style_auto.h"</Command>
<Command>"$(SolutionDir)$(Platform)\$(Configuration)Style\MetaStyle.exe" -classes_in ".\Resources\style_classes.txt" -classes_out ".\GeneratedFiles\style_classes.h" -styles_in ".\Resources\style.txt" -styles_out ".\GeneratedFiles\style_auto.h"</Command>
</CustomBuild>
<CustomBuild Include="Resources\style.txt">
<Outputs>.\GeneratedFiles\style_auto.h</Outputs>
<Command>"$(SolutionDir)$(Platform)\$(Configuration)Meta\MetaStyle.exe" -classes_in ".\Resources\style_classes.txt" -classes_out ".\GeneratedFiles\style_classes.h" -styles_in ".\Resources\style.txt" -styles_out ".\GeneratedFiles\style_auto.h"</Command>
<Command>"$(SolutionDir)$(Platform)\$(Configuration)Style\MetaStyle.exe" -classes_in ".\Resources\style_classes.txt" -classes_out ".\GeneratedFiles\style_classes.h" -styles_in ".\Resources\style.txt" -styles_out ".\GeneratedFiles\style_auto.h"</Command>
</CustomBuild>
<CustomBuild Include="Resources\lang.txt">
<Outputs>.\GeneratedFiles\lang.h</Outputs>