SFML community forums

Help => General => Topic started by: mvlabat on June 21, 2015, 10:54:21 am

Title: Strange error "Unhandled event type: 0"
Post by: mvlabat on June 21, 2015, 10:54:21 am
Hello!

I'm using QSFMLWidget from 1.x turorual which I have got working with SFML2.3.
On implementing event handling system I've faced a strange error.

X Extensions:
        Generic Event Extension - First event: 0
        SHAPE - First event: 64
        MIT-SHM - First event: 65
        XInputExtension - First event: 66
        XTEST - First event: 0
        BIG-REQUESTS - First event: 0
        SYNC - First event: 83
        XKEYBOARD - First event: 85
        XC-MISC - First event: 0
        XFIXES - First event: 86
        RENDER - First event: 0
        RANDR - First event: 88
        XINERAMA - First event: 0
        Composite - First event: 0
        DAMAGE - First event: 90
        MIT-SCREEN-SAVER - First event: 91
        DOUBLE-BUFFER - First event: 0
        RECORD - First event: 0
        DPMS - First event: 0
        Present - First event: 0
        DRI3 - First event: 0
        X-Resource - First event: 0
        XVideo - First event: 92
        XFree86-VidModeExtension - First event: 0
        XFree86-DGA - First event: 94
        DRI2 - First event: 101
        GLX - First event: 103
        NV-GLX - First event: 0
        NV-CONTROL - First event: 120
Unhandled event type: 0
Report this to the SFML maintainers if possible

Here is my function:
void QSFMLCanvas::OnUpdate()
{
    sf::Event event;
    while (pollEvent(event)) {
        switch(event.type)
        {
            case (sf::Event::MouseButtonPressed) :
                qDebug() << "mouse clicked"; // Event never handled
                //mousePressedEventHandling(event);
                break;
            case (sf::Event::MouseMoved) :
                qDebug() << "mouse moved"; // Event handled
                //mouseMovedEventHandling(event);
                break;
            case (sf::Event::KeyPressed) :
                qDebug() << "key pressed"; // Event handled
                break;
            default:
                break;
        }

    }
    // Clear screen
    clear(sf::Color(0, 0, 0));
    engine.render();
}

As I can see in my console, none of the events are handled.
I'm using Linux.
Title: Re: Strange error "Unhandled event type: 0"
Post by: binary1248 on June 21, 2015, 05:31:01 pm
Can you provide more code (including the section where you create the window) and state which version of Qt you are using?
Title: Re: Strange error "Unhandled event type: 0"
Post by: mvlabat on June 22, 2015, 12:33:35 am
https://github.com/mvlabat/qtsfml-game/blob/3edb5fd58ddf580bcbea9d69875ec1e2594c35d2/main.cpp
https://github.com/mvlabat/qtsfml-game/blob/3edb5fd58ddf580bcbea9d69875ec1e2594c35d2/qsfmlcanvas.cpp

There are my files in the state when I wrote my message.
I use Qt 5.4.1.
Title: Re: Strange error "Unhandled event type: 0"
Post by: binary1248 on June 22, 2015, 12:26:18 pm
When you say "As I can see in my console, none of the events are handled." what do you mean? Are you just misinterpreting what is output on the console? Or do the events in your application not work? The console output is only diagnostic information which helps us track down subtle issues which might be related to it. If your application functions correctly even though stuff is printed on the console then we will just have to add the event type to the whitelist.
Title: Re: Strange error "Unhandled event type: 0"
Post by: mvlabat on June 22, 2015, 01:53:50 pm
I do
qDebug() << "some string..."
which has to print corresponding text to my IDE (Qt Creator) console on aforementioned in the code events.
On moving and pressing mouse and buttons I get no such output. So the logical conclusion is that my events aren't handled for some mysterious reason. In addition I get the strange error "Unhandled event type: 0" which may be related to the problem.

I hope now I'm clear. Thank you
Title: Re: Strange error "Unhandled event type: 0"
Post by: binary1248 on June 22, 2015, 02:06:48 pm
Are you sure that QSFMLCanvas::showEvent() is being called and that the SFML window is being created with the right window ID? Qt can create multiple (hidden/temporary) windows in certain situations and it is up to you to provide SFML with the right ID to take over.
Title: Re: Strange error "Unhandled event type: 0"
Post by: mvlabat on June 22, 2015, 03:15:50 pm
Yes, QSFMLCanvas::showEvent() is called.
Which window ID is right: of main window or of QSFMLCanvas widget?

As you can see all my program is working well except event handling.

(http://i.imgur.com/qGZAQPus.jpg)
(thumbnail) (http://i.imgur.com/kEvtNTf.png)
Title: Re: Strange error "Unhandled event type: 0"
Post by: Laurent on June 22, 2015, 03:21:33 pm
Event handling doesn't work reliably when you integrate SFML with Qt, especially on Linux -- and probably even more now that we've switched to XCB instead of Xlib. Use Qt events instead, those will always work perfectly.
Title: Re: Strange error "Unhandled event type: 0"
Post by: mvlabat on June 22, 2015, 04:14:16 pm
Event handling doesn't work reliably when you integrate SFML with Qt, especially on Linux -- and probably even more now that we've switched to XCB instead of Xlib. Use Qt events instead, those will always work perfectly.

Thank you for your answer. May I ask you if there are any best practices or examples how to use Qt events for proper movement implementation?
Title: Re: Strange error "Unhandled event type: 0"
Post by: Laurent on June 22, 2015, 04:37:01 pm
Quote
May I ask you if there are any best practices or examples how to use Qt events for proper movement implementation?
Events will only tell you when movement starts and stops. What's in between is another topic.