Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qtftp module bug under qt 5.6
QtWS25 Last Chance

Qtftp module bug under qt 5.6

Scheduled Pinned Locked Moved Solved General and Desktop
qt 5.6qtftplist
11 Posts 4 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    magloire touh
    wrote on 16 Dec 2017, 10:58 last edited by
    #1

    Hello everyone. Since I needed to recover all the files on an FTP server, I had to install the qtftp module in Qt 5.6 (which slowed me down because it was quite a puzzle).
    My code to recover all the files works correctly under Qt 4.7.4 but not under Qt 5.6.
    There is no special error except that the path of the tree does not work properly.
    Has anyone ever encountered this kind of problem?

    M 1 Reply Last reply 16 Dec 2017, 11:47
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 16 Dec 2017, 11:34 last edited by
      #2

      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 ?

      1 Reply Last reply
      1
      • M magloire touh
        16 Dec 2017, 10:58

        Hello everyone. Since I needed to recover all the files on an FTP server, I had to install the qtftp module in Qt 5.6 (which slowed me down because it was quite a puzzle).
        My code to recover all the files works correctly under Qt 4.7.4 but not under Qt 5.6.
        There is no special error except that the path of the tree does not work properly.
        Has anyone ever encountered this kind of problem?

        M Offline
        M Offline
        magloire touh
        wrote on 16 Dec 2017, 11:47 last edited by
        #3

        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-> W

        the 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

        A 1 Reply Last reply 16 Dec 2017, 11:48
        0
        • M magloire touh
          16 Dec 2017, 11:47

          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-> W

          the 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

          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 16 Dec 2017, 11:48 last edited by
          #4

          @magloire-touh Can you please show the code you are using to achive this?

          Qt has to stay free or it will die.

          M 1 Reply Last reply 16 Dec 2017, 12:01
          1
          • A aha_1980
            16 Dec 2017, 11:48

            @magloire-touh Can you please show the code you are using to achive this?

            M Offline
            M Offline
            magloire touh
            wrote on 16 Dec 2017, 12:01 last edited by
            #5

            class MainWindow : public QMainWindow
            {
            Q_OBJECT

            public:
            .........
            ........
            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 !";
            }
            }
            }

            A 1 Reply Last reply 16 Dec 2017, 14:02
            0
            • M magloire touh
              16 Dec 2017, 12:01

              class MainWindow : public QMainWindow
              {
              Q_OBJECT

              public:
              .........
              ........
              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 !";
              }
              }
              }

              A Offline
              A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on 16 Dec 2017, 14:02 last edited by
              #6

              @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

              Qt has to stay free or it will die.

              M 1 Reply Last reply 16 Dec 2017, 17:51
              3
              • K Offline
                K Offline
                koahnig
                wrote on 16 Dec 2017, 14:52 last edited by
                #7

                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.

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 16 Dec 2017, 15:15 last edited by
                  #8

                  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.

                  1 Reply Last reply
                  2
                  • A aha_1980
                    16 Dec 2017, 14:02

                    @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

                    M Offline
                    M Offline
                    magloire touh
                    wrote on 16 Dec 2017, 17:51 last edited by
                    #9

                    @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

                    1 Reply Last reply
                    2
                    • M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 16 Dec 2017, 18:08 last edited by
                      #10

                      Oh so it still works as it should ?
                      Good news :)

                      M 1 Reply Last reply 16 Dec 2017, 18:17
                      0
                      • M mrjj
                        16 Dec 2017, 18:08

                        Oh so it still works as it should ?
                        Good news :)

                        M Offline
                        M Offline
                        magloire touh
                        wrote on 16 Dec 2017, 18:17 last edited by
                        #11

                        @mrjj yes. Everything correct. Thanks for the help

                        1 Reply Last reply
                        1

                        7/11

                        16 Dec 2017, 14:52

                        • Login

                        • Login or register to search.
                        7 out of 11
                        • First post
                          7/11
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved