Segmentation fault while open a text file
-
Hello,
i want to open a .htm file with this code:
QString fileName = QFileDialog::getOpenFileName(this, tr("Öffnen..."), QString(), tr("TextPad 1.0 (*.htm);;")); QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); if(fileName.isEmpty()) return; QFile file(fileName, this); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Fehler beim Öffnen der Datei"; } QProgressDialog progress("Öffnen - Fortschritt", "Abbrechen", 0, 10); progress.setWindowTitle("Öffnen"); progress.show(); for(int i = 0; i < 10; i++) { progress.setValue(i); if(progress.wasCanceled()) break; QTime saveTime = QTime::currentTime().addMSecs(40); while(QTime::currentTime() < saveTime) QCoreApplication::processEvents(QEventLoop::AllEvents, 100); } progress.setValue(1); if (document()) { document()->clear(); } document()->setHtml(file.readAll()); file.close();But i will get this error:
shell\comdlg32\fileopensave.cpp(14382)\COMDLG32.DLL!7465AABC: (caller: 7468B0FD) ReturnHr(1) tid(da8) 80004005 Unspecified error CallContext:[\PickerModalLoop]Anybody an idea how to fix that?
@HenrikSt. One more note: why do you pass this to QFile()?
-
@JohanSolo I debug that
@SGaist What do you mean? How can I fix that? The thing is, it worked before I changed the kits from mscv2015 to msgw32 bit... -
I googled this error message and somehow told that this error has nothing to do with Qt. It's a general Windows Problem, so that the error comes too while open a file into Notepad. Is it right?
-
@JohanSolo I debug that
@SGaist What do you mean? How can I fix that? The thing is, it worked before I changed the kits from mscv2015 to msgw32 bit...@HenrikSt. What @SGaist means is:
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Fehler beim Öffnen der Datei"; }If you cannot open the file you just continue and try to read its content later. Shouldn't you add a return there?
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Fehler beim Öffnen der Datei"; return; }Also: why do you set a parent in your QFile?
-
@JohanSolo I debug that
@SGaist What do you mean? How can I fix that? The thing is, it worked before I changed the kits from mscv2015 to msgw32 bit...@HenrikSt. said in Segmentation fault while open a text file:
changed the kits from mscv2015 to msgw32 bit
Did you rerun qmake and did a rebuild after changing the kit?
-
Hello,
i want to open a .htm file with this code:
QString fileName = QFileDialog::getOpenFileName(this, tr("Öffnen..."), QString(), tr("TextPad 1.0 (*.htm);;")); QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); if(fileName.isEmpty()) return; QFile file(fileName, this); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Fehler beim Öffnen der Datei"; } QProgressDialog progress("Öffnen - Fortschritt", "Abbrechen", 0, 10); progress.setWindowTitle("Öffnen"); progress.show(); for(int i = 0; i < 10; i++) { progress.setValue(i); if(progress.wasCanceled()) break; QTime saveTime = QTime::currentTime().addMSecs(40); while(QTime::currentTime() < saveTime) QCoreApplication::processEvents(QEventLoop::AllEvents, 100); } progress.setValue(1); if (document()) { document()->clear(); } document()->setHtml(file.readAll()); file.close();But i will get this error:
shell\comdlg32\fileopensave.cpp(14382)\COMDLG32.DLL!7465AABC: (caller: 7468B0FD) ReturnHr(1) tid(da8) 80004005 Unspecified error CallContext:[\PickerModalLoop]Anybody an idea how to fix that?
@HenrikSt. said in Segmentation fault while open a text file:
shell\comdlg32\fileopensave.cpp(14382)\COMDLG32.DLL!7465AABC: (caller: 7468B0FD) ReturnHr(1) tid(da8) 80004005 Unspecified error
CallContext:[\PickerModalLoop]To add to the already given suggestions, this error doesn't seem to have anything to do with the actual opening of the file, but rather with the
QFileDialog::getOpenFileName. Try with an alien dialog and see how that fares. -
I googled this error message and somehow told that this error has nothing to do with Qt. It's a general Windows Problem, so that the error comes too while open a file into Notepad. Is it right?
@HenrikSt. This line does not have any effect, why do you have it?
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); -
I will get this error. And i removed the line @jsulm .
Here's a picture:
https://1drv.ms/i/s!AqaeHLtTIsoIhOofMu8aGwHVDcerHA -
I have tested the example "Application" which is installed with Qt.
There is the same errer while open a file, so it has nothing to do with my code!
How can i fix that? I reinstalled Qt but the error is still there...
-
I have tested the example "Application" which is installed with Qt.
There is the same errer while open a file, so it has nothing to do with my code!
How can i fix that? I reinstalled Qt but the error is still there...
-
What version of Qt do you have installed? 5.7
From where did you install? C: Standard path
What OS? Windows 10 insider slow ring
What tool chain are you using? I don't know actually -
What version of Qt do you have installed? 5.7
From where did you install? C: Standard path
What OS? Windows 10 insider slow ring
What tool chain are you using? I don't know actually@HenrikSt.
@HenrikSt. said in Segmentation fault while open a text file:
From where did you install? C: Standard path
I meant from standard online installer or from some obscure place?
Or even a self-compiled version?Tools is the compiler tool chain.
Is it MinGW or a MSVS version? -
Online installer from qt.io
MinGw
-
Online installer from qt.io
MinGw
-
No, it is only crashing when I want to open a file into QTextEdit. I use the Application Example from Qt and my own written Application. Both crashes when I want to load a file :/
Yes, I am using Qt Creater IDE
Other applications are running well...
-
No, it is only crashing when I want to open a file into QTextEdit. I use the Application Example from Qt and my own written Application. Both crashes when I want to load a file :/
Yes, I am using Qt Creater IDE
Other applications are running well...
-
-
Any idea why it crashes while opening a file?
-
@HenrikSt.
I have just loaded the project file C:\Qt\Examples\Qt-5.7\widgets\mainwindows\application\application.pro
as it is already on my machine. Compiled with MinGW and linked with Qt 5.7.1, all standard as from installation through online installer.
I have a win 10 64 bit running.I did a compilation as debug and release. Both I can start from inside of creator with run command.
-
Any idea why it crashes while opening a file?
@HenrikSt. said in Segmentation fault while open a text file:
Any idea why it crashes while opening a file?
The release if I have simply opened one of the make files and it did not crash. It was loaded into application.
Is something wrong with the file you are trying to load?
You are starting the application directly from Qt creator?