Looks like the SIGNAL loadFinished(bool) is not emitted anymore with Qt 6.8.1
-
Thank you very much for your answer!
hmm.. Since I also used your code in my project and your name of the view was different, it should not be a shadowing problem.In fact in my source I have a lot of similar names in different dialogs. In the main dialog and also in a sub dialog:
mainwindow.h class MainWindow : public QMainWindow { … QWebEngineView *viewPreview; … } mainwindow.cpp void MainWindow::printTimetable() { TimetablePrintForm dialog(this); if (dialog.exec()) { } ... }
This mainwindow executes the timetableprintform:
timetableprintform.h class TimetablePrintForm: public Qdialog{ { … QWebEngineView *viewPreview; … }
I renamed QWebEngineView *viewPreview; in the timetableprintform to an other name. The bug is still present. So it is not a shadowing problem of the view. :-(
But while coding it, it reminds me on an 12 years old TODO. Maybe that is producing the shadowing problem? I sadly don't know if my comment it true and how to fix it:
main.cpp ... QApplication* app=NULL; QTranslator TTranslator; ... int main(int argc, char *argv[]){ ... QApplication app(argc, argv); //TODO: QApplication shadows the global Qapplication? app.setApplicationName(NAME); app.setApplicationVersion(VERSION); ... if(TSettings->language==""){ selectLanguage(NULL); } setLanguage(app, NULL); ... if(TSettings->languageRTL) app.setLayoutDirection(Qt::RightToLeft); ... MainWindow mainWin(check); mainWin.show(); return app.exec(); }
Any advice? Thank you very much.
-
@Volker75 said in Looks like the SIGNAL loadFinished(bool) is not emitted anymore with Qt 6.8.1:
QApplication app(argc, argv);
This is correct. QApplication instance is usually created in main() - there should not be any global instances of that class.
Did you address what @ChrisW67 wrote: "at line 58 of your code, the view pointer is invalid"? -
Thank you. I think I addressed that, since like I already wrote "I renamed QWebEngineView *viewPreview; in the timetableprintform to an other name. The bug is still present.". So the pointer got a new unique name. So there shouldn't be a shadowing.
Maybe I misunderstand you. Is there an other way to do? What should can I do? Just check if the pointer is !=NULL (But even if it is NULL, what should I do in that case?)? -
I coded now this:
if(viewPreview2==NULL){ qDebug("NULL"); } else { qDebug("Not NULL"); } viewPreview2->setHtml(updateHTMLprintString(true));
The last line is the problem.
Debug tells me "Not NULL" in the terminal.
Is there any thing else that I could check to locate the bug more detailed? -
Here are some things to try in your code:
TimetablePrintForm::TimetablePrintForm(QWidget *parent): QDialog(parent){ QVBoxLayout *layout = new QVBoxLayout(this); QWebEngineView *view = new QWebEngineView(this); qDebug() << "As constructed" << view; connect(view, &QWebEngineView::loadFinished, this, &TimetablePrintForm::loadFinished); layout->addWidget(view); QTimer::singleShot(0, [=](){ qDebug() << "In lambda 1" << view; view->setHtml("<html><head><title>Initial page</title></head><body><p>Initial content</p></body></html>"); } ); QTimer::singleShot(3000, [=](){ qDebug() << "In lambda 2" << view; view->setHtml("<html><head><title>Three seconds page</title></head><body><p>New content</p></body></html>"); } );
Do the three qDebugs print the same value?
What is the value ofview
in the slotTimetablePrintForm::loadFinished
?Replace QWebEngineView with a basic instrumented subclass (something like):
class MyWebEngineView: public QWebEngineView { Q_OBJECT public: explicit MyWebEngineView(QWidget *parent = nullptr) : QWebEngineView(parent) { qDebug() << "Constructing MyWebEngineView" << this; } ~MyWebEngineView() { qDebug() << "Destructing MyWebEngineView" << this; } };
Do you see constructions/destructions you were not expecting?
Matching pairs?When it crashes in your debugger, what is the complete backtrace?
-
Thank you very much! I am using Qt 6.8.1:
Terminal:15 As constructed QWebEngineView(0x5beb9e2e2120) In lambda 1 QWebEngineView(0x5beb9e2e2120) 15 Speicherzugriffsfehler (Speicherabzug geschrieben)
"Speicherzugriffsfehler" = segmentation fault
"15" that is a debug information from my mainwindow.cpp file; not from the timetableprintform.cpp file.Debuginfod has been enabled. To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit. Downloading separate debug info for system-supplied DSO at 0x7ffff7fc3000 Downloading separate debug info for /home/volker/Dokumente/TMP-to-publish/TiTiTo/libSimpleMail2Qt6.so.0 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6PrintSupport.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Widgets.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Gui.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Sql.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Network.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6QuickWidgets.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6WebChannel.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Positioning.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Quick.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6OpenGL.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6QmlMeta.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6QmlModels.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6QmlWorkerScript.so.6 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Qml.so.6 Downloading separate debug info for /lib/x86_64-linux-gnu/libglib-2.0.so.0 Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libglib-2.0.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libglib-2.0.so.0 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6DBus.so.6 Downloading separate debug info for /lib/x86_64-linux-gnu/libfreetype.so.6 Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libgthread-2.0.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libgthread-2.0.so.0 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libicui18n.so.73 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libicuuc.so.73 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/lib/libicudata.so.73 Downloading separate debug info for /lib/x86_64-linux-gnu/libsmime3.so Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libsmime3.so Downloading separate debug info for /lib/x86_64-linux-gnu/libsmime3.so Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libnss3.so Downloading separate debug info for /lib/x86_64-linux-gnu/libnss3.so Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libnssutil3.so Downloading separate debug info for /lib/x86_64-linux-gnu/libnssutil3.so Downloading separate debug info for /lib/x86_64-linux-gnu/libplds4.so Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libplds4.so Downloading separate debug info for /lib/x86_64-linux-gnu/libplds4.so Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libplc4.so Downloading separate debug info for /lib/x86_64-linux-gnu/libplc4.so Downloading separate debug info for /lib/x86_64-linux-gnu/libnspr4.so Downloading separate debug info for /lib/x86_64-linux-gnu/libXrandr.so.2 Downloading separate debug info for /lib/x86_64-linux-gnu/libexpat.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libdrm.so.2 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libXi.so.6 Downloading separate debug info for /lib/x86_64-linux-gnu/libasound.so.2 Downloading separate debug info for /lib/x86_64-linux-gnu/libgbm.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libpcre2-8.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libpng16.so.16 Downloading separate debug info for /lib/x86_64-linux-gnu/libwayland-server.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-randr.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libcap.so.2 Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libcap.so.2 Downloading separate debug info for /lib/x86_64-linux-gnu/libcap.so.2 Downloading separate debug info for /lib/x86_64-linux-gnu/libgcrypt.so.20 Downloading separate debug info for /lib/x86_64-linux-gnu/libbsd.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libgpg-error.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libmd.so.0 Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/platforms/libqxcb.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/platforms/../../lib/libQt6XcbQpa.so.6 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-shm.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-sync.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-xfixes.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-render.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-shape.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-xkb.so.1 [New Thread 0x7fffe58006c0 (LWP 19381)] [New Thread 0x7fffe4e006c0 (LWP 19382)] Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-glx.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libGLX_mesa.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libglapi.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-dri2.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-dri3.so.0 Downloading separate debug info for /lib/x86_64-linux-gnu/libxcb-present.so.0 Downloading separate debug info for /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so Downloading separate debug info for /lib/x86_64-linux-gnu/libLLVM-17.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libsensors.so.5 Downloading separate debug info for /lib/x86_64-linux-gnu/libdrm_radeon.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libelf.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libdrm_amdgpu.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libdrm_nouveau.so.2 Downloading separate debug info for /lib/x86_64-linux-gnu/libdrm_intel.so.1 Downloading separate debug info for /lib/x86_64-linux-gnu/libedit.so.2 Downloading separate debug info for /lib/x86_64-linux-gnu/libtinfo.so.6 Warnung: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libtinfo.so.6 Downloading separate debug info for /lib/x86_64-linux-gnu/libtinfo.so.6 Downloading separate debug info for /lib/x86_64-linux-gnu/libxml2.so.2 [New Thread 0x7fffddc006c0 (LWP 19383)] [New Thread 0x7fffdd2006c0 (LWP 19384)] [New Thread 0x7fffce8006c0 (LWP 19385)] [New Thread 0x7fffcde006c0 (LWP 19386)] [New Thread 0x7fffcd4006c0 (LWP 19387)] [New Thread 0x7fffcca006c0 (LWP 19388)] [New Thread 0x7fffc7e006c0 (LWP 19389)] [New Thread 0x7fffc74006c0 (LWP 19390)] [New Thread 0x7fffc6a006c0 (LWP 19391)] Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/iconengines/libqsvgicon.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/iconengines/../../lib/libQt6Svg.so.6 [New Thread 0x7fffc60006c0 (LWP 19392)] [New Thread 0x7fffc56006c0 (LWP 19393)] /home/volker/Dokumente/TMP-to-publish/TiTiTo/TiTiTo Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/sqldrivers/libqsqlite.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/imageformats/libqgif.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/imageformats/libqjpeg.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/imageformats/libqico.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/imageformats/libqsvg.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/tls/libqcertonlybackend.so Downloading separate debug info for /home/volker/Qt6.8/6.8.1/gcc_64/plugins/tls/libqopensslbackend.so [New Thread 0x7fffbbe006c0 (LWP 19397)] [New Thread 0x7fffbb4006c0 (LWP 19398)] [New Thread 0x7fffbaa006c0 (LWP 19399)] [Thread 0x7fffbaa006c0 (LWP 19399) exited] [Thread 0x7fffbb4006c0 (LWP 19398) exited] [Thread 0x7fffbbe006c0 (LWP 19397) exited] [New Thread 0x7fffbbe006c0 (LWP 19400)] [New Thread 0x7fffbb4006c0 (LWP 19401)] [New Thread 0x7fffbaa006c0 (LWP 19402)] [Thread 0x7fffbaa006c0 (LWP 19402) exited] [Thread 0x7fffbb4006c0 (LWP 19401) exited] [Thread 0x7fffbbe006c0 (LWP 19400) exited] [New Thread 0x7fffbbe006c0 (LWP 19403)] [Detaching after fork from child process 19404] [Detaching after fork from child process 19405] [Detaching after fork from child process 19406] [New Thread 0x7fffbb4006c0 (LWP 19407)] [New Thread 0x7fffbaa006c0 (LWP 19408)] [New Thread 0x7fffb8a006c0 (LWP 19409)] [New Thread 0x7fffafe006c0 (LWP 19410)] [New Thread 0x7fffaf4006c0 (LWP 19411)] [New Thread 0x7fffaea006c0 (LWP 19412)] [New Thread 0x7fffae0006c0 (LWP 19413)] [New Thread 0x7fffad6006c0 (LWP 19414)] [New Thread 0x7fffa3e006c0 (LWP 19423)] [New Thread 0x7fffacc006c0 (LWP 19422)] [New Thread 0x7fffa34006c0 (LWP 19424)] [New Thread 0x7fffa2a006c0 (LWP 19425)] [New Thread 0x7fffa20006c0 (LWP 19426)] [New Thread 0x7fffa0c006c0 (LWP 19428)] [New Thread 0x7fffa16006c0 (LWP 19427)] [New Thread 0x7fff97e006c0 (LWP 19429)] [New Thread 0x7fff974006c0 (LWP 19430)] [New Thread 0x7fff96a006c0 (LWP 19431)] [New Thread 0x7fff960006c0 (LWP 19432)] [New Thread 0x7fff956006c0 (LWP 19433)] [New Thread 0x7fff94c006c0 (LWP 19434)] [New Thread 0x7fff8be006c0 (LWP 19435)] [Thread 0x7fff8be006c0 (LWP 19435) exited] [Thread 0x7fff94c006c0 (LWP 19434) exited] [Thread 0x7fff956006c0 (LWP 19433) exited] [New Thread 0x7fff956006c0 (LWP 19436)] [New Thread 0x7fff94c006c0 (LWP 19437)] [New Thread 0x7fff8be006c0 (LWP 19438)] [Thread 0x7fff8be006c0 (LWP 19438) exited] [Thread 0x7fff94c006c0 (LWP 19437) exited] [Thread 0x7fff956006c0 (LWP 19436) exited] [New Thread 0x7fff956006c0 (LWP 19439)] [New Thread 0x7fff94c006c0 (LWP 19440)] [New Thread 0x7fff8be006c0 (LWP 19441)] 15 [New Thread 0x7fff8b4006c0 (LWP 19454)] [New Thread 0x7fff8aa006c0 (LWP 19455)] [New Thread 0x7fff8a0006c0 (LWP 19456)] [New Thread 0x7fff890006c0 (LWP 19457)] [New Thread 0x7fff7fe006c0 (LWP 19458)] [New Thread 0x7fff7f4006c0 (LWP 19459)] [New Thread 0x7fff7ea006c0 (LWP 19460)] As constructed QWebEngineView(0x5555569866f0) In lambda 1 QWebEngineView(0x5555569866f0) [New Thread 0x7fff7e0006c0 (LWP 19466)] [New Thread 0x7fff7d6006c0 (LWP 19467)] [New Thread 0x7fff7cc006c0 (LWP 19469)] [New Thread 0x7fff73e006c0 (LWP 19470)] [New Thread 0x7fff734006c0 (LWP 19471)] [Thread 0x7fff734006c0 (LWP 19471) exited] [Thread 0x7fff73e006c0 (LWP 19470) exited] [Thread 0x7fff7cc006c0 (LWP 19469) exited] [New Thread 0x7fff7cc006c0 (LWP 19472)] [New Thread 0x7fff73e006c0 (LWP 19473)] [New Thread 0x7fff734006c0 (LWP 19474)] [New Thread 0x7fff72a006c0 (LWP 19480)] [New Thread 0x7fff720006c0 (LWP 19481)] [New Thread 0x7fff716006c0 (LWP 19482)] [Thread 0x7fff716006c0 (LWP 19482) exited] [Thread 0x7fff720006c0 (LWP 19481) exited] [Thread 0x7fff72a006c0 (LWP 19480) exited] 15 [Thread 0x7fff734006c0 (LWP 19474) exited] [Thread 0x7fff73e006c0 (LWP 19473) exited] [Thread 0x7fff7cc006c0 (LWP 19472) exited] Thread 1 "Test" received signal SIGSEGV, Segmentation fault. 0x0000555556c0ace0 in ?? () (gdb) bt #0 0x0000555556c0ace0 in ?? () #1 0x00007ffff77da635 in operator<<(QDebug, QWidget const*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Widgets.so.6 #2 0x0000555555ae065f in operator() (__closure=0x555556ab0a20) at src/timetableprintform.cpp:52 #3 0x0000555555ae10a7 in operator() (__closure=0x7fffffffc120) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:141 #4 0x0000555555ae114e in QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()> >::call(TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()>&, void**)::<lambda()> >(void **, struct {...} &&) (args=0x7fffffffc258, fn=...) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:65 #5 0x0000555555ae10ec in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()> >::call(struct {...} &, void **) (f=..., arg=0x7fffffffc258) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:140 #6 0x0000555555ae1011 in QtPrivate::FunctorCallable<TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()> >::call<QtPrivate::List<>, void>(struct {...} &, void *, void **) (f=..., arg=0x7fffffffc258) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:362 #7 0x0000555555ae0f90 in QtPrivate::QCallableObject<TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()>, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=1, this_=0x555556ab0a10, r=0x555556ab0230, a=0x7fffffffc258, ret=0x0) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:572 #8 0x00007ffff5fde038 in ?? () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #9 0x00007ffff5feb33e in ?? () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #10 0x00007ffff5fd1e75 in QObject::event(QEvent*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #11 0x00007ffff77903f6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Widgets.so.6 #12 0x00007ffff5f7bcaa in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #13 0x00007ffff6129b4a in QTimerInfoList::activateTimers() () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #14 0x00007ffff625570c in ?? () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #15 0x00007fffe95145b5 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
timetableprintform.cpp:52 is:
qDebug() << "In lambda 2" << view;
I am not sure where I must do "Replace QWebEngineView with a basic instrumented subclass". That is a bit over my skill level. I will try it and report in a few minutes.
-
ahh.. Sorry. Now I understand why your code in my project do the semention fault.
TimetablePrintForm::~TimetablePrintForm() { qDebug("~TimetablePrintForm"); }
give me:
15 As constructed QWebEngineView(0x5977e8b2e040) In lambda 1 QWebEngineView(0x5977e8b2e040) 15 ~TimetablePrintForm Speicherzugriffsfehler (Speicherabzug geschrieben)
I am so sorry for that :-(
I sadly still don't get why my source doesn't work, because with my source I don't close the dialog. It closes only if I press a "close" button. So my code still doesn't emit the loadFinished signal with Qt 6.8.1; but with 6.7.2. -
@ChrisW67 said in Looks like the SIGNAL loadFinished(bool) is not emitted anymore with Qt 6.8.1:
~MyWebEngineView() { qDebug() << "Destructing MyWebEngineView" << this; }
I don't mean to detract from the diagnosis attempt, but I think it is actually causing its own problem/seg fault?
If you scroll through to the last backtrace we have been given in https://forum.qt.io/post/818795 we come across:
Thread 1 "Test" received signal SIGSEGV, Segmentation fault. 0x0000555556c0ace0 in ?? () (gdb) bt #0 0x0000555556c0ace0 in ?? () #1 0x00007ffff77da635 in operator<<(QDebug, QWidget const*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Widgets.so.6 #2 0x0000555555ae065f in operator() (__closure=0x555556ab0a20) at src/timetableprintform.cpp:52
This looks to me like the
this
in the destructor codeqDebug() << "Destructing MyWebEngineView" << this;
is aQWidget const*
and it is actually dying/segging on trying to fetch whatever fromthis
is wanted forqDebug()
? So although you can accessthis
in a destructor I wonder what state theQWidget
is in forqDebug()
at this point?@Volker75
You might want to change that line to justqDebug() << "Destructing MyWebEngineView";
(so nothis
) and see if that changes the backtrace to where whatever you real problem is. -
About the "Replace QWebEngineView with a basic instrumented subclass".
I think now unneeded for your code, since it was sadly my bug and I understand that problem now.
But that trick might help to locate the bug in my source.
I am sadly not clever enough to compile, since the linker complains:timetableprintform.cpp:(.text._ZN15MyWebEngineViewC2EP7QWidget[_ZN15MyWebEngineViewC5EP7QWidget]+0x2e): undefined reference to `vtable for MyWebEngineView'
But that is of course only because my skill level is too low to do that trick. Maybe you can give me a hint? (I added the "class MyWebEngineView" source and only replaced "QWebEngineView" by "MyWebEngineView".)
-
With my code, that is working fine with Qt 6.7.2, I can see that Qt 6.8.1 closes the printdialog as soon as I call setHtmlPreview:
15 setEnabled Preview setHtml Preview 15 ~TimetablePrintForm 15
hmm... Why does it deconstruct the printdialog. There is no reason for this. In Qt 6.7.2 it waits for user input (Since the user might print other tables. They must press pushbutton "close" or "X" the window to quit. So it quits automatically now before displaying the preview)
-
Thank you.
@JonB : I am sadly not clever enough. Source looks like this now:// #include <QtGlobal> #include <QtWidgets> //#ifdef Q_OS_WIN //nothing. Maybe the stuff from QPrintDialog?! //#else #include <QWebEngineView> //#endif #include "timetableprintform.h" #include <QString> #include <QStringList> #include <QSet> #include <QList> #include <QtSql> #include <QVBoxLayout> #include <QDebug> #include <QTimer> #ifdef QT_NO_PRINTER static QMap<QString, int> paperSizesMap; #else static QMap<QString, QPageSize> paperSizesMap; #endif // this is very similar to statisticsexport.cpp. so please also check there if you change something here! class MyWebEngineView: public QWebEngineView { Q_OBJECT public: explicit MyWebEngineView(QWidget *parent = nullptr) : QWebEngineView(parent) { qDebug() << "Constructing MyWebEngineView"; } ~MyWebEngineView() { qDebug() << "Destructing MyWebEngineView"; } }; TimetablePrintForm::TimetablePrintForm(QWidget *parent): QDialog(parent){ QVBoxLayout *layout = new QVBoxLayout(this); MyWebEngineView *view = new MyWebEngineView(this); qDebug() << "As constructed" << view; connect(view, &MyWebEngineView::loadFinished, this, &TimetablePrintForm::loadFinished); layout->addWidget(view); QTimer::singleShot(0, [=](){ qDebug() << "In lambda 1" << view; view->setHtml("<html><head><title>Initial page</title></head><body><p>Initial content</p></body></html>"); } ); QTimer::singleShot(3000, [=](){ qDebug() << "In lambda 2" << view; view->setHtml("<html><head><title>Three seconds page</title></head><body><p>New content</p></body></html>"); } ); } TimetablePrintForm::~TimetablePrintForm() { qDebug("~TimetablePrintForm"); } void TimetablePrintForm::loadFinished(bool ok) { qDebug() << Q_FUNC_INFO << ok; qDebug("loadDinished"); } //#endif
But i can't compile, since the linker tells me:
timetableprintform.cpp:(.text+0x557): undefined reference to `vtable for MyWebEngineView' collect2: error: ld returned 1 exit status
-
@Volker75
I believe this is because you have put theclass
definition withQ_OBJECT
directly into a.cpp
file. Then moc does not get run on it. You be best/simplest moving the wholeclass MyWebEngineView
definition to its own.h
file, including that, and doing a clean rebuild.Actually, I don't see why what you have requires
Q_OBJECT
. Try commenting that line and (important) do a really clean rebuild?But then
connect(view, &MyWebEngineView::loadFinished
probably won't work.... Don't know then whether&QWebEngineView::loadFinished
would work here. You may have to do first paragraph above, move to.h
file.You might wait for @ChrisW67 to get back if he has anything to say, I don't know what effort this is worth for whatever it is trying to prove.
-
Thank you for teaching me so much!
I done it's own .h file. I deleted the whole tmp folder. Clean rebuild.
I got still linker warning undefined reference to `vtable for MyWebEngineView'.
I removed Q_OBJECT.
Then I was able to compile.
I tried once and it crashed again.
I added debug <<this.
I tried once again and it looked similar as before (just with "this" information):15 Constructing MyWebEngineView QWebEngineView(0x63d7c1694fe0) As constructed QWebEngineView(0x63d7c1694fe0) In lambda 1 QWebEngineView(0x63d7c1694fe0) 15 ~TimetablePrintForm Destructing MyWebEngineView QWebEngineView(0x63d7c1694fe0) Speicherzugriffsfehler (Speicherabzug geschrieben)
gdb tells me:
... [New Thread 0x7fffbbe006c0 (LWP 6774)] [New Thread 0x7fffbb4006c0 (LWP 6775)] [New Thread 0x7fffbaa006c0 (LWP 6776)] [Thread 0x7fffbaa006c0 (LWP 6776) exited] [Thread 0x7fffbb4006c0 (LWP 6775) exited] [Thread 0x7fffbbe006c0 (LWP 6774) exited] [New Thread 0x7fffbbe006c0 (LWP 6777)] [New Thread 0x7fffbb4006c0 (LWP 6778)] [New Thread 0x7fffbaa006c0 (LWP 6779)] [Thread 0x7fffbaa006c0 (LWP 6779) exited] [Thread 0x7fffbb4006c0 (LWP 6778) exited] [Thread 0x7fffbbe006c0 (LWP 6777) exited] [New Thread 0x7fffbbe006c0 (LWP 6780)] [Detaching after fork from child process 6781] [Detaching after fork from child process 6782] [Detaching after fork from child process 6783] [New Thread 0x7fffbb4006c0 (LWP 6784)] [New Thread 0x7fffbaa006c0 (LWP 6785)] [New Thread 0x7fffb8a006c0 (LWP 6786)] [New Thread 0x7fffafe006c0 (LWP 6787)] [New Thread 0x7fffaf4006c0 (LWP 6788)] [New Thread 0x7fffaea006c0 (LWP 6789)] [New Thread 0x7fffae0006c0 (LWP 6790)] [New Thread 0x7fffad6006c0 (LWP 6791)] [New Thread 0x7fffacc006c0 (LWP 6792)] [New Thread 0x7fffa3e006c0 (LWP 6793)] [New Thread 0x7fffa2a006c0 (LWP 6795)] [New Thread 0x7fffa34006c0 (LWP 6794)] [New Thread 0x7fffa20006c0 (LWP 6796)] [New Thread 0x7fffa0c006c0 (LWP 6798)] [New Thread 0x7fffa16006c0 (LWP 6797)] [New Thread 0x7fff97e006c0 (LWP 6799)] [New Thread 0x7fff974006c0 (LWP 6800)] [New Thread 0x7fff96a006c0 (LWP 6801)] [New Thread 0x7fff960006c0 (LWP 6802)] [New Thread 0x7fff956006c0 (LWP 6803)] [New Thread 0x7fff94c006c0 (LWP 6804)] [New Thread 0x7fff8be006c0 (LWP 6805)] [Thread 0x7fff8be006c0 (LWP 6805) exited] [Thread 0x7fff94c006c0 (LWP 6804) exited] [Thread 0x7fff956006c0 (LWP 6803) exited] [New Thread 0x7fff956006c0 (LWP 6806)] [New Thread 0x7fff94c006c0 (LWP 6807)] [New Thread 0x7fff8be006c0 (LWP 6808)] [Thread 0x7fff8be006c0 (LWP 6808) exited] [Thread 0x7fff94c006c0 (LWP 6807) exited] [Thread 0x7fff956006c0 (LWP 6806) exited] [New Thread 0x7fff956006c0 (LWP 6809)] [New Thread 0x7fff94c006c0 (LWP 6810)] [New Thread 0x7fff8be006c0 (LWP 6811)] 15 [New Thread 0x7fff8b4006c0 (LWP 6824)] [New Thread 0x7fff8a6006c0 (LWP 6825)] [New Thread 0x7fff89c006c0 (LWP 6826)] [New Thread 0x7fff892006c0 (LWP 6827)] [New Thread 0x7fff7fe006c0 (LWP 6828)] [New Thread 0x7fff7f4006c0 (LWP 6829)] [New Thread 0x7fff7ea006c0 (LWP 6830)] Constructing MyWebEngineView QWebEngineView(0x5555569dd090) As constructed QWebEngineView(0x5555569dd090) In lambda 1 QWebEngineView(0x5555569dd090) [New Thread 0x7fff7e0006c0 (LWP 6835)] [New Thread 0x7fff7d6006c0 (LWP 6836)] [New Thread 0x7fff7cc006c0 (LWP 6838)] [New Thread 0x7fff73e006c0 (LWP 6839)] [New Thread 0x7fff734006c0 (LWP 6840)] [Thread 0x7fff734006c0 (LWP 6840) exited] [Thread 0x7fff73e006c0 (LWP 6839) exited] [Thread 0x7fff7cc006c0 (LWP 6838) exited] [New Thread 0x7fff7cc006c0 (LWP 6841)] [New Thread 0x7fff73e006c0 (LWP 6842)] [New Thread 0x7fff734006c0 (LWP 6843)] [New Thread 0x7fff72a006c0 (LWP 6849)] [New Thread 0x7fff720006c0 (LWP 6850)] [New Thread 0x7fff716006c0 (LWP 6851)] [Thread 0x7fff716006c0 (LWP 6851) exited] [Thread 0x7fff720006c0 (LWP 6850) exited] [Thread 0x7fff72a006c0 (LWP 6849) exited] 15 ~TimetablePrintForm Destructing MyWebEngineView QWebEngineView(0x5555569dd090) [Thread 0x7fff734006c0 (LWP 6843) exited] [Thread 0x7fff73e006c0 (LWP 6842) exited] [Thread 0x7fff7cc006c0 (LWP 6841) exited] Thread 1 "Test" received signal SIGSEGV, Segmentation fault. 0x00005555566db440 in ?? () (gdb) bt #0 0x00005555566db440 in ?? () #1 0x00007ffff77da635 in operator<<(QDebug, QWidget const*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Widgets.so.6 #2 0x0000555555ae06a1 in operator() (__closure=0x5555568004d0) at src/timetableprintform.cpp:45 #3 0x0000555555ae114d in operator() (__closure=0x7fffffffc120) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:141 #4 0x0000555555ae11f4 in QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()> >::call(TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()>&, void**)::<lambda()> >(void **, struct {...} &&) (args=0x7fffffffc258, fn=...) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:65 #5 0x0000555555ae1192 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()> >::call(struct {...} &, void **) (f=..., arg=0x7fffffffc258) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:140 #6 0x0000555555ae10b7 in QtPrivate::FunctorCallable<TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()> >::call<QtPrivate::List<>, void>(struct {...} &, void *, void **) (f=..., arg=0x7fffffffc258) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:362 #7 0x0000555555ae1036 in QtPrivate::QCallableObject<TimetablePrintForm::TimetablePrintForm(QWidget*)::<lambda()>, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=1, this_=0x5555568004c0, r=0x5555568004e0, a=0x7fffffffc258, ret=0x0) at ../../../Qt6.8/6.8.1/gcc_64/include/QtCore/qobjectdefs_impl.h:572 #8 0x00007ffff5fde038 in ?? () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #9 0x00007ffff5feb33e in ?? () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #10 0x00007ffff5fd1e75 in QObject::event(QEvent*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #11 0x00007ffff77903f6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Widgets.so.6 #12 0x00007ffff5f7bcaa in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #13 0x00007ffff6129b4a in QTimerInfoList::activateTimers() () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #14 0x00007ffff625570c in ?? () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #15 0x00007fffe95145b5 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 --Type <RET> for more, q to quit, c to continue without paging-- #16 0x00007fffe9573717 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #17 0x00007fffe9513a53 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #18 0x00007ffff625591e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #19 0x00007ffff5f88fe2 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #20 0x00007ffff5f85166 in QCoreApplication::exec() () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Core.so.6 #21 0x00005555555a7625 in main (argc=1, argv=0x7fffffffd938) at src/main.cpp:677
timetableprintform.cpp:45
qDebug() << "In lambda 2" << view;
I will go to sleep in ~30 minutes minutes. I will check the forum again after work. I can code in spare time only.
Thank you so much! -
@Volker75 said in Looks like the SIGNAL loadFinished(bool) is not emitted anymore with Qt 6.8.1:
#1 0x00007ffff77da635 in operator<<(QDebug, QWidget const*) () from /home/volker/Qt6.8/6.8.1/gcc_64/lib/libQt6Widgets.so.6
Still looks to me like it's trying to
qDebug()
aQWidget
--- presumably yourview
--- when something about it is invalid for that purpose during its destructor.Let's leave this now. I believe you have said you get a segmentation violation without introducing
qDebug()
s of objects during destruction. It would be nice to see a stack trace when that happens without any of this debug stuff introducing its own problems, which I believe is where you are now. -
hmm. Thank you so much. I sadly don't understand the last 2 sentences.
I am not as skilled as you. I still fear that one of the valgrind warnings is not false positive. But this is only a gut feeling from a rookie.
I will retry as soon as Qt 6.8.2 is released. I must sleep now. -
@JonB said in Looks like the SIGNAL loadFinished(bool) is not emitted anymore with Qt 6.8.1:
You might wait for @ChrisW67 to get back if he has anything to say, I don't know what effort this is worth for whatever it is trying to prove.
You are correct, it probably does not require Q_OBJECT. It's just habit for me to put it there and I was typing without the benefit of a Qt environment. I also missed the
connect()
referring to the wrong class as the target.It's just trying to make construct/destruct of the object overt and identify the objects (hence printing
this
). This is an aid to identifying if you have accidentally created a masking variable and to allow ensuring that everything is operating on the same object. This could also be done with debugger breakpoints and understanding. -
I was able to make a minimum example.
With Qt 6.7.2 it is working fine.
With Qt 6.8.1 is doesn't work.
Tested with Kubuntu 24.04.
http://www.scryer.de/MinBUG.zipCan maybe anyone have a look?
Thank you so much!