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. QApplication Crashed ..
Forum Updated to NodeBB v4.3 + New Features

QApplication Crashed ..

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 334 Views
  • 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.
  • G Offline
    G Offline
    GopalS
    wrote on last edited by
    #1

    I have an application running in Windows 10. The application opens a tiff image and displays in QLabel. QLabel *imageLabel; in header file

    Initialization
    imageLabel = new QLabel;
    imageLabel->setBackgroundRole(QPalette::Base);
    imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    imageLabel->setScaledContents(true);

    Application works fine .

    However when i add another Label it crashes.
    QLabel *processedImageLabel; in header file
    processedImageLabel = new QLabel; in constructor

    I ran the program in debug mode,
    I got a pop up window saying

    Inferior stopped because it received a signal from operating system.
    Signal name: SIGSEGV
    Signal meaning: Segmentation Fault.

    Why a segmentation fault even though 'new' operator is used to allocate memory. And pervious declaration works fine. I am not doing anything different.

    Requesting help

    Christian EhrlicherC C 2 Replies Last reply
    0
    • G GopalS

      I have an application running in Windows 10. The application opens a tiff image and displays in QLabel. QLabel *imageLabel; in header file

      Initialization
      imageLabel = new QLabel;
      imageLabel->setBackgroundRole(QPalette::Base);
      imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
      imageLabel->setScaledContents(true);

      Application works fine .

      However when i add another Label it crashes.
      QLabel *processedImageLabel; in header file
      processedImageLabel = new QLabel; in constructor

      I ran the program in debug mode,
      I got a pop up window saying

      Inferior stopped because it received a signal from operating system.
      Signal name: SIGSEGV
      Signal meaning: Segmentation Fault.

      Why a segmentation fault even though 'new' operator is used to allocate memory. And pervious declaration works fine. I am not doing anything different.

      Requesting help

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Please provide a minimal example and format your code with code tags so it is readable. Your pieces above are fine. If your application crashes then you normally take a debugger to see where exactly it is crashing.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • G GopalS

        I have an application running in Windows 10. The application opens a tiff image and displays in QLabel. QLabel *imageLabel; in header file

        Initialization
        imageLabel = new QLabel;
        imageLabel->setBackgroundRole(QPalette::Base);
        imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
        imageLabel->setScaledContents(true);

        Application works fine .

        However when i add another Label it crashes.
        QLabel *processedImageLabel; in header file
        processedImageLabel = new QLabel; in constructor

        I ran the program in debug mode,
        I got a pop up window saying

        Inferior stopped because it received a signal from operating system.
        Signal name: SIGSEGV
        Signal meaning: Segmentation Fault.

        Why a segmentation fault even though 'new' operator is used to allocate memory. And pervious declaration works fine. I am not doing anything different.

        Requesting help

        C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        @GopalS said in QApplication Crashed ..:

        However when i add another Label it crashes.

        QLabel *processedImageLabel;  in header file
        processedImageLabel = new QLabel; in constructor
        

        This pointer is local to the constructor and may be masking another pointer that never gets initialised, e.g. one declared as a member of the class. Using an uninitialised member variable pointer will likely end how you describe.

        JonBJ 1 Reply Last reply
        0
        • C ChrisW67

          @GopalS said in QApplication Crashed ..:

          However when i add another Label it crashes.

          QLabel *processedImageLabel;  in header file
          processedImageLabel = new QLabel; in constructor
          

          This pointer is local to the constructor and may be masking another pointer that never gets initialised, e.g. one declared as a member of the class. Using an uninitialised member variable pointer will likely end how you describe.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @ChrisW67
          Well not as show it is not, the second line in the constructor just uses the one declared in the .h file?

          Nonetheless, until we see actual code we don't know and it might well be that in fact the second one has a declaration in the constructor as you say....

          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