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



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

    In the catalog files are stored

    icudt53.dll,icuin53.dll,icuuc53.dll,libgcc_s_dw2-1.dll,libstdc++-6.dll,libwinpthread-1.dll,Qt5Core.dll
    @
    QStringList filters;
    filters << QString (".dll"); // Or ".d *"

    QDir clientDir = QDir::current();
    clientDir.setNameFilters(filters);
    QStringList entryList = serverDir.entryList(QDir::Filter::Files, QDir::SortFlag::NoSort);
    std::cout << entryList.join (',') << std::endl;
    @
    The system displays a window of a program crash.
    Under Linux x64 mistake is not repeated.

    The following example works correctly
    @
    QRegExp rx(QString("*.dll"), Qt::CaseSensitive, QRegExp::Wildcard);
    std::cout << rx.exactMatch("Qt5Core.dll") << std::endl; // return true and print 1
    @


  • Lifetime Qt Champion

    Hi and welcome to devnet,

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



  • 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];
    @


  • Lifetime Qt Champion

    Can you show a backtrace when you make it crash ?



  • 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)
    @


  • Lifetime Qt Champion

    Can you try with a more recent version of Qt ?

    It seems that that assert is not there anymore



  • 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.



  • 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.
    @



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


  • Lifetime Qt Champion

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



  • 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;
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.