Results 1 to 3 of 3

Thread: Application does no longer start in Qt Creator once it has run into segfault in Linux

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Application does no longer start in Qt Creator once it has run into segfault in L

    I figured out why this was happening and it wasn't related to qt creator but i can't find a way to delete this post.

    Just for the odd chance someone runs into this issue. It was cause by using QSharedMemory to allow only single instance of application process to run. In Linux/Unix the shared memory did not get released after application crashed.
    Qt Code:
    1. int main(int argc, char *argv[]) {
    2. QSharedMemory shared(QDir::currentPath());
    3. if(!shared.create(512, QSharedMemory::ReadWrite)) {
    4. Log4Qt::Logger::logger(QLatin1String("ErrorLogger"))->info("Application already running.");
    5. exit(0);
    6. }
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Application does no longer start in Qt Creator once it has run into segfault in L

    Yes, on Unix shared memory is "owned" by the operating system itself: http://qt-project.org/doc/qt-4.8/qsh...y.html#details

    An approach that should work better cross-platform is using a QLocalServer.
    Has the additional benefit that you can use QLocalSocket in the second instance to communicate with the first one, e.g. passing command line arguments of the new invocation.

    Cheers,
    _

Similar Threads

  1. Load the workspace in Qt Creator at start
    By qt_developer in forum Newbie
    Replies: 1
    Last Post: 1st November 2012, 14:50
  2. Replies: 3
    Last Post: 17th July 2012, 20:58
  3. Replies: 5
    Last Post: 25th April 2012, 11:34
  4. Cannot start app in Qt Creator
    By giantdragon in forum Newbie
    Replies: 1
    Last Post: 23rd May 2011, 21:32
  5. QListWidgetItem->text() causing application segfault
    By Valheru in forum Qt Programming
    Replies: 6
    Last Post: 21st August 2006, 22:08

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
  •  
Qt is a trademark of The Qt Company.