Describe the bug
Feature count is removed and "Show Feature Count" is unchecked when layer is dragged in the legend and setCustomProperty("showFeatureCount", True) was used to show the feature count programmatically.
for (layer) in allLayers:
layer.setCustomProperty("showFeatureCount", True)
3. Open the context menu of the layer to verify "Show Feature Count" is checked
4. Drag and drop the layer in the legend
5. Feature count is removed and "Show Feature Count" is unchecked in the context menu
![lost_fc](https://user-images.githubusercontent.com/20856381/74233161-79df3f00-4cca-11ea-86a2-63080a8cdd95.gif)
**QGIS and OS versions**
QGIS version | 3.10.2-A Coruña | QGIS code revision | 616ad4531b
-- | -- | -- | --
Compiled against Qt | 5.11.3 | Running against Qt | 5.11.3
Compiled against GDAL/OGR | 2.4.0 | Running against GDAL/OGR | 2.4.0
Compiled against GEOS | 3.7.1-CAPI-1.11.1 | Running against GEOS | 3.7.1-CAPI-1.11.1 27a5e771
Compiled against SQLite | 3.27.2 | Running against SQLite | 3.27.2
PostgreSQL Client Version | 11.5 (Debian 11.5-1+deb10u1) | SpatiaLite Version | 4.3.0a
QWT Version | 6.1.4 | QScintilla2 Version | 2.10.4
Compiled against PROJ | 5.2.0 | Running against PROJ | Rel. 5.2.0, September 15th, 2018
OS Version | Debian GNU/Linux 10 (buster)
Active python plugins | ClipMultipleLayers; quick_map_services; scriptrunner3; LAStools; canvas_clipper; savedialog; loadthemall; kmltools; MapsPrinter; mmqgis; pluginbuilder3; vector_tiles_reader; layerGroupFilter; plugin_reloader; realcentroid; mask; MetaSearch; db_manager; processing
Additionally, once the feature count is lost in the legend after dragging a layer, it's not possible to make it appear again using PyQGIS (tested with 3.16.0):
Describe the bug Feature count is removed and "Show Feature Count" is unchecked when layer is dragged in the legend and
setCustomProperty("showFeatureCount", True)
was used to show the feature count programmatically.How to Reproduce
for (layer) in allLayers: layer.setCustomProperty("showFeatureCount", True)