Skip to content

Commit

Permalink
Don't try to load missing cpt ramps, part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 20, 2022
1 parent 51abf19 commit a49f487
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/core/auto_generated/qgscolorrampimpl.sip.in
Expand Up @@ -826,6 +826,7 @@ Returns the string identifier for QgsCptCityColorRamp.
void loadPalette();
bool hasMultiStops() const;


QString fileName() const;
bool loadFile();
bool fileLoaded() const;
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgscolorrampimpl.cpp
Expand Up @@ -1016,6 +1016,10 @@ QVariantMap QgsCptCityColorRamp::properties() const
return map;
}

QString QgsCptCityColorRamp::fileNameForVariant( const QString &schema, const QString &variant )
{
return QgsCptCityArchive::defaultBaseDir() + QDir::separator() + schema + variant + ".svg";
}

QString QgsCptCityColorRamp::fileName() const
{
Expand Down
8 changes: 8 additions & 0 deletions src/core/qgscolorrampimpl.h
Expand Up @@ -773,6 +773,14 @@ class CORE_EXPORT QgsCptCityColorRamp : public QgsGradientColorRamp
void loadPalette() { loadFile(); }
bool hasMultiStops() const { return mMultiStops; }

/**
* Returns the source file name for a CPT \a schema and \a variant.
*
* \note Not available in Python bindings
* \since QGIS 3.28
*/
static QString fileNameForVariant( const QString &schema, const QString &variant ) SIP_SKIP;

QString fileName() const;
bool loadFile();
bool fileLoaded() const { return mFileLoaded; }
Expand Down
7 changes: 6 additions & 1 deletion src/core/symbology/qgscptcityarchive.cpp
Expand Up @@ -1190,7 +1190,12 @@ QVector<QgsCptCityDataItem *> QgsCptCitySelectionItem::createChildren()
}
else
{
// init item to test if is valid after loading file
const QString fileName = QgsCptCityColorRamp::fileNameForVariant( childPath, QString() );
if ( !QFile::exists( fileName ) )
{
continue;
}

item = new QgsCptCityColorRampItem( this, childPath, childPath, QString(), true );
if ( item->isValid() )
children << item;
Expand Down

0 comments on commit a49f487

Please sign in to comment.