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. Upgraded Qt5.4.1 to 5.12.1, and now QCodec gives an exception
Forum Updated to NodeBB v4.3 + New Features

Upgraded Qt5.4.1 to 5.12.1, and now QCodec gives an exception

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 271 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.
  • J Offline
    J Offline
    Jeredriq
    wrote on last edited by Jeredriq
    #1

    I've "inherited" a project which was working fine but we upgraded it to work with visual studio 2015 and qt 5.12.1.

    But for some reason it gives an exception now. What it basically does is it checks a location in regedit (which is written from another application) and reads a string value (which records the users). The query it does is :

    CMD:

    wmic /node:127.0.0.1 /user: "User" /password:"Password" class stdregprov call GetStringValue hDefKey="&H80000007" sSubKeyName=Software\Company\ApplicationServer sValueName=USERS"
    

    When I run this from cmd it returns a result and gives the same result in application too.

    The return value is
    OUT:

    Executing (stdregprov)->GetStringValue()
    
    Method execution successful.
    
    Out Parameters:
    instance of __PARAMETERS
    {
      ReturnValue = 0;
      sValue = "127.0.0.1-test.user";
    }
    

    But when it tries the codec in the code below, it gives an Access Violation Exception. Note that cmd is the parameters we sent to cmd (as shown above) and out is the response (as its shown above too).

    void MyUtil::runProcess(QString& cmd, QString& out, QString& arr){
    
    QProcess process;
    process.start(cmd);
    proces.waitForFinished(osProcessTimeout*1000);
    
    if(cmd.contains("sValueName=USERS")){ //which is true for our problem
    QByteArray arr = process.readAllStandardOutput();
    QTextCodec *codec = QTextCodec::codecForName("857");
    out = codec->toUnicode(arr);   // ----> WHERE IT GIVES THE EXCEPTION
    
    }else{
    
    out = process.readAllStandardOutput();
    
    }
    
    err = process.readAllStandardError();
    
    }
    
    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jeredriq
      wrote on last edited by
      #2

      I used QTextCodec::codecForName("ISO-8859-9"); and it worked. Alternatively codecForLocale();

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

        Hi and welcome to devnet,

        You can check the codec available with QTextCodec::availableCodecs.

        Note that it's always a good idea to check the returned pointer when dealing with that kind of methods.

        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
        3

        • Login

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