Bug report #6243
QgsProject.read() should open a project file in "append" mode
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Project Loading/Saving | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | invalid |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 15550 |
Description
QgsProject API Documentation states:
bool read (QFileInfo const &file)
read project file
bool read ()
presuming that the caller has already reset the map canvas, map registry, and legend
the first read (QFileInfo const &file) sets the project filename and calls the second read (). As you read, it says: "presuming that the caller has already reset the map canvas, map registry, and legend", so I wanted to use it to append my QGIS project file to current.
But it doesn't happen: current maplayers are cleared and substituted to the layers of the project file, althrough I still see the old project title in the window titlebar.
Here's how you can reproduce it:
- write a plugin with this code:
QgsProject.instance().read ( new QFileInfo ( "<path of a qgis file>" ) );
- open a different qgis project file
- launch the plugin
- all layers are substituted.
History
#1 Updated by Paolo Cavallini about 12 years ago
- Target version changed from Version 1.8.0 to Version 2.0.0
#2 Updated by Sandro Santilli about 12 years ago
I'm also looking for a way to "append" layers to an existing project. Ideally all under a group named after the file.
#3 Updated by Sandro Santilli about 12 years ago
The code is intentionally clearing all stuff, surely for project properties but don't know if for anything else too (assets referenced by layers?):
// before we start loading everything, let's clear out the current set of // properties first so that we don't have the properties from the previous // project still hanging around imp_->clear(); mEmbeddedLayers.clear();
#4 Updated by Giovanni Manghi almost 12 years ago
- Priority changed from High to Normal
#5 Updated by luca76 - over 10 years ago
- Target version changed from Version 2.0.0 to Future Release - Lower Priority
#6 Updated by Alexander Bruy over 10 years ago
- Category changed from C++ Plugins to Project Loading/Saving
#7 Updated by luca76 - over 8 years ago
- Resolution set to invalid
- Status changed from Open to Closed