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. GUI hangs under linux
Forum Updated to NodeBB v4.3 + New Features

GUI hangs under linux

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 3.5k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Without code it's crystal ball debugging. Can you show your main.cpp for a start ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SpanishJohn
      wrote on last edited by
      #3

      Yes. Sorry I realize it was a bit vague

      Here is my main:

      int main(int argc, char *argv[])
      {
      config_t config;

      #ifndef WIN32

      // It is only necessary to call this function if multiple threads might use Xlib concurrently (and this should *not* be the case - I think!)
      XInitThreads();
      

      #endif

      fprintf(stderr, "\n");
      
      if (config_t::load(argc, argv, &config) != 1)
      {
          return -1;
      }
      
      Q_INIT_RESOURCE(backhaul_gui);
      
      QApplication app(argc, argv);
      
      QCoreApplication::setOrganizationDomain("AlteraDomain");
      QCoreApplication::setOrganizationName("Altera");
      QCoreApplication::setApplicationName(APP_NAME);
      QCoreApplication::setApplicationVersion("1.0.0");
      

      #ifndef WIN32

      app.setStyle("windowsxp");
      

      #endif

      backhaul_gui backhaul_gui(config);
      
      backhaul_gui.setMinimumSize(1200, 600);
      
      if (!backhaul_gui.initialise())
      {
          QMessageBox::warning(NULL, QObject::tr(APP_NAME),
                               QObject::tr("Unable to initialise. Application terminating."),
                               QMessageBox::Ok);
      
          return -1;
      }
      
      // Get the thread ID of the main thread
      g_thread_id = QThread::currentThreadId();
      
      return app.exec();
      

      }

      The app opens and has the option to open the 'connect with server' dialog. The dialog requires an IP address and a socket number. I only have to press the mouse button in the edit box and she hangs...

      BRgds, SJ

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SpanishJohn
        wrote on last edited by
        #4

        @int main(int argc, char *argv[])
        {
        config_t config;

        #ifndef WIN32

        XInitThreads();
        

        #endif

        fprintf(stderr, "\n");
        
        
        if (config_t::load(argc, argv, &config) != 1)
        {
            return -1;
        }
        
        Q_INIT_RESOURCE(backhaul_gui);
        
        QApplication app(argc, argv);
        
        QCoreApplication::setOrganizationDomain("AlteraDomain");
        QCoreApplication::setOrganizationName("Altera");
        QCoreApplication::setApplicationName(APP_NAME);
        QCoreApplication::setApplicationVersion("1.0.0");
        

        #ifndef WIN32

        app.setStyle("windowsxp");
        

        #endif

        backhaul_gui backhaul_gui(config);
        
        backhaul_gui.setMinimumSize(1200, 600);
        
        if (!backhaul_gui.initialise())
        {
            QMessageBox::warning(NULL, QObject::tr(APP_NAME),
                                 QObject::tr("Unable to initialise. Application terminating."),
                                 QMessageBox::Ok);
        
            return -1;
        }
        
        // Get the thread ID of the main thread
        g_thread_id = QThread::currentThreadId();
        
        return app.exec();
        

        }@
        A better main :)

        SJ

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SpanishJohn
          wrote on last edited by
          #5

          The application is statically built with Qt 4.7.4

          SJ

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SpanishJohn
            wrote on last edited by
            #6

            Hi again. More details.

            The application always hangs when I go to edit the socket number.

            here is the code for the corresponding slot:

            @void api_connect_t::edit_socket(QString str)
            {
            if (str.length() > 0)
            {
            m_socket = str.toInt();
            }
            }@

            If I remove the

            @XInitThreads();@

            from main and run this is what I get:

            bq. X Error: BadImplementation (server does not implement operation) 17
            Major opcode: 20 (X_GetProperty)
            Resource id: 0x0
            Xlib: sequence lost (0x10000 > 0x99eb) in reply type 0x0!
            X Error: 0 0
            Major opcode: 0 ()
            Resource id: 0x2c484d0
            X Error: 0 0
            Major opcode: 0 ()
            Resource id: 0x132
            X Error: 0 0
            Major opcode: 0 ()
            Resource id: 0x0
            X Error: 0 0
            Major opcode: 0 ()
            Resource id: 0x0
            Xlib: sequence lost (0x10000 > 0xa9c3) in reply type 0xe7!
            Xlib: sequence lost (0x10000 > 0xa9c3) in reply type 0xe7!
            Xlib: sequence lost (0x10000 > 0xaa9b) in reply type 0x0!
            X Error: 0 0
            Major opcode: 0 ()
            Resource id: 0x0
            Xlib: sequence lost (0x10000 > 0xaa9b) in reply type 0x1!
            Xlib: unexpected async reply (sequence 0x0)!
            Killed

            Now, if I do this to my socket slot the problem appears to go away:

            @void api_connect_t::edit_socket(QString str)
            {
            return;

            if (str.length() > 0)
            {
                m_socket = str.toInt();
            }
            

            }@

            Very strange!!

            SJ

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #7

              First, why do you need XInitThreads ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SpanishJohn
                wrote on last edited by
                #8

                Hi.

                I use XInitThreads because it makes a bad situation slightly better. However it does not solve the problem so ideally it should not be there. Without it I get the screen dump shown above almost immediately on opening my simple dialog.

                My application does implement a worker thread that is used for the client layer of my app, where as all GUI related work is done by the main thread. I have been very careful to avoid the worker thread directly manipulating widgets - on the rare event that such manipulation is required I use the following method to
                ensure the worker does not directly drive the widget.

                @QCoreApplication::postEvent(g_gui, new progress_event_t(0));@

                As it happens the crash shown above happens when the worker thread is idle (running usleep) .

                SJ

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  How does your application behave if you don't have that worker thread active ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SpanishJohn
                    wrote on last edited by
                    #10

                    Hi. OK so I commented out the code that starts the worker thread and -

                    she hung immediately :(

                    which confirms its not the worker thread that's causing the problem. I'm out of ideas.

                    SJ

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      Then start your application from scratch adding one element after another until it hangs

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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