简体   繁体   中英

"Unhandled exception at 0x000007FEFD5D7C8A (ole32.dll) in myprogram.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF"

I'm trying to use QfileDialog (as a static fct) for the user to select and read a ".txt" file, as follow:

void VisOCMConfig::readNmbTiles()
{
    QString  m_findFile;
    m_findFile = QFileDialog::getOpenFileName(0, tr("Open TextFile"),
                                              QDir::homePath(), tr("Text files (*.txt)"));

    QFile myfile(m_findFile);
    if (!myfile.open(QIODevice::ReadOnly | QIODevice::Text))
        return;
    else 
        while (!myfile.atEnd()) 
        {
            m_scanPos = myfile.readLine();
            m_nmbofLines++;
        }

    myfile.close();
    qDebug() << "Scan Positions: (" << m_scanPos.size() << "): " << m_scanPos;
    m_nmbofScan->setText(QString("#Tiles: %1").arg(m_nmbofLines));
}

Where m_scanPos is a QByteArray initialized in VisOCMConfig.h.

When I run the programm, It works correctly until a break occurs suddenly with the following message:

Unhandled exception at 0x000007FEFD5D7C8A (ole32.dll) in VisOCMConfig.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF

I read on other questions that it might be due to the use of null pointer but i'm still lost about it. Can you identify my mistake?

I've been having the same issue. Try using "DontUseNativeDialog" as a flag. I believe this solves the crash, but then you are left with a non-native dialog.

I have the same problem. Solution is also to use a non-native QFileDialog. Actually it only appears in Debug mode. In Release mode evething is fine.

The same code is working under QT4.8. Somehow it is not when using QT5.6.

Those who downvoted this question (I upvoted it) are more than welcome to downvote also this my answer.

I have the same problem with Qt 5.2.1 - same exception in ole32.dll after using QFileDialog::getOpenFileName() - not immediately but after 10 - 60 seconds. It happens if I continue with application AND ALSO if do nothing after opening file, just wait some time. Using "DontUseNativeDialog" as suggested by @aeson and @guest avoids this problem. I hope this information can help others.

@MartinBonner I think the tag should be changed back to QFileDialog because the problem is clearly related to it

I had the same error - my application crashed in debug mode.

If you examine the call stack when this issue occurs, you notice that the issue is related to the NetworkItemFactory.dll component.

A similar problem is described here: Unhandled exception in marshal.cxx under VS2013

Microsoft fixed this, so the solution is to apply Microsoft's hotfix Windows6.1-KB2718841

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM