Qtftp module bug under qt 5.6
-
Hi and welcome
I have not seen any reports on its not working. Its no longer maintained and
it might have issues that not been reported here.Searching the forum only showed posts about
build/installing it but not that it it almost worked but
some elements did not.When you say "path of the tree does not work properly."
what does that mean ? -
it means that under Qt 4.7.4 when I have a file tree like
B-> A-> C
B-> B-> D-> R
B-> X> Y
B-> Z
B-> E-> F-> G-> D
B-> E-> X, E-> Wthe search works correctly, that mean it accesses all the folders of the tree but under Qt 5.6 it accesses the elements of B which represents the root here and also B-> A but from there it goes in all directions by wanting for example to access B-> A-> G which does not exist so it bug
-
@magloire-touh Can you please show the code you are using to achive this?
-
class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
.........
........
public slots:
void handleListInfo(QUrlInfo info);
void getAllFilesFromFtp();
void handleCommandFinished( int id, bool error );private:
QFtp *ftp;
QList<QUrlInfo> ftpFilesList;
QQueue<QString> ftpFolders;
QString currentFtpFolder;
};MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ftp = new QFtp();
ftp->connectToHost("127.0.0.1");
connect(ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(handleListInfo(QUrlInfo)));
connect(ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(handleCommandFinished(int,bool)));
ftp->login("username","password");
getAllFilesFromFtpDir();
}void MainWindow::handleListInfo(QUrlInfo info){
if(info.isFile()){
qDebug() << currentFtpFolder+'/'+info.name();
ftpFilesList.push_back(info);
} else if(info.isDir()){
ftpFolders.enqueue(currentFtpFolder+"/"+info.name());
}
}void MainWindow::getAllFilesFromFtpDir(){
ftp->list();
}void MainWindow::handleCommandFinished( int id, bool error ){
if(ftp->currentCommand() == QFtp::List){
if(!ftpFolders.isEmpty()){
currentFtpFolder = ftpFolders.dequeue();
ftp->cd("/");
ftp->cd(currentFtpFolder);
ftp->list();
}else{
qDebug() << QString::number(ftpFilesList.count())+" éléments trouvés !";
}
}
} -
@magloire-touh said in Qtftp module bug under qt 5.6:
void MainWindow::handleCommandFinished( int id, bool error ){
I don't have experience with QFtp, but reading the docs I understand that QFtp is fully asynchronous. I.e. every command (including cd) is queued and executed in background, emitting a finished signal afterwards.
For further debugging, I recommend you to add a qDebug at the start of your finished handler:
void MainWindow::handleCommandFinished( int id, bool error ) { qDebug() << "handleCommandFinished(" << id << "," << error ")"; // ...
That way you can trace the execution and compare what happens under Qt 4.7 and Qt 5.6
-
QFtp became also deprecated towards the end of Qt4 main stream development.
AFAIK is the QtFtp module for Qt 5 only a recreation of the functionality as available through QFtp in Qt 4.
I have switched from Qt 4 to Qt 5 probably around Qt 5.1. I had downloaded QtFtp at that time and it contains follwoing note:
This repository contains deprecated APIs which have been removed from Qt
Applications are recommended to port to the supported APIs.
However as some features are lost, these APIs are provided as standalone
source code for applications that require removed features.Therefore, my interpretation this is merely some sort of courtesy module, but it is no longer part of Qt libraries. Also in the course of changes in Qt libs it was already expected that this may not continue to work all the time.
-
Hi
I think you have to debug the ftp code to find out what goes wrong.
From reading the code nothing sprang to eye.
Also as @aha_1980 suggest putting in lots of qDebug to help show
what exactly is going wrong.
But it sounds like
its ftp->cd and list() but
without running it, its hard to tell what issue is. -
@aha_1980 death of laughter. I followed your advice and traced all the execution and it is not the code of recovery the list of the files which does not work but it was rather the fact of called twice the method getAllFilesFromFtpDir () which has fucked up the mess. Thank you
-
Oh so it still works as it should ?
Good news :)