Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually entered "layer name" never cleared #28858

Closed
qgib opened this issue Jan 20, 2019 · 6 comments · Fixed by #47087
Closed

Manually entered "layer name" never cleared #28858

qgib opened this issue Jan 20, 2019 · 6 comments · Fixed by #47087
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! WMS data provider

Comments

@qgib
Copy link
Contributor

qgib commented Jan 20, 2019

Author Name: Jonathan Moules (Jonathan Moules)
Original Redmine Issue: 21039
Affected QGIS version: 3.4.3
Redmine category:web_services_clients/wms


I entered a "layer name" on the WMS layer dialog (very bottom box). Now, no matter which WMS layer I select, it always has that same "layer name" showing, and every layer I add uses that QGIS layer name.

Even if I start a completely new project, it remembers my old "layer name", let along when I simply close and re-open the WMS dialog. The only way to

The only way to clear it is either to restart QGIS entirely, or manually delete everything from the field.

I'd suggest it should be reset when a new layer is selected.

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers labels May 25, 2019
@Pedro-Murteira
Copy link

Still true on QGIS 3.16.14 and 3.22.1.

@landryb
Copy link
Contributor

landryb commented Jan 28, 2022

ok, #40421 was closed as a duplicate of this issue, but still, this behaviour is infuriating... :)

User experience:

  • i load a wms server, add some layers, each with their own name provided by the server - all is fine
  • at one point, only once, i need to add a new wms layer with a different/manually entered name (say, add 'prod' or 'dev' to compare layers from distinct servers, or 'jpg'/'png' to compare two renderings)
  • from that point, the name i've manually entered/edited will be kept forever in the layer name field until qgis is closed, whatever the number of times i'll reopen the 'add wms layer' dialog, selecting another wms server, clicking on other layers with completely different names/content.

@landryb
Copy link
Contributor

landryb commented Jan 28, 2022

looking at the code, from my understanding of https://github.com/qgis/QGIS/blob/master/src/providers/wms/qgswmssourceselect.cpp#L989 to 'fix' this strange behaviour i'd remove mLastLayerName handlinh completely and directly update leLayerName. That would actually simplify the code, while still allowing to manually edit the layer name before adding it ? I'll test that locally.

@elpaso, since you commented on #40421, what do you think about it ?

@landryb
Copy link
Contributor

landryb commented Jan 28, 2022

diff --git a/src/providers/wms/qgswmssourceselect.cpp b/src/providers/wms/qgswmssourceselect.cpp
index 68e0487532..4d8da4b5b2 100644
--- a/src/providers/wms/qgswmssourceselect.cpp
+++ b/src/providers/wms/qgswmssourceselect.cpp
@@ -986,30 +986,28 @@ void QgsWMSSourceSelect::updateButtons()
     }
   }
 
-  if ( leLayerName->text().isEmpty() || leLayerName->text() == mLastLayerName )
+  if ( leLayerName->text().isEmpty() )
   {
     if ( addButton()->isEnabled() )
     {
       if ( !lstTilesets->selectedItems().isEmpty() )
       {
         QTableWidgetItem *item = lstTilesets->selectedItems().first();
-        mLastLayerName = item->data( Qt::UserRole + 5 ).toString();
-        if ( mLastLayerName.isEmpty() )
-          mLastLayerName = item->data( Qt::UserRole + 0 ).toString();
-        leLayerName->setText( mLastLayerName );
+        QString tileLayerName = item->data( Qt::UserRole + 5 ).toString();
+        if ( tileLayerName.isEmpty() )
+          tileLayerName = item->data( Qt::UserRole + 0 ).toString();
+        leLayerName->setText( tileLayerName );
       }
       else
       {
         QStringList layers, styles, titles;
         collectSelectedLayers( layers, styles, titles );
-        mLastLayerName = titles.join( QLatin1Char( '/' ) );
-        leLayerName->setText( mLastLayerName );
+        leLayerName->setText( titles.join( QLatin1Char( '/' ) );
       }
     }
     else
     {
-      mLastLayerName.clear();
-      leLayerName->setText( mLastLayerName );
+      leLayerName->setText( "" );
     }
   }
 }
diff --git a/src/providers/wms/qgswmssourceselect.h b/src/providers/wms/qgswmssourceselect.h
index 739a5d18af..12604f79a4 100644
--- a/src/providers/wms/qgswmssourceselect.h
+++ b/src/providers/wms/qgswmssourceselect.h
@@ -160,9 +160,6 @@ class QgsWMSSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsWM
     //! URI for selected connection
     QgsDataSourceUri mUri;
 
-    //! layer name derived from latest layer selection (updated as long it's not edited manually)
-    QString mLastLayerName;
-
     //! The widget that controls the image format radio buttons
     QButtonGroup *mImageFormatGroup = nullptr;
 

a bit crude but you get the idea.

@gioman
Copy link
Contributor

gioman commented Jan 28, 2022

a bit crude but you get the idea.

@landryb better post the patch as a Pull Request, otherwise is likely no one will ever review it.

@landryb
Copy link
Contributor

landryb commented Jan 28, 2022

sure, i'll do a PR once i've locally tested a patch :)

edit: had tried a distinct patch but the layer name field isnt updated at all once set, will have to rethink it and retry differently.

landryb added a commit to landryb/QGIS that referenced this issue Mar 23, 2022
previously, if the layer title was manually modified, it would never get
updated anymore until qgis was restarted.

Fixes qgis#28858 qgis#40421
qgis-bot pushed a commit that referenced this issue Mar 23, 2022
previously, if the layer title was manually modified, it would never get
updated anymore until qgis was restarted.

Fixes #28858 #40421
qgis-bot pushed a commit that referenced this issue Mar 23, 2022
previously, if the layer title was manually modified, it would never get
updated anymore until qgis was restarted.

Fixes #28858 #40421
benoitdm-oslandia pushed a commit to benoitdm-oslandia/QGIS that referenced this issue Mar 28, 2022
previously, if the layer title was manually modified, it would never get
updated anymore until qgis was restarted.

Fixes qgis#28858 qgis#40421
nyalldawson pushed a commit that referenced this issue Apr 17, 2022
previously, if the layer title was manually modified, it would never get
updated anymore until qgis was restarted.

Fixes #28858 #40421
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! WMS data provider
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants