Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error searching for files. Qt 5.4.0, MinGW x86, Windows 7 ×86
Qt 6.11 is out! See what's new in the release blog

Error searching for files. Qt 5.4.0, MinGW x86, Windows 7 ×86

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 3.8k Views 1 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    Are you calling your application from Qt Creator ? From Window's explorer ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexey-s
      wrote on last edited by
      #3

      Build release on QtCreator 2.8.1 (Qt 5.1.1 x64), MinGW 64, Windows 8.1 x64.
      @
      #include <QCoreApplication>
      #include <QStringList>
      #include <QDir>
      #include <QTextStream>

      int main(int argc, char argv[]) {
      QCoreApplication a(argc, argv);
      QStringList filters;
      QStringList masks(a.arguments());
      masks.removeAt(0);
      foreach(QString mask, masks)
      filters << mask; // "
      .dll" or "*.d *"

      QDir clientDir = QDir::current();
      clientDir.setNameFilters(filters);
      QStringList entryList = clientDir.entryList(QDir::Files, QDir::NoSort);
      QTextStream out(stdout);
      out << entryList.join (',') << endl;
      return 0;
      

      }
      @

      Run from command line (cmd, far manager)
      @

      dir
      25.10.2014 21:53 18 944 dir-files.exe
      30.08.2013 12:45 22 336 000 icudt51.dll
      30.08.2013 12:45 1 792 512 icuin51.dll
      30.08.2013 12:45 1 290 752 icuuc51.dll
      29.08.2013 10:44 75 264 libgcc_s_seh-1.dll
      30.08.2013 12:40 431 570 libpcre16-0.dll
      29.08.2013 10:44 957 440 libstdc++-6.dll
      30.08.2013 09:15 79 637 libwinpthread-1.dll
      06.10.2013 16:46 3 809 280 Qt5Core.dll

      dir-files.exe
      dir-files.exe,icudt51.dll,icuin51.dll,icuuc51.dll,libgcc_s_seh-1.dll,libpcre16-0.dll,libstdc++-6.dll,libwinpthread-1.dll,main.o,Qt5Core.dll
      dir-files.exe .dll
      !!! crash !!!
      dir-files.exe l
      .dll
      !!! crash !!!
      dir-files.exe Q*.dll
      Qt5Core.dll
      dir-files.exe i*.dll
      !!! crash !!!
      dir-files.exe .d
      !!! crash !!!
      @

      Managed to localize the error.
      Blame method call
      @
      QStringList QCoreApplication::arguments ()
      @

      Bug fixes. Replacement code
      @
      QStringList filters;
      for(int i = 1; i < argc; i++)
      filters << argv[i];
      @

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Can you show a backtrace when you make it crash ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alexey-s
          wrote on last edited by
          #5

          Run mingw 64 debug. Use Qt 5.1.1
          @

          C:\QtSDK\mingw64\bin\gdb.exe dir-files.exe *.dll
          (gdb) set args *.dll
          (gdb) run
          Starting program: C:\QtProjects\build-dir-files-Desktop-Release\test\dir-files.exe *.dll
          [New Thread 2580.0x680]
          ASSERT: "allArguments.size() == origArgc" in file kernel/qcoreapplication.cpp, line 2095

          This application has requested the Runtime to terminate it in an unusual way.
          Please contact the application's support team for more information.
          [Inferior 1 (process 2580) exited with code 03]
          (gdb)
          @

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Can you try with a more recent version of Qt ?

            It seems that that assert is not there anymore

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              alexey-s
              wrote on last edited by
              #7

              As you noticed, there is an error on versions 5.1.1 and 5.4.0.
              Today specially staged home with source Qt under Linux.

              Qt5.4.0/5.4/Src/qtbase/src/corelib/kernel/qcoreapplication.cpp
              @
              2187: const QStringList allArguments = qWinCmdArgs(cmdline);
              2188: Q_ASSERT(allArguments.size() == origArgc);
              @

              Later I will try to find out what the function "qWinCmdArgs" returns.
              More specifically, the work function "CommandLineToArgvW" from MSDN.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                alexey-s
                wrote on last edited by
                #8

                Nothing in this life I do not understand.
                @
                #include <QCoreApplication>
                #include <QStringList>
                #include <QDir>
                #include <QTextStream>
                #include <windows.h>

                // copy from Qt5.4.0/5.4/Src/qtbase/src/corelib/kernel/qcorecmdlineargs_p.h
                static inline QStringList qWinCmdArgs(const QString &cmdLine)
                {
                QStringList result;
                int size;
                if (wchar_t **argv = CommandLineToArgvW((const wchar_t *)cmdLine.utf16(), &size)) {
                result.reserve(size);
                wchar_t **argvEnd = argv + size;
                for (wchar_t **a = argv; a < argvEnd; ++a)
                result.append(QString::fromWCharArray(*a));
                LocalFree(argv);
                }
                return result;
                }

                int main(int argc, char *argv[]) {
                QCoreApplication a(argc, argv);
                QTextStream out(stdout);

                QString cmdLine = QString::fromWCharArray(GetCommandLine());
                QStringList params = qWinCmdArgs(cmdLine);
                out << params.join (',') << endl;
                out << QString("argc=%1, params.size=%2").arg(argc).arg(params.size()) << endl;
                
                for(int i = 0; i < argc; i++) {
                    out << QString("arg[%1]=\"%2\"").arg(i).arg(argv[i]) << endl;
                }
                
                QStringList masks(a.arguments());
                out << masks.join (',') << endl;
                return 0;
                

                }
                @
                return result
                @

                dir-files.exe .dll
                C:\QtProjects\build-dir-files-Desktop_Qt_5_4_MinGW_32bit-Debug\debug\dir-files.exe,
                .dll
                argc=8, params.size=2
                arg[0]="C:\QtProjects\build-dir-files-Desktop_Qt_5_4_MinGW_32bit-Debug\debug\dir-files.exe"
                arg[1]="icudt53.dll"
                arg[2]="icuin53.dll"
                arg[3]="icuuc53.dll"
                arg[4]="libgcc_s_dw2-1.dll"
                arg[5]="libstdc++-6.dll"
                arg[6]="libwinpthread-1.dll"
                arg[7]="Qt5Cored.dll"
                ASSERT: "allArguments.size() == origArgc" in file kernel\qcoreapplication.cpp, line 2188

                This application has requested the Runtime to terminate it in an unusual way.
                Please contact the application's support team for more information.
                @

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  alexey-s
                  wrote on last edited by
                  #9

                  Really, no one is repeated?
                  Run programs on different machines. Result stable - ASSERT.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Looks like it's something "known":https://bugreports.qt-project.org/browse/QTBUG-30330

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      alexey-s
                      wrote on last edited by
                      #11

                      I'm find solution
                      "Windows: where is the function _setargv() defined?":http://mingw-users.1079350.n2.nabble.com/Windows-where-is-the-function-setargv-defined-td7582536.html

                      add line before function main
                      @
                      int _CRT_glob = 0;
                      @

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt
                      • Unsolved