QFontDatabase causes Segfault [Solved]
-
You should run a debug build of your application, it will give more precise information.
-
@SGaist I'm already compiling with
QMAKE_CXXFLAGS += -std=c++14 -Wall -Wextra -pedantic -g -ggdb -rdynamic
, what exactly would you like me to do? -
Did you set these flags your self or use Qt Creator Run in debug mode ?
-
I set these flags myself, I never use Qt Creator for anything. I compile and run everything through the terminal with
qmake
andmake
There was also this line though:
QMutex: destroying locked mutex
but I'm not using any mutex. -
Try again with
CONFIG+=debug
. You currently build a debug version of your app running against a release build of Qt.You might not be using mutex directly but depending on what part of Qt you use, Qt is.
-
@SGaist I've added
CONFIG+=debug
in the .pro file but the outcome is the same.:S -
Do you have the Qt debug package for your distribution installed ?
-
@SGaist I've just installed
qtbase5-dbg
to make sure, but the result remains the same.Anyway, do we really need to get more information about what exactly is causing the segmentation fault in
QFontDatabase::QFontDatabase
? It seems that almost anything in<QFontDatabase>
causes a segmentation fault. Well, at leastQFontDatabase::QFontDatabase
andQFontDatabase::addApplicationFont
do. -
Wait, Valgrind seems to be more accurate than the stack trace for some reason.
==2786== at 0x672E3FA: initializeDb() (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.2.1) ==2786== by 0x672E460: QFontDatabase::QFontDatabase() (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.2.1)
I don't know how to get more info.
-
When are you using it in your application ?
-
int main(int argc, char *argv[]) { DS::Initialize(); \\ ... }
where
DS::Initialize
is a static function of the classDS
:void DS::Initialize(void) { struct sigaction act; sigemptyset(&act.sa_mask); act.sa_handler = ::Handler; act.sa_flags = 0; sigaction(SIGSEGV, &act, 0); QFontDatabase k; std::cout << "foo" << std::endl; auto s = QFontDatabase::addApplicationFont("construct/Type.ttf"); std::cout << "foo" << std::endl; \\ ... }
-
You're missing a QGuiApplication in order to use QFontDatabase
-
@SGaist So it was only a matter of order! It works now, thank you so much! How do I add <Solved> ?
-
You're welcome !
Just edit the thread title a prepend it or rather [solved] so that the forum can pick it up and modify the view accordingly :)