[wms] Insure that mbtiles layers are invalidated when dataset is missing #56296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fixes an issue whereas passing a WMS mbtiles source with a blank url fails to flag the layer as invalid.
The reason this is happening is because sqlite won't error when opening an empty-string database. In turn, that wrongly informs the WMS provider that everything is fine (ouch).
The fix is to simply check for an empty filename when calling QgsMbTiles::open() and return false (failure to open) when that's the case.
As for when a WMS mbtiles layer gets a blank url, it will easily happen if the .mbtile file is in a localized path where the file has been moved or deleted. In that cause, prior to the PR, QGIS would create a valid WMS layer rendering nothingness :)