Browse Source

Merge pull request #4565 from glassez/fixes

Fix some bugs (reported by Coverity Scan)
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
d3c38da04d
  1. 3
      src/base/bittorrent/torrentcreatorthread.cpp
  2. 29
      src/base/logger.cpp
  3. 4
      src/base/logger.h
  4. 1
      src/base/net/smtp.cpp
  5. 6
      src/gui/rss/feedlistwidget.cpp
  6. 9
      src/gui/torrentcontentmodel.cpp
  7. 2
      src/gui/transferlistsortmodel.cpp
  8. 2
      src/webui/abstractwebapplication.cpp

3
src/base/bittorrent/torrentcreatorthread.cpp

@ -60,6 +60,9 @@ bool fileFilter(const std::string &f) @@ -60,6 +60,9 @@ bool fileFilter(const std::string &f)
TorrentCreatorThread::TorrentCreatorThread(QObject *parent)
: QThread(parent)
, m_private(false)
, m_pieceSize(0)
, m_abort(false)
{
}

29
src/base/logger.cpp

@ -2,31 +2,6 @@ @@ -2,31 +2,6 @@
#include <QDateTime>
namespace Log
{
Msg::Msg() {}
Msg::Msg(int id, MsgType type, const QString &message)
: id(id)
, timestamp(QDateTime::currentMSecsSinceEpoch())
, type(type)
, message(message)
{
}
Peer::Peer() {}
Peer::Peer(int id, const QString &ip, bool blocked, const QString &reason)
: id(id)
, timestamp(QDateTime::currentMSecsSinceEpoch())
, ip(ip)
, blocked(blocked)
, reason(reason)
{
}
}
Logger* Logger::m_instance = 0;
Logger::Logger()
@ -61,7 +36,7 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type) @@ -61,7 +36,7 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
{
QWriteLocker locker(&lock);
Log::Msg temp(msgCounter++, type, message);
Log::Msg temp = { msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message };
m_messages.push_back(temp);
if (m_messages.size() >= MAX_LOG_MESSAGES)
@ -74,7 +49,7 @@ void Logger::addPeer(const QString &ip, bool blocked, const QString &reason) @@ -74,7 +49,7 @@ void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)
{
QWriteLocker locker(&lock);
Log::Peer temp(peerCounter++, ip, blocked, reason);
Log::Peer temp = { peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip, blocked, reason };
m_peers.push_back(temp);
if (m_peers.size() >= MAX_LOG_MESSAGES)

4
src/base/logger.h

@ -20,8 +20,6 @@ namespace Log @@ -20,8 +20,6 @@ namespace Log
struct Msg
{
Msg();
Msg(int id, MsgType type, const QString &message);
int id;
qint64 timestamp;
MsgType type;
@ -30,8 +28,6 @@ namespace Log @@ -30,8 +28,6 @@ namespace Log
struct Peer
{
Peer(int id, const QString &ip, bool blocked, const QString &reason);
Peer();
int id;
qint64 timestamp;
QString ip;

1
src/base/net/smtp.cpp

@ -96,6 +96,7 @@ Smtp::Smtp(QObject *parent) @@ -96,6 +96,7 @@ Smtp::Smtp(QObject *parent)
: QObject(parent)
, m_state(Init)
, m_useSsl(false)
, m_authType(AuthPlain)
{
#ifndef QT_NO_OPENSSL
m_socket = new QSslSocket(this);

6
src/gui/rss/feedlistwidget.cpp

@ -34,7 +34,11 @@ @@ -34,7 +34,11 @@
#include "guiiconprovider.h"
#include "feedlistwidget.h"
FeedListWidget::FeedListWidget(QWidget *parent, const Rss::ManagerPtr& rssmanager): QTreeWidget(parent), m_rssManager(rssmanager) {
FeedListWidget::FeedListWidget(QWidget *parent, const Rss::ManagerPtr& rssmanager)
: QTreeWidget(parent)
, m_rssManager(rssmanager)
, m_currentFeed(nullptr)
{
setContextMenuPolicy(Qt::CustomContextMenu);
setDragDropMode(QAbstractItemView::InternalMove);
setSelectionMode(QAbstractItemView::ExtendedSelection);

9
src/gui/torrentcontentmodel.cpp

@ -167,9 +167,12 @@ TorrentContentModelItem::ItemType TorrentContentModel::itemType(const QModelInde @@ -167,9 +167,12 @@ TorrentContentModelItem::ItemType TorrentContentModel::itemType(const QModelInde
int TorrentContentModel::getFileIndex(const QModelIndex& index)
{
TorrentContentModelFile* item = dynamic_cast<TorrentContentModelFile*>(static_cast<TorrentContentModelItem*>(index.internalPointer()));
Q_ASSERT(item);
return item->fileIndex();
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
if (item->itemType() == TorrentContentModelItem::FileType)
return static_cast<TorrentContentModelFile*>(item)->fileIndex();
Q_ASSERT(item->itemType() == TorrentContentModelItem::FileType);
return -1;
}
QVariant TorrentContentModel::data(const QModelIndex& index, int role) const

2
src/gui/transferlistsortmodel.cpp

@ -191,7 +191,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex @@ -191,7 +191,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
bool TransferListSortModel::lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const
{
const TorrentModel *model = dynamic_cast<TorrentModel*>(sourceModel());
const TorrentModel *model = static_cast<TorrentModel*>(sourceModel());
// Sort according to TR_PRIORITY
const int queueL = model->data(model->index(left.row(), TorrentModel::TR_PRIORITY)).toInt();

2
src/webui/abstractwebapplication.cpp

@ -68,6 +68,7 @@ struct WebSession @@ -68,6 +68,7 @@ struct WebSession
WebSession(const QString& id)
: id(id)
{
updateTimestamp();
}
void updateTimestamp()
@ -349,7 +350,6 @@ bool AbstractWebApplication::sessionStart() @@ -349,7 +350,6 @@ bool AbstractWebApplication::sessionStart()
{
if (session_ == 0) {
session_ = new WebSession(generateSid());
session_->updateTimestamp();
sessions_[session_->id] = session_;
QNetworkCookie cookie(C_SID, session_->id.toUtf8());

Loading…
Cancel
Save