mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Scan-build cleanup
This commit is contained in:
parent
a37f169386
commit
c576a1485a
|
@ -167,13 +167,16 @@ void ChatLine::replaceContent(int col, ChatLineContent *lineContent)
|
|||
|
||||
void ChatLine::layout(qreal w, QPointF scenePos)
|
||||
{
|
||||
if (!content.size())
|
||||
return;
|
||||
|
||||
width = w;
|
||||
bbox.setTopLeft(scenePos);
|
||||
|
||||
qreal fixedWidth = (content.size()-1) * columnSpacing;
|
||||
qreal varWidth = 0.0; // used for normalisation
|
||||
|
||||
for (int i = 0; i < static_cast<int>(format.size()); ++i)
|
||||
for (size_t i = 0; i < format.size(); ++i)
|
||||
{
|
||||
if (format[i].policy == ColumnFormat::FixedSize)
|
||||
fixedWidth += format[i].size;
|
||||
|
@ -190,8 +193,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
|
|||
qreal xOffset = 0.0;
|
||||
qreal xPos[content.size()];
|
||||
|
||||
|
||||
for (int i = 0; i < static_cast<int>(content.size()); ++i)
|
||||
for (size_t i = 0; i < content.size(); ++i)
|
||||
{
|
||||
// calculate the effective width of the current column
|
||||
qreal width;
|
||||
|
@ -225,7 +227,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
|
|||
maxVOffset = qMax(maxVOffset, content[i]->getAscent());
|
||||
}
|
||||
|
||||
for (int i = 0; i < static_cast<int>(content.size()); ++i)
|
||||
for (size_t i = 0; i < content.size(); ++i)
|
||||
{
|
||||
// calculate vertical alignment
|
||||
// vertical alignment may depend on width, so we do it in a second pass
|
||||
|
|
|
@ -973,20 +973,20 @@ QList<QString> Core::getGroupPeerNames(int groupId) const
|
|||
{
|
||||
QList<QString> names;
|
||||
int nPeers = getGroupNumberPeers(groupId);
|
||||
if (nPeers == -1)
|
||||
if (nPeers < 0)
|
||||
{
|
||||
qWarning() << "getGroupPeerNames: Unable to get number of peers";
|
||||
return names;
|
||||
}
|
||||
uint8_t namesArray[nPeers][TOX_MAX_NAME_LENGTH];
|
||||
uint16_t* lengths = new uint16_t[nPeers];
|
||||
int result = tox_group_get_names(tox, groupId, namesArray, lengths, nPeers);
|
||||
std::unique_ptr<uint8_t[][TOX_MAX_NAME_LENGTH]> namesArray{new uint8_t[nPeers][TOX_MAX_NAME_LENGTH]};
|
||||
std::unique_ptr<uint16_t[]> lengths{new uint16_t[nPeers]};
|
||||
int result = tox_group_get_names(tox, groupId, namesArray.get(), lengths.get(), nPeers);
|
||||
if (result != nPeers)
|
||||
{
|
||||
qWarning() << "getGroupPeerNames: Unexpected result";
|
||||
return names;
|
||||
}
|
||||
for (int i=0; i<nPeers; i++)
|
||||
for (size_t i=0; i<nPeers; i++)
|
||||
names.push_back(CString::toString(namesArray[i], lengths[i]));
|
||||
|
||||
return names;
|
||||
|
|
|
@ -102,7 +102,7 @@ QByteArray Core::getSaltFromFile(QString filename)
|
|||
QByteArray data = file.read(TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
|
||||
file.close();
|
||||
|
||||
uint8_t *salt = new uint8_t[TOX_PASS_SALT_LENGTH];
|
||||
uint8_t salt[TOX_PASS_SALT_LENGTH];
|
||||
if (!tox_get_salt(reinterpret_cast<uint8_t *>(data.data()), salt))
|
||||
{
|
||||
qWarning() << "can't get salt from" << filename << "header";
|
||||
|
@ -110,7 +110,6 @@ QByteArray Core::getSaltFromFile(QString filename)
|
|||
}
|
||||
|
||||
QByteArray res(reinterpret_cast<const char*>(salt), TOX_PASS_SALT_LENGTH);
|
||||
delete[] salt;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,9 @@ QVector<VideoMode> v4l2::getDeviceModes(QString devName)
|
|||
case V4L2_FRMSIZE_TYPE_STEPWISE:
|
||||
mode.width = vfse.stepwise.max_width;
|
||||
mode.height = vfse.stepwise.max_height;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
QVector<unsigned short> rates = getDeviceModeFramerates(fd, mode.width, mode.height, vfd.pixelformat);
|
||||
for (unsigned short rate : rates)
|
||||
|
|
|
@ -99,8 +99,7 @@ void AboutUser::onRemoveHistoryClicked()
|
|||
History* history = Nexus::getProfile()->getHistory();
|
||||
if (history)
|
||||
history->removeFriendHistory(toxId.publicKey);
|
||||
QMessageBox::StandardButton reply;
|
||||
reply = QMessageBox::information(this,
|
||||
QMessageBox::information(this,
|
||||
tr("History removed"),
|
||||
tr("Chat history with %1 removed!").arg(ui->userName->text().toHtmlEscaped()),
|
||||
QMessageBox::Ok);
|
||||
|
|
|
@ -83,7 +83,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
|
|||
if (contentDialog == nullptr || notAlone)
|
||||
openChatWindow = menu.addAction(tr("Open chat in new window"));
|
||||
|
||||
if (contentDialog->hasGroupWidget(groupId, this))
|
||||
if (contentDialog && contentDialog->hasGroupWidget(groupId, this))
|
||||
removeChatWindow = menu.addAction(tr("Remove chat from this window"));
|
||||
|
||||
menu.addSeparator();
|
||||
|
|
|
@ -116,7 +116,7 @@ void NotificationScrollArea::resizeEvent(QResizeEvent *event)
|
|||
|
||||
void NotificationScrollArea::findNextWidget()
|
||||
{
|
||||
int value;
|
||||
int value = 0;
|
||||
GenericChatroomWidget* next = nullptr;
|
||||
QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin();
|
||||
|
||||
|
@ -151,7 +151,7 @@ void NotificationScrollArea::findNextWidget()
|
|||
|
||||
void NotificationScrollArea::findPreviousWidget()
|
||||
{
|
||||
int value;
|
||||
int value = 0;
|
||||
GenericChatroomWidget* next = nullptr;
|
||||
QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin();
|
||||
|
||||
|
|
|
@ -1486,7 +1486,6 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
|
|||
}
|
||||
else if (change == TOX_CHAT_CHANGE_PEER_NAME) // core overwrites old name before telling us it changed...
|
||||
{
|
||||
qDebug() << "UPDATING PEER";
|
||||
g->updatePeer(peernumber, name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user