Announcement

Collapse
No announcement yet.

There's something weird about this source code...

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    There's something weird about this source code...

    Actually I found this app the other day after a amateur game developer suggested this was a good open source choice to handling game maps. It's called Tiled, that's because we are supposed to work on sprite tiles anyway.

    Here's the link to the Tiled developers' website.

    On the right hand side just below both app screenshots you'll find the download links to the source code and the DEB file.

    When I installed it on my Kubuntu box I immediately noticed something weird. The menus as well as the tiles tab on the right hand side were displayed incorrectly, meaning they were completely distorted. It's the only app where I've seen such an serious issue right away and it makes it more complicated to create the game maps. I wonder if any of you could tell me what the developer did wrong and where and suggest something so I can "fix it" somehow especially since I downloaded the source code and tried to build it on my own and nothing changed.

    I know, some people might say that I should file a report, I did that but I'd like to know what was wrong since I'm interested specifically in the Qt framework.
    Multibooting: Kubuntu Jammy 22.04
    Before: Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
    Win / & 10 sadly
    Using Linux since June, 2008

    #2
    Re: There's something weird about this source code...

    At first glance it looks like some pointer confusion in Tilesetview.cpp, in this function, with the reuse of the "header" pointer:
    TilesetView::TilesetView(MapDocument *mapDocument, QWidget *parent)
    : QTableView(parent)
    , mZoomable(new Zoomable(this))
    , mMapDocument(mapDocument)
    {
    setHorizontalScrollMode(QAbstractItemView::ScrollP erPixel);
    setVerticalScrollMode(QAbstractItemView::ScrollPer Pixel);
    setItemDelegate(new TileDelegate(this));
    setShowGrid(false);

    QHeaderView *header = horizontalHeader();
    header->hide();
    header->setResizeMode(QHeaderView::ResizeToContents);
    header->setMinimumSectionSize(1);

    header = verticalHeader();
    header->hide();
    header->setResizeMode(QHeaderView::ResizeToContents);
    header->setMinimumSectionSize(1);

    connect(mZoomable, SIGNAL(scaleChanged(qreal)), SLOT(adjustScale()));
    }
    "header" holds the address of the value pointed to by the pointer "*header".
    Try "*header = verticalHeader();"

    I've only looked at the code by opening it up in Ark because I haven't vetted the source code and I try to avoid installing unvetted code from non-repository sites. Also, I am going out of town today won't be back online till I get back.
    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
    – John F. Kennedy, February 26, 1962.

    Comment


      #3
      Re: There's something weird about this source code...

      like GG I am just glancing, so take with a grain of salt. The code dealing with the headers is fine. Both verticalHeader and horizontalHeader (inherited from QTableView) return pointers. I think the previously described change will cause an error when compiled.

      Code:
      TilesetView::TilesetView(MapDocument *mapDocument, QWidget *parent)
        : QTableView(parent)
        , mZoomable(new Zoomable(this))
        , mMapDocument(mapDocument)
      {
      ...
      }
      I don't think the line with mZoomable(new Zoomable(this)) is "correct". It is creating a dynamically allocated object and then passing it as a QObject parent to another Zoomable object. The parent hierarchy looks correct so Qt garbage collector should delete everything and prevent a memory leak, but coding like this will lead to memory leaks. The line should be mZoomable(this) or mZoomable should be made a pointer and a line inside the constructor should be added assigning the pointer to a new object like:
      mZoomable = new(Zoomable(this)); The readme file talks about the app/library written originally in java and have since moved to c++ qt. So I am guessing the guys are going through some growing pains.

      now is any of this the source of your problem? who knows. If you want to know what the fix is (when it comes),

      1) erase the source code you downloaded before.
      2) terminal sudo apt-get install git-core.
      3) make a directory somewhere that will take the source code again.
      4) terminal (inside of new directory) git clone git://gitorious.org/tiled/tiled-qt.git
      5) terminal git log will show the history of the project.
      6) find the commit that makes the fix (when it's there) and git diff "previous fix commit" "fix commit"
      example: git diff bac451940a385c9af16f50735676844dc37f91d4 b054d686775aa339e112ec540b69d46164e0552f

      http://gitorious.org/tiled/
      http://github.com/guides/git-cheat-sheet
      FKA: tanderson

      Comment


        #4
        Re: There's something weird about this source code...

        Tanderson is right, my "quick glance" was too quick!

        I downloaded the code and loaded it into QtCreator, which is using Qt 4.6.3 from the qtsdk-2010.3.
        It compiled without errors. Also, it worked and displayed without distortions or errors on this 64bit platform running KDE 4.4.5. See the attached graph.
        Attached Files
        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
        – John F. Kennedy, February 26, 1962.

        Comment


          #5
          Re: There's something weird about this source code...

          I wonder if the desktop file included some command line argument like:

          Code:
          tiled -graphicssytem native
          I found that after reading the main.cpp file and found out that the distortion quickly disappeared. As someone suggested in tiled IRC channel, I had to disable OpenGL to make it display menus properly with the native alternative.

          BTW it's also available in the repositories AFAIK, no wait, I think I previously added the repos, sorry! At least I'm completely sure it's in Debian sid repos and thus also available for sidux.
          Multibooting: Kubuntu Jammy 22.04
          Before: Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
          Win / & 10 sadly
          Using Linux since June, 2008

          Comment

          Working...
          X