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

[Bug] Copying a page to another document moves images to layer 1000000 #1167

Open
qqqqqqqqq9 opened this issue Nov 20, 2024 · 5 comments
Open
Labels

Comments

@qqqqqqqqq9
Copy link

Describe the bug

Copying a page to another document moves images to layer 1000000

To Reproduce

  1. Create Doc 1.
  2. Add two images to the first page.
  3. Create Doc 2.
  4. Copy Page 1 of Doc 1 to Doc 2 by drag and drop.

Expected behavior

The images should be in Layer 1 and 2, respectively.

Actual behavior

The images are in Layer 1e+6.

Is there a way to move to a layer specific layer?
Doing so by clicking takes a looooong time.

Context

  • reproducibility : systematic
  • OpenBoard version :
    • bug happens with : 1.7.2
    • bug doesn't happen with : ``
    • didn't check : 1.6.4 1.7.0 1.7.1a-x.y.z
  • OS :
    • bug happens with : Linux
    • bug doesn't happen with :
    • didn't check : Windows macOS

I built from Source on opensuse using
https://aur.archlinux.org/packages/openboard
as template. (qt6)

Additional context

  • Linux : openSuSE Tumbleweed
@qqqqqqqqq9 qqqqqqqqq9 added the bug label Nov 20, 2024
@letsfindaway
Copy link
Collaborator

letsfindaway commented Nov 20, 2024

Thanks for reporting. I assume this bug is not new with 1.7.2, but here since many years.

You have the same effect when you even drag the page to the same document. However if I check the SVG files, I cannot see those strange z-values. The original page and the copy are identical besides the UUID of the page. And actually: when I close and re-open OpenBoard, then the z-values are ok!

My analysis:

  • Looking at the SVG files, the attribute is ub:z-value="-999999.000000" for the item which has actually z-value 1 and ub:z-value="-999998.000000" for the item which has actually z-value 2. There seems to be a offset of -1e6, for whatever reasons.
  • This seems to be intentionally, because I find lines like UBApplication::showMessage(QString::number(1000000 + newZValue)); when the z-value shall be displayed when pressing the up/down buttons.
  • I can also see that there are two places where the z-value is stored in the items:
    • The zValue property of the item, and
    • The UBGraphicsItemData::ItemOwnZValue data property of the item.
  • When a scene is copied by dragging it to a document in document mode, then a clone is created, which is then saved to the target document. This clone is also inserted to the scene cache and is used as long as OpenBoard is running and the cache is not full.
  • When cloning, the items zValue properties are copied, but the ItemOwnZValue data property is not.
  • Saving the document uses the zValue, so the saved document is correct.
  • But the layer up / down mechanism uses the ItemOwnZValue data property, which is uninitialized and therefore zero. Together with the 1000000 this shows up as 1e6 for all items.

So the fix should be in the clone function of the scene. We have to set the ItemOwnZValue data property. And in the longer term one should ask whether this duplication of information is actually needed. As we see here, this leads to confusion.

Edit and additional note: OpenBoard has several places where a scene is copied using different mechanisms. There is e.g. also a UBPersistenceManager::copyPage - currently restricted to make a copy in the same document. But here simply the SVG file is copied instead of copying and then saving the scene. This mechanism avoids that problem, as the copied scene is later read from disk and during that both z-value properties are corerctly set.

@letsfindaway
Copy link
Collaborator

letsfindaway commented Nov 20, 2024

@qqqqqqqqq9: just out of curiosity: why and how do you use the AUR package to build for Tumbleweed?

And BTW: 1.7.2 is now also in the official Tumbleweed repo! See https://software.opensuse.org/package/OpenBoard?search_term=openboard and here in the build service https://build.opensuse.org/package/show/openSUSE:Factory/OpenBoard for how the official package is built. This build also includes the patch from PR #1165 to mitigate bug #1164 and others for all Wayland users.

@qqqqqqqqq9
Copy link
Author

As to why

  • PKGBUILDs are bash and human-readable.
  • the AUR offers one for almost any software out there
  • the AUR is usually uptodate
  • if something fails, there's a comment section which often already has a solution.

As to how:
I install it into a folder and package that with fpm (https://fpm.readthedocs.io/en/latest/installation.html)
I first used it to keep track of my scripts and some config files.

Thanks for the hint with official packages.
Is there a way to customize the library? (e.g. add custom folders)
Why does the library not recognize symlinks?
Is that intentional?

@letsfindaway
Copy link
Collaborator

Thanks for the insights!!

As to how:
I install it into a folder and package that with fpm (https://fpm.readthedocs.io/en/latest/installation.html)
I first used it to keep track of my scripts and some config files.

Did you know that you could easily create a RPM package using cmake? See https://github.com/OpenBoard-org/OpenBoard/wiki/CMake-Build-System-for-Linux#package.

If you add this command cpack -G RPM to the PKGBUILD script or execute it afterwards, then you automatically get an rpm package of the build result.

Is there a way to customize the library? (e.g. add custom folders)
Why does the library not recognize symlinks?

This should probably go to another issue. When I find time I could write a Discussion topic about this. Short ansers: Customizing is limited. And symlinks? Not intentional. I have to test this.

@qqqqqqqqq9
Copy link
Author

qqqqqqqqq9 commented Nov 20, 2024

Thanks for the cpack hint.
For background on the library:
I'm migrating from activinspire. My data is organized by topic rather than filetype. Currently I bindmount the tree of the current topic under a subfolder of Movies. It works but is confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants