Notification about new connections not working with Qt 5

Issue #5 invalid
Alex Skorodumov created an issue

With Qt 5.1.0 on Win7x64 I got the following warning in standard output:

QWinEventNotifier: Can only be used with threads started with QThread

And server does not response to the client requests. The best answers from Google which I found are about missing event loop (no QCoreApplication::exec), this is not related to our case.

I will make a more deep investigation in this area and will try to fix. But probably somebody has a good idea what to do right now?

Comments (7)

  1. Alex Skorodumov reporter

    I checked the idea, that QCoreApplication::exec must be called before QLocalSocket::listen with such modifications in localserver.cpp:

        QCoreApplication app(argc, argv);
    
        TestService service;
        QJsonRpcLocalServer rpcServer;
        rpcServer.addService(&service);
    
        QTimer startServiceTimer;
        startServiceTimer.setSingleShot(true);
        startServiceTimer.start();
        QObject::connect(&startServiceTimer, &QTimer::timeout, [&rpcServer]{
            if (!rpcServer.listen("correct.address")) {
                qDebug() << "could not start server: " << rpcServer.errorString();
                qApp->instance()->exit(-1);
            }
        });
    
        return app.exec();
    

    No success.

  2. Alex Skorodumov reporter
    • changed status to open

    Still here... I missed warning with Qt5.1.1 cause of release mode (no debug output). Most likely that bug is on the Qt side

  3. Matt Broadstone

    are you running a custom piece of code, or the code from the examples directory? I won't have access to a workstation running 5.1.1 until later today unfortunately.

  4. Alex Skorodumov reporter

    I got the error with the vanilla source code of localserver example. The only changes I have made are for successful compilation with Qt5, they are in repo already. All this changes are only about local socket name.

  5. Alex Skorodumov reporter

    The problem was because of using release version of qjsonrpc1.dll with debug version of localserver example. After successful compilation of qjsonrpc, I ran "make install" and release version of qjsonrpc.dll was copied to QT_HOME/lib folder. During debug session from QtCreator, needed libraries are searching in QT_HOME/lib before the parent project build directory. It would be nice to upgrade .pro file in such way that debug version of library will contain "d", like all others Qt libraries.

  6. Log in to comment