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. QLocalServer crashes when QString is used instead of "string_literal"

QLocalServer crashes when QString is used instead of "string_literal"

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 1.6k Views 2 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
    ashishbansal
    wrote on last edited by
    #1

    Hi everyone,

    Qt application is crashing for me when I use "string_literal" instead of QString in QLocalServer::listen .

    Here's my code :

    SingleInstance::SingleInstance(int argc, char *argv[]) :
        QApplication(argc, argv),
        mServerName("foo")
    {
        mLocalSocket = new QLocalSocket();
        mLocalSocket->connectToServer(mServerName);
        if (mLocalSocket->waitForConnected(mTimeToWait)) {
            askForMainWindow();
            ::exit(0);
        }
    
        mLocalServer = new QLocalServer();
        mLocalServer->setSocketOptions(QLocalServer::UserAccessOption);
        connect(mLocalServer, &QLocalServer::newConnection, this, &SingleInstance::clientConnected);
        mLocalServer->listen(mServerName);
    }
    
    

    This is crashing for me. And if replace mServerName with "foo".
    Does anyone know the reason for this ?
    (BTW this class is inheriting QApplication and event loop hasn't been started yet.)

    Here 's backtrace :

    
    (gdb) bt
    #0  0x00007ffff60210ca in strlen () from /usr/lib/libc.so.6
    #1  0x00007ffff6e63c41 in QCoreApplication::arguments() () from /usr/lib/libQt5Core.so.5
    #2  0x00007fffed464fb2 in ?? () from /usr/lib/libQt5XcbQpa.so.5
    #3  0x00007fffed465bb4 in ?? () from /usr/lib/libQt5XcbQpa.so.5
    #4  0x00007fffecfe9c38 in _SmcProcessMessage () from /usr/lib/libSM.so.6
    #5  0x00007fffecdd946c in IceProcessMessages () from /usr/lib/libICE.so.6
    #6  0x00007ffff6e8f31a in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/libQt5Core.so.5
    #7  0x00007ffff6f0f21e in QSocketNotifier::activated(int, QSocketNotifier::QPrivateSignal) () from /usr/lib/libQt5Core.so.5
    #8  0x00007ffff6e9be3b in QSocketNotifier::event(QEvent*) () from /usr/lib/libQt5Core.so.5
    #9  0x00007ffff78a79ac in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
    #10 0x00007ffff78ace86 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
    #11 0x00007ffff6e60bab in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
    #12 0x00007ffff6eb7a1d in ?? () from /usr/lib/libQt5Core.so.5
    #13 0x00007ffff586cdc7 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
    #14 0x00007ffff586d020 in ?? () from /usr/lib/libglib-2.0.so.0
    #15 0x00007ffff586d0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
    #16 0x00007ffff6eb754f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
    #17 0x00007ffff6e5e57a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
    #18 0x00007ffff6e6653c in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
    #19 0x00000000004351c0 in main (argc=1, argv=0x7fffffffe4a8) at /home/phantom/devel/sdm/main.cpp:31
    
    

    Is this a bug in Qt ?

    Moreover, I'm using Qt5.5.1 and gcc version 5.3.0 (GCC)

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

      Hi,

      Not a direct answer but are you trying to reimplement QtSingleApplication ?

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

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Not a direct answer but are you trying to reimplement QtSingleApplication ?

        A Offline
        A Offline
        ashishbansal
        wrote on last edited by
        #3

        @SGaist said:

        Hi,

        Not a direct answer but are you trying to reimplement QtSingleApplication ?

        Yeah

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

          Why not use it ? IIRC It's been ported to Qt 5

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

          A 1 Reply Last reply
          0
          • SGaistS SGaist

            Why not use it ? IIRC It's been ported to Qt 5

            A Offline
            A Offline
            ashishbansal
            wrote on last edited by
            #5

            @SGaist said:

            Why not use it ? IIRC It's been ported to Qt 5

            Oh, I didn't know that.

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

              It's in the QtSolution module and there's a fix for Qt 5.5 so yes, it's been ported :)

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

              A 1 Reply Last reply
              1
              • SGaistS SGaist

                It's in the QtSolution module and there's a fix for Qt 5.5 so yes, it's been ported :)

                A Offline
                A Offline
                ashishbansal
                wrote on last edited by
                #7

                @SGaist said:

                It's in the QtSolution module and there's a fix for Qt 5.5 so yes, it's been ported :)

                Okay, Thanks a lot :)

                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