Results 1 to 1 of 1

Thread: Segfault when using signal and slot in dynamic library

  1. #1
    Join Date
    Oct 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Segfault when using signal and slot in dynamic library

    Hello,

    I have two part in my program :
    - the first is like a "plugin manager" with a gui
    - the second is one (or more) "plugin" also with a gui

    all work well (when i get from the dyanmic library the layout and display it), but when i click on the button it's segfault.

    there is the backtrace with gdb
    Qt Code:
    1. #0 0x00007ffff6512224 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    2. #1 0x00007ffff7114e42 in QAbstractButton::clicked(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    3. #2 0x00007ffff6e9e096 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    4. #3 0x00007ffff6e9ebae in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    5. #4 0x00007ffff6e9ed24 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    6. #5 0x00007ffff6de2ea5 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    7. #6 0x00007ffff6da7c8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    8. #7 0x00007ffff6dadb61 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    9. #8 0x00007ffff64eac2d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    10. #9 0x00007ffff6dab9e1 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
    11. from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    12. #10 0x00007ffff6dffbbf in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    13. #11 0x00007ffff6e019bb in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    14. #12 0x00007ffff6da7c8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    15. #13 0x00007ffff6dace56 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
    16. #14 0x00007ffff64eac2d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    17. #15 0x00007ffff4f1425c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
    18. #16 0x00007ffff4f15925 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) ()
    19. from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
    20. #17 0x00007ffff4efe858 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
    21. #18 0x00007fffeede85b0 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
    22. #19 0x00007ffff4922e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    23. #20 0x00007ffff4923048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    24. #21 0x00007ffff49230ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    25. #22 0x00007ffff653798c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    26. #23 0x00007ffff64e996b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    27. #24 0x00007ffff64f00e1 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    28. #25 0x0000000000409264 in main (ac=1, av=0x7fffffffe598) at src/main.cpp:49
    To copy to clipboard, switch view to plain text mode 

    There is my class that is in the shared library
    the ".h"
    Qt Code:
    1. #ifndef TEXTVIEW_H_
    2. # define TEXTVIEW_H_
    3.  
    4. # include <QPushButton>
    5. # include "View.h"
    6.  
    7. class TextView : public QObject, public View
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. TextView(AController &controller, ITcpModel &model);
    13. virtual ~TextView();
    14.  
    15. virtual int getX();
    16. virtual int getY();
    17. virtual int getRows();
    18. virtual int getCols();
    19.  
    20. public slots:
    21. void signtest(bool);
    22. private:
    23. QPushButton *_test;
    24. };
    25.  
    26. #endif
    To copy to clipboard, switch view to plain text mode 

    the ".cpp"
    Qt Code:
    1. # include "TextView.h"
    2. # include <iostream>
    3.  
    4. TextView::TextView(AController &controller, ITcpModel &model):
    5. View(controller, model)
    6. {
    7. _test = new QPushButton();
    8. _test->setText("THIS IS A BUTTON !");
    9. _layout->addWidget(_test, 0, 0, 1, 1);
    10. std::cout << "CONNECT " <<
    11. connect(_test, SIGNAL(clicked(bool)),
    12. this, SLOT(signtest(bool))) << std::endl;
    13. }
    14.  
    15. void TextView::signtest(bool)
    16. {
    17. std::cout << "print this please" << std::endl;
    18. }
    19.  
    20. TextView::~TextView()
    21. {}
    22.  
    23. int TextView::getX() {return 1;}
    24. int TextView::getY() {return 1;}
    25. int TextView::getRows() {return 1;}
    26. int TextView::getCols() {return 1;}
    To copy to clipboard, switch view to plain text mode 

    There is View
    Qt Code:
    1. class View : public AView<QGridLayout>
    2. {
    3. public:
    4. View(AController &controller, ITcpModel &model);
    5. virtual ~View();
    6.  
    7. virtual QGridLayout &getLayout();
    8. virtual void messageBox(const std::string &str);
    9.  
    10. virtual int getX() = 0;
    11. virtual int getY() = 0;
    12. virtual int getRows() = 0;
    13. virtual int getCols() = 0;
    14. protected:
    15. QGridLayout *_layout;
    16. };
    To copy to clipboard, switch view to plain text mode 

    Thank you for reading and sorry for my bad english
    Last edited by e.t.; 28th October 2015 at 19:24.

Similar Threads

  1. signal/slot mechanism and shared library
    By mickael in forum Qt Programming
    Replies: 5
    Last Post: 25th November 2012, 15:08
  2. Replies: 8
    Last Post: 7th November 2012, 15:10
  3. Dynamic library on Mac, Library not loaded
    By grayfox in forum Newbie
    Replies: 2
    Last Post: 2nd July 2011, 03:42
  4. Dynamic library with GUI for Mac
    By mouse_sonya in forum Qt Programming
    Replies: 1
    Last Post: 26th July 2010, 13:23
  5. Interesting little Segfault w/r to signal/slot connection
    By Hydragyrum in forum Qt Programming
    Replies: 24
    Last Post: 12th September 2006, 20:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.