Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving map sometimes doesn't repaint correctly #174

Open
stefanbeller opened this issue Mar 22, 2012 · 16 comments
Open

Moving map sometimes doesn't repaint correctly #174

stefanbeller opened this issue Mar 22, 2012 · 16 comments
Labels
bug Broken behavior. qt issue Qt related issue.

Comments

@stefanbeller
Copy link
Contributor

(Moving https://sourceforge.net/apps/mantisbt/tiled/view.php?id=84 to the new issue tracker here)

When the map is being dragged around by either middleclick or by space bar and left mouseclick, sometimes
artifacts (the current stampbrush) is painted on the map and not removed correctly.

That happens when you scroll against a border (so mouse moves, but map does not move, because map border is reached)
and once you are done scrolling, the area is not repainted until you move the mouse.

@jakerr
Copy link

jakerr commented Feb 17, 2013

This went away for me when I turned on "Hardware accelerated drawing (Open GL)" in the preferences menu.

@bjorn
Copy link
Member

bjorn commented Feb 17, 2013

@jakerr Yeah, in general you will not have repaint issues when enabling OpenGL mode because in that mode the whole map view gets repainted if anything changed, while in software rendering mode only the changing parts get repainted.

@parasyte
Copy link

This bug is especially annoying when scrolling large maps with a trackpad or mouse wheel on a Mac. (I haven't tried it on Linux yet.) It doesn't happen in 0.8.1.

@bjorn
Copy link
Member

bjorn commented Feb 18, 2013

@parasyte Hmm, if your issue doesn't happen on 0.8.1 then I think you're talking about a new bug, since this one has been happening forever and on all platforms. Any idea what the difference could be? Could you show a screenshot?

@parasyte
Copy link

@bjorn sorry about that. It seemed to be related. The easiest to reproduce case is creating a new large map (I used 100x100 tiles, 32x32 px each) and just scrolling the map with the brush tool. Even with no tile selected for the brush, the "highlight" graphic will not be refreshed properly.

Two screens: one with a tile selected, and one without. All I did was scroll the map up and down without moving the mouse cursor. The cursor wasn't captured in the screen shots, so I simulated it by adding a black arrow.

Without tile

With tile

@bjorn
Copy link
Member

bjorn commented Feb 18, 2013

@parasyte Arg, how very annoying. That is indeed a different and rather more severe bug. Could you tell me the Qt version (listed in Help -> About Qt) that was used for both 0.8.1 and 0.9.0? I'm afraid we may have to open an issue about this on the Qt bug tracker...

@parasyte
Copy link

@bjorn Thanks!

0.8.1 uses Qt 4.7.4
0.9.0 uses Qt 4.8.4

@bjorn bjorn changed the title Moving Map sometimes doesn't repaint correctly. Moving map sometimes doesn't repaint correctly May 8, 2014
@andykorth
Copy link

This also seems to be an issue in Tiled 0.9.1, using Qt 4.8.5 on OS X 10.9.4. OpenGL mode does seem to work well for me, though.

@bjorn
Copy link
Member

bjorn commented Jul 31, 2014

@andykorth Please try whether it's better with a daily build of Tiled that is built against Qt 5.3 (though there are new issues with OpenGL, so you may want to turn that off again for this version).

@andykorth
Copy link

@bjorn Ooh, it does seem to be fixed in Tiled 2014-06-15. Thanks! (which reports Qt 5.3.0)

@mhuggins
Copy link

mhuggins commented Aug 3, 2014

+1, just downloaded Tiled from the website last night and I'm seeing this issue. (Tiled 0.9.1, QT 4.8.5)

@mhuggins
Copy link

mhuggins commented Aug 3, 2014

Update based upon the comments above...realized I could turn on OpenGL mode, and that fixes the issue.

@cjke
Copy link

cjke commented Oct 23, 2015

@bjorn I am still experiencing this issue on build 0.14.2. I'm on a Mac running El Capitan. I have included a few screenshots. Oddly, I can't turn on OpenGL mode.

I'm not sure of the Qt version, it doesn't seem to be an available option in Help anymore. This is on a fresh install of Tiled.

screenshot 2015-10-23 23 33 07
screenshot 2015-10-23 23 33 30

@bjorn
Copy link
Member

bjorn commented Oct 23, 2015

@bjorn I am still experiencing this issue on build 0.14.2. I'm on a Mac running El Capitan. I have included a few screenshots. Oddly, I can't turn on OpenGL mode.

Yeah, unfortunately this is almost certainly a bug on the Qt side. A simple example application demonstrating the issue may help to get it fixed, but unfortunately this part of Qt has been rather unmaintained in the past years. The issue did get a lot less severe than the initial bug seen in the screenshots posted by @parasyte, right?

You can't turn on OpenGL because I disabled it on OS X. There is no version of Qt 5 where OpenGL has worked in any usable way (see for example issue #529).

I'm not sure of the Qt version, it doesn't seem to be an available option in Help anymore. This is on a fresh install of Tiled.

Right, I thought it was not important enough to have its own menu item, but I should probably at least put the Qt version into the About dialog. In any case I'm sure it's Qt 5.5.0.

@cjke
Copy link

cjke commented Oct 24, 2015

Thanks @bjorn for the quick reply.

The severity seems on par with that shown by @parasyte I would say.

Makes sense to have it disabled, and makes equal sense for Qt to not have a menu anymore - I was only wanting to include it to make sure my issue was complete.

It's a shame that it's a bug with the underlying framework, but it's tolerable. Thanks again, and amazing product! Goodluck with the patreon support.

@bjorn
Copy link
Member

bjorn commented Jun 20, 2021

I've created a small example application that reproduces this issue, which confirms it's an issue in Qt:

#include <QApplication>
#include <QGraphicsRectItem>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include <cmath>

class Scene : public QGraphicsScene
{
public:
    /**
     * Sets up the scene with a "canvas" and a "cursor".
     */
    Scene()
    {
        addRect(QRectF(0, 0, 1024, 1024));
        cursor = addRect(QRectF(0, 0, 32, 32), QPen(), Qt::lightGray);
    }

protected:
    /**
     * Changes the position of the cursor to stay below the mouse, snapped to a
     * virtual grid.
     *
     * Changing the position of an item in response to a mouse event is
     * normally not a problem, but it causes visible repainting issues when
     * that mouse move event was generated due to handling a mouse wheel event.
     *
     * The snapping is necessary in triggering the issue, because otherwise the
     * item position on the screen would not change at all while scrolling.
     */
    void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) override
    {
        auto snapped = mouseEvent->scenePos() / 32;
        snapped.setX(std::floor(snapped.x()));
        snapped.setY(std::floor(snapped.y()));
        cursor->setPos(snapped * 32);

        QGraphicsScene::mouseMoveEvent(mouseEvent);
    }

private:
    QGraphicsRectItem *cursor;
};

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    Scene scene;

    QGraphicsView view;
    view.setScene(&scene);
    view.viewport()->setMouseTracking(true);
    view.resize(256, 256);  // make sure the view can be scrolled with wheel
    view.show();

    return a.exec();
}

Zipped up together with a project file: repaintbug.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior. qt issue Qt related issue.
Projects
None yet
Development

No branches or pull requests

7 participants