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

8251481: TableCell accessing row: NPE on auto-sizing #716

Closed

Conversation

Maran23
Copy link
Member

@Maran23 Maran23 commented Jan 14, 2022

This PR will fix a simple NPE which may happens when using the TableRow inside a TableCell during the initial auto sizing.
In the auto sizing code, no TableRow is set, therefore getTableRow() will return null and it is not possible to e.g. access the row item.

This is fixed by adding the TableRow in the resizeColumnToFitContent method, similar as it is already done for the TreeTableView (TreeTableRow).


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8251481: TableCell accessing row: NPE on auto-sizing

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/716/head:pull/716
$ git checkout pull/716

Update a local copy of the PR:
$ git checkout pull/716
$ git pull https://git.openjdk.java.net/jfx pull/716/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 716

View PR using the GUI difftool:
$ git pr show -t 716

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/716.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 14, 2022

👋 Welcome back mhanl! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Jan 14, 2022
@mlbridge
Copy link

mlbridge bot commented Jan 14, 2022

Webrevs

@kleopatra
Copy link
Collaborator

hmm .. I think here are two issues:

  • the auto-sizing code definitely needs to fully configure the cell (with index, row, column, tableView plus applying css) to measure the correct size
  • the implementation of cell.updateItem (even though it's my own ;) is a bit fishy: does its spec really guarantee that getTableRow() != null if !empty()? Meanwhile, I think that's not the case - but then, it's for demonstrating the first bullet :)

The first is fixed by this PR (looks good on first sight). The second might need a clarification in the method doc .. or not, undecided.

@Maran23
Copy link
Member Author

Maran23 commented Jan 14, 2022

hmm .. I think here are two issues:

  • the auto-sizing code definitely needs to fully configure the cell (with index, row, column, tableView plus applying css) to measure the correct size
  • the implementation of cell.updateItem (even though it's my own ;) is a bit fishy: does its spec really guarantee that getTableRow() != null if !empty()? Meanwhile, I think that's not the case - but then, it's for demonstrating the first bullet :)

The first is fixed by this PR (looks good on first sight). The second might need a clarification in the method doc .. or not, undecided.

Yes the auto sizing has some more issues.
While looking on it, I found two problems which should be done as follow-up:

  1. Both resizeColumnToFitContent methods do not use the row factory of the corresponding table (minor, but still something which should be improved here)
  2. Currently both implementation add the TableCell directly into the TableSkin, which is not how it is usually done. Normally the TableRow is added (by the VirtualFlow), therefore the example of the related ticket JDK-8251480 won't work after this fix, but may do when the TableRow is added instead (didn't tested it though)

May both can be addressed in future via JDK-8251480

Copy link
Collaborator

@kleopatra kleopatra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix looks good: verified that the bug example doesn't throw after the fix, also that the test failed/passed before/after the fix

left a couple of inline comments for the test

Copy link
Collaborator

@kleopatra kleopatra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good (there's one minor thingy in completely aligning the test for TreeTable)

@openjdk
Copy link

openjdk bot commented Jan 29, 2022

@Maran23 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8251481: TableCell accessing row: NPE on auto-sizing

Reviewed-by: fastegal

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 22 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@kleopatra) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Ready to be integrated label Jan 29, 2022
@openjdk openjdk bot removed the ready Ready to be integrated label Feb 1, 2022
Copy link
Collaborator

@kleopatra kleopatra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

@openjdk openjdk bot added the ready Ready to be integrated label Feb 2, 2022
@Maran23
Copy link
Member Author

Maran23 commented Feb 2, 2022

/integrate

@openjdk openjdk bot added the sponsor Ready to sponsor label Feb 2, 2022
@openjdk
Copy link

openjdk bot commented Feb 2, 2022

@Maran23
Your change (at version a706068) is now ready to be sponsored by a Committer.

@kleopatra
Copy link
Collaborator

/sponsor

@openjdk
Copy link

openjdk bot commented Feb 2, 2022

Going to push as commit 59cd8ec.
Since your change was applied there have been 22 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 2, 2022
@openjdk openjdk bot closed this Feb 2, 2022
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review sponsor Ready to sponsor labels Feb 2, 2022
@openjdk
Copy link

openjdk bot commented Feb 2, 2022

@kleopatra @Maran23 Pushed as commit 59cd8ec.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@Maran23 Maran23 deleted the 8251481-table-cell-npe-auto-sizing branch July 5, 2022 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
2 participants