emit a signale twice => ASSERT: "!isEmpty()"



  • I get this error message:
    ASSERT: "!isEmpty()" in file d:\libraries\qt\msvs15_v5_7_0\include\qtcore\qvector.h, line 238

    When i emit a 2nd time here it gonna crash at this part.

    What is wrong??
    I can emit as often as i like here and i have no problems.



  • check the stack trace at the crash point, that assertion is triggered just because you try to access the first element of an empty vector, it's crashing somewhere else



  • i removed that if so i emit always.
    Opening a 2nd file => crash,
    Opening a file with more then one texture => crash,
    Removing the emit line => everything works.
    So i'm pretty sure it's that piece of code causing the problem. But here is my stack

    Qt5Cored.dll!qt_message_fatal(QtMsgType __formal, const QMessageLogContext & context, const QString & message) Zeile 1673 C++
    Qt5Cored.dll!QMessageLogger::fatal(const char * msg, ...) Zeile 793 C++
    Qt5Cored.dll!qt_assert(const char * assertion, const char * file, int line) Zeile 3063 C++
    QtMeshViewer.exe!QVector<QOpenGLTexture *>::last() Zeile 238 C++
    QtMeshViewer.exe!GeometryEngine::drawGeometry(QOpenGLShaderProgram * program) Zeile 212 C++
    QtMeshViewer.exe!OglViewerWidget::paintGL() Zeile 170 C++
    Qt5Widgetsd.dll!QOpenGLWidgetPrivate::invokeUserPaint() Zeile 830 C++
    Qt5Widgetsd.dll!QOpenGLWidgetPrivate::render() Zeile 851 C++
    Qt5Widgetsd.dll!QOpenGLWidget::paintEvent(QPaintEvent * e) Zeile 1204 C++
    Qt5Widgetsd.dll!QWidget::event(QEvent * event) Zeile 8931 C++
    Qt5Widgetsd.dll!QOpenGLWidget::event(QEvent * e) Zeile 1349 C++
    Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Zeile 3799 C++
    Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Zeile 3762 C++
    Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Zeile 988 C++
    Qt5Cored.dll!QCoreApplication::sendSpontaneousEvent(QObject * receiver, QEvent * event) Zeile 234 C++
    Qt5Widgetsd.dll!QWidgetPrivate::sendPaintEvent(const QRegion & toBePainted) Zeile 5696 C++
    Qt5Widgetsd.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev, const QRegion & rgn, const QPoint & offset, int flags, QPainter * sharedPainter, QWidgetBackingStore * backingStore) Zeile 5640 C++
    Qt5Widgetsd.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev, const QList<QObject *> & siblings, int index, const QRegion & rgn, const QPoint & offset, int flags, QPainter * sharedPainter, QWidgetBackingStore * backingStore) Zeile 5832 C++
    Qt5Widgetsd.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev, const QRegion & rgn, const QPoint & offset, int flags, QPainter * sharedPainter, QWidgetBackingStore * backingStore) Zeile 5690 C++
    Qt5Widgetsd.dll!QWidgetBackingStore::doSync() Zeile 1365 C++
    Qt5Widgetsd.dll!QWidgetBackingStore::sync() Zeile 1152 C++
    Qt5Widgetsd.dll!QWidgetPrivate::syncBackingStore() Zeile 1957 C++
    Qt5Widgetsd.dll!QWidget::event(QEvent * event) Zeile 9084 C++
    Qt5Widgetsd.dll!QMainWindow::event(QEvent * event) Zeile 1544 C++
    Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Zeile 3799 C++
    Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Zeile 3762 C++
    Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Zeile 988 C++
    Qt5Cored.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Zeile 231 C++
    Qt5Widgetsd.dll!QWidgetBackingStore::sendUpdateRequest(QWidget * widget, QWidgetBackingStore::UpdateTime updateTime) Zeile 484 C++
    Qt5Widgetsd.dll!QWidgetBackingStore::markDirty(const QRect & rect, QWidget * widget, QWidgetBackingStore::UpdateTime updateTime, QWidgetBackingStore::BufferState bufferState) Zeile 672 C++
    Qt5Widgetsd.dll!QWidget::repaint(const QRect & rect) Zeile 10874 C++
    Qt5Widgetsd.dll!QStatusBar::hideOrShow() Zeile 644 C++
    Qt5Widgetsd.dll!QStatusBar::showMessage(const QString & message, int timeout) Zeile 567 C++
    QtMeshViewer.exe!MainWindow::printMessage(QString message, int severity) Zeile 105 C++
    QtMeshViewer.exe!MainWindow::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Zeile 98 C++
    Qt5Cored.dll!QMetaObject::activate(QObject * sender, int signalOffset, int local_signal_index, void * * argv) Zeile 3740 C++
    Qt5Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Zeile 3602 C++
    QtMeshViewer.exe!GeometryEngine::sendMessage(QString _t1, int _t2) Zeile 189 C++
    QtMeshViewer.exe!GeometryEngine::loadTexture(const char * filePath, const char * fileName) Zeile 134 C++
    QtMeshViewer.exe!GeometryEngine::loadFile(const char * filePath) Zeile 101 C++
    QtMeshViewer.exe!GeometryEngine::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Zeile 99 C++
    Qt5Cored.dll!QMetaObject::activate(QObject * sender, int signalOffset, int local_signal_index, void * * argv) Zeile 3740 C++
    Qt5Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Zeile 3602 C++
    QtMeshViewer.exe!OglViewerWidget::loadFile(const char * t1) Zeile 138 C++
    QtMeshViewer.exe!OglViewerWidget::dropEvent(QDropEvent * e) Zeile 107 C++
    Qt5Widgetsd.dll!QWidget::event(QEvent * event) Zeile 8977 C++
    Qt5Widgetsd.dll!QOpenGLWidget::event(QEvent * e) Zeile 1349 C++
    Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Zeile 3799 C++
    Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Zeile 3556 C++
    Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Zeile 988 C++
    Qt5Cored.dll!QCoreApplication::sendSpontaneousEvent(QObject * receiver, QEvent * event) Zeile 234 C++
    Qt5Widgetsd.dll!QWidgetWindow::handleDropEvent(QDropEvent * event) Zeile 873 C++
    Qt5Widgetsd.dll!QWidgetWindow::event(QEvent * event) Zeile 280 C++
    Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Zeile 3799 C++
    Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Zeile 3159 C++
    Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Zeile 988 C++
    Qt5Cored.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Zeile 231 C++
    Qt5Guid.dll!QGuiApplicationPrivate::processDrop(QWindow * w, const QMimeData * dropData, const QPoint & p, QFlags<enum Qt::DropAction> supportedActions) Zeile 2853 C++
    Qt5Guid.dll!QWindowSystemInterface::handleDrop(QWindow * w, const QMimeData * dropData, const QPoint & p, QFlags<enum Qt::DropAction> supportedActions) Zeile 699 C++
    qwindowsd.dll!QWindowsOleDropTarget::Drop(IDataObject * pDataObj, unsigned long grfKeyState, POINTL pt, unsigned long * pdwEffect) Zeile 636 C++
    [Externer Code]
    [Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für ole32.dll]
    Qt5Guid.dll!QWindowSystemInterfacePrivate::postWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent * ev) Zeile 403 C++
    Qt5Guid.dll!QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent * ev) Zeile 436 C++
    [Externer Code]
    qwindowsd.dll!QWindowsMouseHandler::translateMouseEvent(QWindow * window, HWND
    * hwnd, QtWindows::WindowsEventType et, tagMSG msg, long * result) Zeile 382 C++
    [Externer Code]
    tiptsf.dll!6d1678bc() Unbekannt
    [Externer Code]
    Qt5Cored.dll!qt_GetMessageHook(int code, unsigned int wp, long lp) Zeile 508 C++
    [Externer Code]
    tiptsf.dll!6d16c2e4() Unbekannt
    [Externer Code]
    Qt5Cored.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Zeile 135 C++
    Qt5Cored.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Zeile 210 C++
    Qt5Cored.dll!QCoreApplication::exec() Zeile 1261 C++
    Qt5Guid.dll!QGuiApplication::exec() Zeile 1640 C++
    Qt5Widgetsd.dll!QApplication::exec() Zeile 2976 C++
    QtMeshViewer.exe!main(int argc, char * * argv) Zeile 12 C++
    [Externer Code]



  • QtMeshViewer.exe!GeometryEngine::drawGeometry(QOpenGLShaderProgram * program) Zeile 212 C++

    the problem is here when m_textures is empty



  • This is never empty.
    Since it is only executed when the buffers are created
    and if those are created there is always a texture added to that list here

    But why does it only crashes, when i emit that signal?? i see that the stack is currently running that. But when i go through the code with the debugger, it's always here where it crashes



  • @QT-static-prgm said in emit a signale twice => ASSERT: "!isEmpty()":

    This is never empty.

    Your stack trace disagrees... try adding Q_ASSERT(!m_textures.isEmpty()); before if (it.textureIndex < m_textures.size()) it's free and if I'm wrong and never asserts I'll shut my hole



  • @VRonin just one question, what should happen, if i add that in this line??

    i think i fixed it by an other way:
    I opened my file the first time and it worked. Then i pressed open file and aboard => Error: file not found is printed via the signal slot connection.
    next i opened my file again (now it should crash), but it does not. I wonder that there are no warnings emit as well, so i debugged and noticed that i did an logical mistake. I could always overwrite Messages in the statusbar, if my severity is higher then the previous. But i forgot about the time out. If there is currently no message i can print every severity. And while i was thinking about the big solution with QTimer and reset the m_currentSeverity variable i found the QStatusbar::currentMessage().isEmpty() function and added it here

    And now everything works fine. So please explain to me, WHY THE HELL did it crash without that?? It still process the same way, since the messages are all same priority, they were previous printed and now they are printed, too. But previous it crash at printing


  • Qt Champions 2016

    As my fellow said, this has little to do with any signal emitting. Your QVector<> is empty so it asserts when calling QVector::last():

    QtMeshViewer.exe!QVector<QOpenGLTexture *>::last() Zeile 238 C++
    

    It even specifies where exactly this happens.



  • But all i changed was changing this: !ui->statusBar->currentMessage().isEmpty() &&
    and now it works.

    If you don't believe I haven't changed anything else you can check the git change log: https://git.rwth-aachen.de/carstenf/OpenGL/commit/e963b7538e8ce9fbd706e035e53ab8aef53dae77


  • Qt Champions 2016

    Look, I'm not saying it works or it doesn't, or what you changed. I haven't run your code, hell I haven't even looked at your code, just because the stack trace can never lie to you. I trust it with my life and it says you've tripped the assertion on line 212 in GeometryEngine::drawGeometry by calling QVector<QOpenGLTexture *>::last() on a vector that's empty. That's all, so if you change something and this is not happening anymore, then you won't trip the assertion.



  • I see.
    The only way i could explain it to me: does showMessage on the statusbar call update on the window??



  • @QT-static-prgm said in emit a signale twice => ASSERT: "!isEmpty()":

    @VRonin just one question, what should happen, if i add that in this line??

    • In debug mode you can read Q_ASSERT(condition) as if(!condition){ /*"crash the program"*/;}
    • In release mode that line is completely ignored

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.