Solved but not explained: Qt5.5 webkitwidgets, missing DLL, unexpected crash - c++

I made a very simple and boring postal code -> city lookup program (it uses an online api).
I wanted to add functionality which allows to select any country (which the api can process). For this I wanted to load the main page and parse the DOM to get all the countries. This requires webkitwidgets. http://www.zippopotam.us/#where (this is the table I want to extract the information from)
Unfortunately, when attempting to run the program it never even starts and gives me the Application Output:
Starting ZipcodeToLocation.exe...
The program has unexpectedly finished.
ZipcodeToLocation.exe crashed
So I try running the debugger:
An exception was triggered:
Exception at 0x77cbd4f2, code: 0xc0000135: DLL not found, flags=0x0.
During startup program exited with code 0xc0000135.
Weird... so I try finding this error message on the internet and nothing really helps me. I think maybe I set something up wrong, so I open the webkitwidgets examples and compile those. When attempting to run - same error.
Using programs like some dependency walker didn't really help me much either.
I ran the MaintananceTool to check whether I was missing something, but I wasn't able to detect anything.
Im running QtCreator on Windows btw.
My .pro
QT += core gui webkitwidgets network
CONFIG += c++14
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ZipcodeToLocation
TEMPLATE = app
SOURCES += main.cpp\
MainWindow.cpp
HEADERS += MainWindow.hpp
FORMS += MainWindow.ui
If I remove the following portion from my main window ctor, everything runs es expected:
auto page = new QWebPage(this);
page->mainFrame()->load(QUrl("http://www.zippopotam.us"));
Note: this is currently the only section using webkitwidgets.
I would be really happy if someone could help me overcome this roadblock and has any suggestions on what might be going wrong.
Edit: Just to make it complete, a screenshot of the depends run: https://i.imgur.com/YWpdlO6.png?1
The german part translates to "The System can't find specified file".
Edit2: If you have QtCreator installed and want to attempt reproducing my error, create new QWidgets application, edit your .pro like so:
QT += core gui webkitwidgets
and this line at the end of MainWindow ctor (probably any usage of webkitwidgets would do):
#include <QWebKitWidgets>
//...
QWebPage *page = new QWebPage(this);
Edit3: As a reaction to a recent comment, I tried copying all dlls from the Qt directory to the .exe location (release) and tried running it from there. It said "Missing Qt5Positioning.dll". Which is weird, because I am not using the location module... But I guess that explains the missing dll crash?
Edit4:
I finally had enough and simply completely reinstalled Qt from scratch. Somehow my installation had to be messed up, because after that the problem vanished.

Related

Qt creator could not parse stddef.h --> incorrect code completion and highlighting

I am developing a QT GUI for my application using QT Creator (4.11.0).
Recently, our IT updated my OS to Ubuntu 20.04 (from 18.04) - maybe the error is related to that.
I have not touched to project in some month but yesterday wanted to continue developing it.
However, within the IDE there are now thousands of errors highlighted at almost every line of my code. (with highlighted I mean that there is this red background and a red dot beside the line number)
On the very top, it says:
Warning: The code model could not parse an included file, which might lead to incorrect code completion and highlighting, for example.
cstddef:50:10: fatal error: 'stddef.h' file not found
...
The errors that are listed in the IDE are very wired like:
type `QMainWindow`is not a direct or virtual base of `MainWindow` (my class is called `MainWindow`)
I'm pretty sure it is not related to my code:
the code compiles and works fine - it is really just the IDE that is highlighting errors at every line of my code.
I have the same code on a Windows Computer and there no errors are listed in the IDE.
even if I start a brand new QT Widget project the errors appear within the template code provided by the QT Creator.
Since the GCC version changed with the update of the OS, I thought maybe I have to define a new KIT but this also did not help.
Is there anything I can do to fix the issue?
Do I have to reinstall the QT Creator?
I know, pictures are not very well-liked but here I think it might help to understand what I mean with "IDE is highlighting errors":
1. First
~/.profile :
CPATH="/usr/include/clang/10/include:$CPATH"
C_INCLUDE_PATH="/usr/include/clang/10/include:$C_INCLUDE_PATH"
CPLUS_INCLUDE_PATH="/usr/include/clang/10/include:$CPLUS_INCLUDE_PATH"
export CPATH
export C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH
maybe /usr/include/clang/10/include see in you file system.
2. Second
Logout / login.
3. Third
Specifying Build Settings (Projects -> Build -> in every config build) in Build Environment section: [unset] CPATH, C_INCLUDE_PATH and CPLUS_INCLUDE_PATH
or [edit] replace this variable with the necessary values
I fixed this issue by sudo apt install clang-8.
Source: https://bugs.launchpad.net/ubuntu/+source/qtcreator/+bug/1890434

Qt Creator and MSVC - Ignoring specific exception types on debugging?

I'm currently using Qt Creator 4.4.1 with Qt 5.9.2 and the MSVC 2015 32/64 Bit compilers to create a DLL on Windows 7.
In Qt Creator under
Projects -> Build & Run -> Desktop Qt 5.9.2 MSVC2015 xxbit -> Run -> Executable
I've specified the host application, that loads my DLL, so when I hit F5 this app gets executed and loads my DLL without a flaw.
However, on loading, the main app raises an exception which I have no hands-on, making Qt Creator showing up a message box with the following content:
The inferior stopped because it triggered an exception.
Stopped in thread 0 by: Exception at 0x60251637, code 0xc0000005: write access violation at: 0x1, flags=0x0 (first chance).
I now have to close the message box and hit F5 again to proceed.
Because I have to do this for every test run, again and again, it becomes really annoying. So, is there a simplest way to tell CDB from Qt Creator to ignore only that specific type of exception?
Look at the call stack, find the relevant code and see what it does. You should find a try ... catch ... around that line. See whether you can avoid the exception in some way, typically by introducing an if ... else ....
If you cannot avoid it, and you made sure it's really safe to ignore it, start CDB with command line argument -c "sxn c0000005" or the equivalent -c "sxn av", where AV is short for "access violation". You can use sx to see all exception settings.
I encountered the same problem, the problem may be caused by the variable is not initialized, for example:
QLable *lable;
If you forget to allocate memory for this variable, it will cause this error.
lable = new QLable(this);
I think you should check your variables.

missing defaultconnection#qsqldatabase##2peadea

I'm working on a project that uses a sqlite database.
When I run project from the qt creator, everything works fine, but when I run exe file, application reports an error.
The procedure entry point defaultconnection#qsqldatabase##2peadea
could not be located in the dynamic link library.
Do you know where the problem is?
To get all needed libraries I run windeployqt.exe
I've added QT += core gui sql in my project.
In qt creator everything works without error.
In my program directory is:
.\D3Dcompiler_47.dll
.\libEGL.dll
.\libGLESV2.dll
.\myapp.deploy.cmd
.\myapp.exe
.\opengl32sw.dll
.\Qt5Core.dll
.\Qt5Gui.dll
.\Qt5Sql.dll
.\Qt5Svg.dll
.\Qt5Widgets.dll
.\iconengines\qsvgicon.dll
.\imageformats\qgif.dll
.\imageformats\qicns.dll
.\imageformats\qico.dll
.\imageformats\qjpeg.dll
.\imageformats\qsvg.dll
.\imageformats\qtga.dll
.\imageformats\qtiff.dll
.\imageformats\qwbmp.dll
.\imageformats\qwebp.dll
.\platforms\qwindows.dll
.\sqldrivers\qsqlite.dll
.\sqldrivers\qsqlmysql.dll
.\sqldrivers\qsqlodbc.dll
.\sqldrivers\qsqlpsql.dll
.\translations\qt_ca.qm
.\translations\qt_cs.qm
.\translations\qt_de.qm
.\translations\qt_en.qm
.\translations\qt_fi.qm
.\translations\qt_fr.qm
.\translations\qt_he.qm
.\translations\qt_hu.qm
.\translations\qt_it.qm
.\translations\qt_ja.qm
.\translations\qt_ko.qm
.\translations\qt_lv.qm
.\translations\qt_pl.qm
.\translations\qt_ru.qm
.\translations\qt_sk.qm
.\translations\qt_uk.qm

Qt deployed (macdeployqt) application does not create a file

I'm facing the following problem:
I wrote a simple application to track working hours. Therefor I create a *.db file programmatically.
Launching the application from Qt Creator (debug or release) works perfectly fine.
I used the macdeployqt tool to get a *.dmg file. When starting the application now the method (see below) cannot open, respectively create the *.db file and I run out of ideas why. In addition to this, the application should output some *.csv files. This also fails.
One more information, running the application as administrator using the sudo command on terminal...well it works and the *.db file and *.csv files get created.
So I am quite sure it must deal with file permissions but I have no idea how to change this except for changing it in the information context menu but this didn't help at all.
Below the method for the *.db file which always returns false when not launching the app from Qt Creator:
QFile file(Globals::Environment::WORKING_DIRECTORY + "/" + "Records.db");
if(file.open(QIODevice::ReadWrite))
return true;
else
{
QMessageBox msg;
msg.setWindowTitle("Error");
msg.setText("Failed to create database file!");
msg.exec();
}
return false;
I am on MacOS 10.11.3.
Qt 5.5.1 (Clang 6.1 (Apple), 64 bit)
If more information is needed, I will provide it of course.
Thanks a lot for every help in advance.

Qt Creator - Code is running but I get an error message from the IDE

As soon as I run my code (note that I'm using C only, no QT and no C++) I get the following message from the application output inside the IDE:
Cannot obtain a handle to the inferior: The parameter is incorrect.
When I delete the makefiles and debug/release folders it's running but after some time I still get the error. It's not that much of a problem though, the code runs and everything is fine but this error pops up and it's quite annoying.
The content of the .pro file is:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CC = gcc -std=c99
SOURCES += main.c
Thanks in advance!
edit: I have added C++ tag, because this error occurs also for C++ console application as in my case.
I have met same problem. Tips and advices on forums are rather clueless, so I investigated problem myself and I have found that it's a bug in QtCreator.
There is dirty little program called qtcreator_process_stub. Whenever you run your program within IDE, IDE first runs qtcreator_process_stub and passes your program name as parameter (among some other parameters). qtcreator_process_stub then starts your program as separate process and prints its PID (and on windows also thread id). Information is printed to the pipe and then it is read by ConsoleProcess::readStubOutput(), which is part of Utils.dll library used by QtCreator.
The problem occurs when "inferior" process (your application) finishes execution before whole communication has been processed. ConsoleProcess::readStubOutput() attempts to use OpenProcess() on non-existing process with closed handle. OpenProcess() fails hence error "Cannot obtain a handle to the inferior: The parameter is incorrect.". Whole error is not handled very gently (Uhm, and now what?)... :-/
Solution:
When you add some user input action, pause, sleep, delay or just some loops, so that execution of your application is a bit longer error vanishes. There is enough time for ConsoleProcess::readStubOutput() to execute OpenProcess(), before your application quits. So as a workaroud I suggest to do that until the bug is fixed.
I got the same error repeatedly while working on a C++ project in Qt. I was able to solve it by copying one of the shared libraries(.dll) I was using in to the build folder.
So, if you are using any shared external libraries that are needed at runtime, make sure they are in the builds folder.