Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Segmentation fault when allocating widgets
Forum Updated to NodeBB v4.3 + New Features

Segmentation fault when allocating widgets

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ageispolis
    wrote on last edited by
    #1

    Hey everyone,

    I've hit a rather bizarre (and frustrating) issue involving the setupUi() method generated by Qt Creator:

    @
    void setupUi(QMainWindow *MainWindow)
    {
    if (MainWindow->objectName().isEmpty())
    MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
    MainWindow->setWindowModality(Qt::WindowModal);
    MainWindow->resize(761, 556);
    MainWindow->setAutoFillBackground(false);
    actionFull_Screen = new QAction(MainWindow);
    actionFull_Screen->setObjectName(QString::fromUtf8("actionFull_Screen"));
    actionClose_Midi = new QAction(MainWindow);
    actionClose_Midi->setObjectName(QString::fromUtf8("actionClose_Midi"));
    [...]
    @

    The issue is that once the method attempts to allocate any widget (not just a QAction), a segfault occurs. It can't be that MainWindow is a null pointer, since it always points to the (already instantiated) main window, and the same pointer is dereferenced several times without any problems immediately prior to the segfault anyway.

    What's especially strange about this is that the problem more or less came out of nowhere; before it started happening, I had only made minimal changes to the .ui file, which basically amounted to tweaking a few widget settings, but nothing that seems like it would lead to an issue like this.

    Any ideas? (If it makes a difference, I'm running Qt Creator 2.4.0 on Windows)

    Thanks in advance!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      As the very first step, I would try to completely rebuild the project.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ageispolis
        wrote on last edited by
        #3

        Hmm, that did the trick - no idea why I didn't try that previously. Thanks!

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          No problem, you're welcome. Sometimes the source code of some class using another one is not recompiled in case the latter one changes. So, the object alignment within that latter class doesn't fit that of the using class anymore. I ran into some weird crashes of that sort quite often too, most times a recompile cures everything.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mlong
            wrote on last edited by
            #5

            Be sure and tag your post as [Solved]. Thanks!

            Software Engineer
            My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved