Skip to content

Change DEBUG to WARN log level when no primary selected object#2044

Merged
petebankhead merged 1 commit intoqupath:mainfrom
Rylern:warn-instead-of-debug
Dec 2, 2025
Merged

Change DEBUG to WARN log level when no primary selected object#2044
petebankhead merged 1 commit intoqupath:mainfrom
Rylern:warn-instead-of-debug

Conversation

@Rylern
Copy link
Contributor

@Rylern Rylern commented Nov 28, 2025

This script doesn't work:

selectObjectsByClassification("Tumour")
var roi = getSelectedROI()    // roi is null, even if a "Tumour" annotation exists

This is because there is a concept of "primary" selected object in the hierarchy:

  • selectObjectsByClassification("Tumour") select all objects with the Tumour pathclass, but doesn't set the primary selected object.
  • def roi = getSelectedROI() try to get the primary selected object. It doesn't exist, so roi is null.

This is not fundamentally a QuPath problem, because functions like selectObjectsBy...() should be followed by getSelectedObjects(), not getSelectedROI() or getSelectedObject(). However, this behaviour could be more explicit. Currently, getSelectedROI() is able to detect this specific situation and logs a message, but only with the DEBUG level. This PR converts it to a WARN message.

@petebankhead petebankhead merged commit 1a3d79d into qupath:main Dec 2, 2025
3 checks passed
@petebankhead petebankhead added this to the v0.7.0 milestone Dec 2, 2025
@Rylern Rylern deleted the warn-instead-of-debug branch December 2, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants