Skip to content

Extent not updated when adding features in a memory layer #64497

@strokovnjaka

Description

@strokovnjaka

What is the bug or the crash?

In a memory layer, when features are added with lyr.dataProvider().addFeatures(ftrs) extent is not updated.

Steps to reproduce the issue

In a memory layer, when features are added with

lyr.dataProvider().truncate()
lyr.dataProvider().addFeatures(ftrs)
lyr.triggerRepaint()

they are rendered ok on map (provided map is zoomed appropriately). But, a call to

lyr.extent()

returns previous extent, e.g. on a new layer a (0 0, 0 0) extent.

A correctly updated extent is returned if you first either

  • select the lyr in Layers and click Zoom to Layer command, or
  • call lyr.reload()

Versions

QGIS version3.44.0-Solothurn
QGIS code revision5d9ba037df1
 
Libraries
Qt version5.15.13
Python version3.12.11
GDAL version3.11.0 (Compiled)
3.11.1 (Running) — Eganville
PROJ version9.6.2
EPSG Registry database versionv12.013 (2025-05-26)
GEOS version3.13.1-CAPI-1.19.2
SQLite version3.46.1
PDAL version2.9.0
PostgreSQL client version17.3
SpatiaLite version5.1.0
QWT version6.3.0
QScintilla2 version2.14.1
OS versionWindows 11 Version 2009
 
Active Python plugins
ONaNiNO-dev#26bc963 on docked
plugin_reloader0.18
db_manager0.1.20
MetaSearch0.3.6
processing2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEither a bug report, or a bug fix. Let's hope for the latter!FeedbackWaiting on the submitter for answers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions