mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-03 11:00:14 -05:00
fixed crash when canceling DL from channel files list
This commit is contained in:
parent
9442d87644
commit
f6c584183b
@ -33,8 +33,8 @@
|
||||
|
||||
#include "retroshare/rsfiles.h"
|
||||
|
||||
GxsChannelFilesStatusWidget::GxsChannelFilesStatusWidget(const RsGxsFile &file, QWidget *parent) :
|
||||
QWidget(parent), mFile(file), ui(new Ui::GxsChannelFilesStatusWidget)
|
||||
GxsChannelFilesStatusWidget::GxsChannelFilesStatusWidget(const RsGxsFile &file, QWidget *parent,bool used_as_editor) :
|
||||
QWidget(parent), mFile(file), mUsedAsEditor(used_as_editor),ui(new Ui::GxsChannelFilesStatusWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -46,7 +46,7 @@ GxsChannelFilesStatusWidget::GxsChannelFilesStatusWidget(const RsGxsFile &file,
|
||||
connect(ui->downloadPushButton, SIGNAL(clicked()), this, SLOT(download()));
|
||||
connect(ui->resumeToolButton, SIGNAL(clicked()), this, SLOT(resume()));
|
||||
connect(ui->pauseToolButton, SIGNAL(clicked()), this, SLOT(pause()));
|
||||
connect(ui->cancelToolButton, SIGNAL(clicked()), this, SLOT(cancel()));
|
||||
connect(ui->cancelToolButton, SIGNAL(clicked()), this, SLOT(cancel()));
|
||||
connect(ui->openFilePushButton, SIGNAL(clicked()), this, SLOT(openFile()));
|
||||
|
||||
ui->downloadPushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/download.png"));
|
||||
@ -306,14 +306,15 @@ void GxsChannelFilesStatusWidget::resume()
|
||||
|
||||
void GxsChannelFilesStatusWidget::cancel()
|
||||
{
|
||||
if ((QMessageBox::question(this, "", tr("Are you sure that you want to cancel and delete the file?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) == QMessageBox::No) {
|
||||
return;
|
||||
}
|
||||
if(!mUsedAsEditor)
|
||||
if ((QMessageBox::question(this, "", tr("Are you sure that you want to cancel and delete the file?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) == QMessageBox::No) {
|
||||
return;
|
||||
}
|
||||
|
||||
rsFiles->FileCancel(mFile.mHash);
|
||||
|
||||
emit onButtonClick();// Signals the parent widget to e.g. update the downloadable file count
|
||||
check();
|
||||
check();
|
||||
}
|
||||
|
||||
void GxsChannelFilesStatusWidget::openFolder()
|
||||
@ -327,8 +328,12 @@ void GxsChannelFilesStatusWidget::openFolder()
|
||||
QDir dir = QFileInfo(QString::fromUtf8(fileInfo.path.c_str())).absoluteDir();
|
||||
if (dir.exists()) {
|
||||
if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(dir.absolutePath()))) {
|
||||
QMessageBox::warning(this, "", QString("%1 %2").arg(tr("Can't open folder"), dir.absolutePath()));
|
||||
}
|
||||
if(!mUsedAsEditor)
|
||||
QMessageBox::warning(this, "", QString("%1 %2").arg(tr("Can't open folder"), dir.absolutePath()));
|
||||
else
|
||||
RsErr() << "Can't open folder " << dir.absolutePath().toStdString() ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,8 +352,12 @@ void GxsChannelFilesStatusWidget::openFile()
|
||||
std::cerr << "GxsChannelFilesStatusWidget(): can't open file " << fileInfo.path << std::endl;
|
||||
}
|
||||
}else{
|
||||
QMessageBox::information(this, tr("Play File"),
|
||||
tr("File %1 does not exist at location.").arg(fileInfo.path.c_str()));
|
||||
return;
|
||||
if(!mUsedAsEditor)
|
||||
QMessageBox::information(this, tr("Play File"),
|
||||
tr("File %1 does not exist at location.").arg(fileInfo.path.c_str()));
|
||||
else
|
||||
RsErr() << "File " << fileInfo.path << " does not exist at location." ;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,10 @@ class GxsChannelFilesStatusWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GxsChannelFilesStatusWidget(const RsGxsFile &file, QWidget *parent = 0);
|
||||
explicit GxsChannelFilesStatusWidget(const RsGxsFile &file, QWidget *parent = 0,bool used_as_editor=false);
|
||||
~GxsChannelFilesStatusWidget();
|
||||
|
||||
bool usedAsEditor() const { return mUsedAsEditor; }
|
||||
signals:
|
||||
|
||||
void onButtonClick();
|
||||
@ -73,6 +74,8 @@ private:
|
||||
uint64_t mSize;
|
||||
uint64_t mDivisor;
|
||||
|
||||
bool mUsedAsEditor;
|
||||
|
||||
Ui::GxsChannelFilesStatusWidget *ui;
|
||||
};
|
||||
|
||||
|
@ -284,8 +284,10 @@ QWidget *ChannelPostFilesDelegate::createEditor(QWidget *parent, const QStyleOpt
|
||||
|
||||
if(index.column() == RsGxsChannelPostFilesModel::COLUMN_FILES_FILE)
|
||||
{
|
||||
GxsChannelFilesStatusWidget* w = new GxsChannelFilesStatusWidget(file,parent);
|
||||
connect(w,SIGNAL(onButtonClick()),this->parent(),SLOT(updateDAll_PB()));
|
||||
GxsChannelFilesStatusWidget* w = new GxsChannelFilesStatusWidget(file,parent,true);
|
||||
w->setFocusPolicy(Qt::StrongFocus);
|
||||
connect(w,SIGNAL(onButtonClick()),this->parent(),SLOT(updateDAll_PB()));
|
||||
|
||||
return w;
|
||||
}
|
||||
else
|
||||
|
@ -47,7 +47,7 @@ class ChannelPostFilesDelegate: public QStyledItemDelegate
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChannelPostFilesDelegate(QObject *parent=0) : QStyledItemDelegate(parent){}
|
||||
ChannelPostFilesDelegate(QObject *parent=0) : QStyledItemDelegate(parent){}
|
||||
virtual ~ChannelPostFilesDelegate(){}
|
||||
|
||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user