about how to try to new application in code go on
-
What do you want to ask us?
-
I have qustion, than ,when I try use qt5.11.3,
step1:I new application A
step2:delete this aplication A
step3:new application B,
in step3, is fail I try to new application in second time segmentation fault
How I close this question
my core is
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication *a;
QApplication *b;
a = new QApplication(argc, argv);
delete a;
a = nullptr;
b = new QApplication(argc, argv);
delete b;
b = nullptr;
return 0;
} -
You must not create a second Q(Core)Application. It's nonsense.
-
-
Apart from the really strange idea on re-creating a Q(Core)Application for no reason your code works fine for me with Qt5.15. Use a debugger and see where exactly it crashes.
-
I try debug core, i see when I new qapplication ,i see it new two thread, one is for xdisplay , two is for qdbus,(i guess) when delete this qapplication , one thread is die, another one is still online ,
and then , try to if (qApp ==null) to judge application ,is already die, is true ,qapp,is null
and then ,i try to recreate application , segmentation fault, like this,
*- Thread 1 "123" received signal SIGSEGV, Segmentation fault.
0x0000fffff359ddec in deepin_platform_plugin::DHighDpi::logicalDpi(QXcbScreen*) ()
from /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libdxcb.so
(gdb) bt
#0 0x0000fffff359ddec in deepin_platform_plugin::DHighDpi::logicalDpi(QXcbScreen*) ()
at /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libdxcb.so
#1 0x0000fffff359d32c in deepin_platform_plugin::DHighDpi::pixelDensity(QXcbScreen*) ()
at /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libdxcb.so
#2 0x0000fffff751aecc in QHighDpiScaling::screenSubfactor(QPlatformScreen const*) () at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#3 0x0000fffff751b6ac in QHighDpiScaling::factor(QPlatformScreen const*) () at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#4 0x0000fffff74d00d8 in QPlatformScreen::deviceIndependentGeometry() const () at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#5 0x0000fffff750cd4c in () at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#6 0x0000fffff74cefd0 in QPlatformIntegration::screenAdded(QPlatformScreen*, bool) () at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#7 0x0000fffff34047a4 in QXcbConnection::initializeScreens() () at /lib/aarch64-linux-gnu/libQt5XcbQpa.so.5
#8 0x0000fffff3405164 in QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) ()
at /lib/aarch64-linux-gnu/libQt5XcbQpa.so.5
#9 0x0000fffff34093b8 in QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**) ()
at /lib/aarch64-linux-gnu/libQt5XcbQpa.so.5
#10 0x0000fffff3596974 in deepin_platform_plugin::DPlatformIntegration::DPlatformIntegration(QStringList const&, int&, char**) ()
at /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libdxcb.so
#11 0x0000fffff3595f4c in DPlatformIntegrationPlugin::create(QString const&, QStringList const&, int&, char**) ()
at /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libdxcb.so
#12 0x0000fffff74d125c in QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char**, QString const&) ()
at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#13 0x0000fffff74df7c8 in QGuiApplicationPrivate::createPlatformIntegration() () at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#14 0x0000fffff74e0658 in QGuiApplicationPrivate::createEventDispatcher() () at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#15 0x0000fffff707d6ec in QCoreApplicationPrivate::init() () at /lib/aarch64-linux-gnu/libQt5Core.so.5
#16 0x0000fffff74e1898 in QGuiApplicationPrivate::init() () at /lib/aarch64-linux-gnu/libQt5Gui.so.5
#17 0x0000fffff7ab554c in QApplicationPrivate::init() () at /lib/aarch64-linux-gnu/libQt5Widgets.so.5
#18 0x0000000000402ba4 in main(int, char**) (argc=1, argv=0xffffffffdc98) at ../123/main.cpp:10
(gdb)*
I think maybe i use error function to delete a qapplictaion.
- Thread 1 "123" received signal SIGSEGV, Segmentation fault.
-
@YouHok said in about how to try to new application in code go on:
I think maybe i use error function to delete a qapplictaion.
As I said - it's not really supported and not needed at all.
-
@Christian-Ehrlicher
so any solution you can suggest,in my business application,
whice i use so library package qt, in this way I only need to provide so and sdk for customer。
this so mayber ,Load or unload by customer,
how can i protect the one Q(core)Applicaction in this environment