From 0154be513868b21d95b474452e8ffff094a09f90 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 14 Feb 2016 22:46:01 +0300 Subject: [PATCH] fixed errors for 0.9.22 dev version --- Telegram/SourceFiles/audio.cpp | 8 ++++---- Telegram/SourceFiles/history.cpp | 2 +- Telegram/SourceFiles/historywidget.cpp | 2 +- Telegram/SourceFiles/mtproto/mtpConnection.cpp | 13 +++++++------ Telegram/SourceFiles/overviewwidget.cpp | 2 +- Telegram/SourceFiles/structs.cpp | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/audio.cpp b/Telegram/SourceFiles/audio.cpp index 7771eb39e..a074ad3f8 100644 --- a/Telegram/SourceFiles/audio.cpp +++ b/Telegram/SourceFiles/audio.cpp @@ -1867,10 +1867,10 @@ struct AudioCapturePrivate { , swrContext(0) , lastUpdate(0) , levelMax(0) + , dataPos(0) , waveformMod(0) , waveformEach(AudioVoiceMsgFrequency / 100) - , waveformPeak(0) - , dataPos(0) { + , waveformPeak(0) { } ALCdevice *device; AVOutputFormat *fmt; @@ -2548,7 +2548,7 @@ public: const char *data = buffer.data(); if (fmt == AL_FORMAT_MONO8 || fmt == AL_FORMAT_STEREO8) { - for (int32 i = 0, l = buffer.size(); i + sizeof(uchar) <= l;) { + for (int32 i = 0, l = buffer.size(); i + int32(sizeof(uchar)) <= l;) { uint16 sample = qAbs((int32(*(uchar*)(data + i)) - 128) * 256); if (peak < sample) { peak = sample; @@ -2563,7 +2563,7 @@ public: } } } else if (fmt == AL_FORMAT_MONO16 || fmt == AL_FORMAT_STEREO16) { - for (int32 i = 0, l = buffer.size(); i + sizeof(uint16) <= l;) { + for (int32 i = 0, l = buffer.size(); i + int32(sizeof(uint16)) <= l;) { uint16 sample = qAbs(int32(*(int16*)(data + i))); if (peak < sample) { peak = sample; diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 8d1ed775a..8c3844416 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -4069,7 +4069,7 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r uchar max_value = 0; int32 max_delta = st::msgWaveformMax - st::msgWaveformMin, bottom = st::msgFilePadding.top() + st::msgWaveformMax; p.setPen(Qt::NoPen); - for (uint32 i = 0, bar_x = 0, sum_i = 0; i < wf_size; ++i) { + for (int32 i = 0, bar_x = 0, sum_i = 0; i < wf_size; ++i) { uchar value = wf ? wf->at(i) : 0; if (sum_i + bar_count >= wf_size) { // draw bar sum_i = sum_i + bar_count - wf_size; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index ad23e890b..01a3cb2b6 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -866,7 +866,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { PhotoLink *lnkPhoto = dynamic_cast(_contextMenuLnk.data()); DocumentLink *lnkDocument = dynamic_cast(_contextMenuLnk.data()); bool lnkIsVideo = lnkDocument ? lnkDocument->document()->isVideo() : false; - bool lnkIsAudio = lnkDocument ? lnkDocument->document()->voice() : false; + bool lnkIsAudio = lnkDocument ? (lnkDocument->document()->voice() != 0) : false; if (lnkPhoto || lnkDocument) { if (isUponSelected > 0) { _menu->addAction(lang(lng_context_copy_selected), this, SLOT(copySelectedText()))->setEnabled(true); diff --git a/Telegram/SourceFiles/mtproto/mtpConnection.cpp b/Telegram/SourceFiles/mtproto/mtpConnection.cpp index dcde71a52..0ef1430e0 100644 --- a/Telegram/SourceFiles/mtproto/mtpConnection.cpp +++ b/Telegram/SourceFiles/mtproto/mtpConnection.cpp @@ -431,18 +431,19 @@ namespace { TCP_LOG(("TCP Error: bad packet header, packet: %1").arg(Logs::mb(packet, length).str())); return mtpBuffer(1, -500); } + const mtpPrime *packetdata = reinterpret_cast(packet + (length - len)); TCP_LOG(("TCP Info: packet received, size = %1").arg(size * sizeof(mtpPrime))); if (size == 1) { - if (packet[0] == -429) { + if (*packetdata == -429) { LOG(("Protocol Error: -429 flood code returned!")); } else { - LOG(("TCP Error: error packet received, code = %1").arg(packet[0])); + LOG(("TCP Error: error packet received, code = %1").arg(*packetdata)); } - return mtpBuffer(1, packet[0]); + return mtpBuffer(1, *packetdata); } mtpBuffer data(size); - memcpy(data.data(), packet + (length - len), size * sizeof(mtpPrime)); + memcpy(data.data(), packetdata, size * sizeof(mtpPrime)); return data; } @@ -729,7 +730,7 @@ void MTPautoConnection::tcpSend(mtpBuffer &buffer) { uint32 second1 = 0; do { memset_rand(nonce, sizeof(nonce)); - } while (*first == first1 || *first == first2 || *first == first3 || *first == first4 || *first == first5 || *second == second1 || nonce[0] == 0xef); + } while (*first == first1 || *first == first2 || *first == first3 || *first == first4 || *first == first5 || *second == second1 || *reinterpret_cast(nonce) == 0xef); sock.write(nonce, sizeof(nonce)); } ++packetNum; @@ -1029,7 +1030,7 @@ void MTPtcpConnection::sendData(mtpBuffer &buffer) { uint32 second1 = 0; do { memset_rand(nonce, sizeof(nonce)); - } while (*first == first1 || *first == first2 || *first == first3 || *first == first4 || *first == first5 || *second == second1 || nonce[0] == 0xef); + } while (*first == first1 || *first == first2 || *first == first3 || *first == first4 || *first == first5 || *second == second1 || *reinterpret_cast(nonce) == 0xef); sock.write(nonce, sizeof(nonce)); } ++packetNum; diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index dd9cf6dbe..919f770a2 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -1262,7 +1262,7 @@ void OverviewInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { _contextMenuLnk = textlnkOver(); PhotoLink *lnkPhoto = dynamic_cast(_contextMenuLnk.data()); DocumentLink *lnkDocument = dynamic_cast(_contextMenuLnk.data()); - bool lnkIsAudio = lnkDocument ? lnkDocument->document()->voice() : false; + bool lnkIsAudio = lnkDocument ? (lnkDocument->document()->voice() != 0) : false; bool lnkIsVideo = lnkDocument ? lnkDocument->document()->isVideo() : false; if (lnkPhoto || lnkDocument) { _menu = new PopupMenu(); diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index 6a9f25ed9..90757d14e 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -977,7 +977,7 @@ void DocumentCancelLink::onClick(Qt::MouseButton button) const { } VoiceData::~VoiceData() { - if (!waveform.isEmpty() && waveform.at(0) == -1 && waveform.size() > sizeof(TaskId)) { + if (!waveform.isEmpty() && waveform.at(0) == -1 && waveform.size() > int32(sizeof(TaskId))) { TaskId taskId = 0; memcpy(&taskId, waveform.constData() + 1, sizeof(taskId)); Local::cancelTask(taskId);