[CLOSED]QTextCodecs causing application crash!! need help.



  • Hi all,
    I have a problem with my application crashing probably due to text encodings transformations but i can't figure it out.I want the application to run normally when before march 2014 and display an expiry message after the date in a QMessageBox.When i comment out the code in the else clause the program exits normally but it crashes whenever that code is executed.I suspect that it is related to text encoding transformations.Any help will be appreciated.
    .Here is the code and thanks for your time:
    @int main(int argc, char *argv[])
    {

    // Uncomment next section to have memory leaks information
    // tracing in VC++ debug mode under Windows
    

    /*
    #if defined(_MSC_VER) && defined(_DEBUG)
    _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
    #endif
    */

    Q_INIT_RESOURCE(sankore);
    
    qInstallMsgHandler(ub_message_output);
    

    #if defined(Q_WS_X11)
    qDebug() << "Setting GraphicsSystem to raster";
    QApplication::setGraphicsSystem("raster");
    #endif

    UBApplication app("Sankore", argc, argv&#41;;
    
    
    //WE RETRIEVE THE CURRENT DATE AND SET THE EXPIRY DATE FOR
    //THE APPLICATION.
    
    QDate currentDate=QDate::currentDate(&#41;;
    QDate expiryDate= QDate(2014,3,31);
    
    
    
    //BUGFIX:
    //when importing a sankore file that contains a non standard character
    //the codecForLocale or the codecForCString is used to convert the file path
    //into a const char*. This is why in french windows setup the codec name shouldn't be
    //set to UTF-8. For example, setting UTF-8, will convert "Haïti" into "HaÂ-ti.
    
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    //QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    
    QStringList args = app.arguments();
    
    QString dumpPath = UBSettings::userDataDirectory() + "/log";
    QDir logDir(dumpPath);
    if (!logDir.exists())
        logDir.mkdir(dumpPath);
    
    .......................................
    

    //---->>>THE CODE RELEVANT TO THE PROBLEM IS DOWN HERE<<<<<-----

    //int result = app.exec&#40;fileToOpen&#41;;
    int result;
    
    if(currentDate.operator <=(expiryDate&#41;&#41;
    {
       result = app.exec&#40;fileToOpen&#41;;
    }
    
    else
    {
     QMessageBox mMessageBox;
     mMessageBox.setText("Your version of the program has expired!"&#41;;
     mMessageBox.exec(&#41;;
    
    result = 0;
    }
    
    app.cleanup(&#41;;
    
    qDebug(&#41; << "application is quitting";
    
    
    
    return result;
    

    }@


  • Lifetime Qt Champion

    Hi,

    You need to give more information i.e os (seems to be windows), Qt version, compiler (seems to be VS but what version ?) etc...

    What does a run through the debugger tells you ?

    Also, this code is not even compilable so nobody can try it on its system.

    Removing all uncompilable pieces and using a QApplication, I don't have any problem with it on OS X.



  • Thans SGaist for the reply,

    I am using Qt 4.8.1 ,Qt Creator 2.4.1 and visual studio’s 2008 compiler.my system is windows 7 .I have been able to successfuly build the application and I just need to tweak the main function to add some behaviour to the program to meet our needs.I have been doing this to no avail so far."Here is the current state of the problem":http://qt-project.org/forums/viewthread/27700/
    and I consider this thread closed since it is no more relevant .Sorry for my poor understanding.


Log in to reply
 

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