Skip to content

Commit

Permalink
use of smartpointer mTranslator
Browse files Browse the repository at this point in the history
for better handling if loaded (or in our case existent) or not...
  • Loading branch information
signedav committed Aug 7, 2018
1 parent 090db0d commit 283b1b4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/app/qgsprojectproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
cbtsLocale->addItem( QIcon( QString( ":/images/flags/%1.svg" ).arg( QStringLiteral( "en_US" ) ) ), QLocale( QStringLiteral( "en_US" ) ).nativeLanguageName(), QStringLiteral( "en_US" ) );
cbtsLocale->setCurrentIndex( cbtsLocale->findData( settings.value( QStringLiteral( "locale/userLocale" ), QString() ).toString() ) );

connect( generateTsFileButton, &QPushButton::clicked, this, &QgsProjectProperties::generateTsFileButton_clicked );
connect( generateTsFileButton, &QPushButton::clicked, this, &QgsProjectProperties::onGenerateTsFileButton );

projectionSelectorInitialized();
populateRequiredLayers();
Expand Down Expand Up @@ -2214,7 +2214,7 @@ void QgsProjectProperties::setCurrentPage( const QString &pageWidgetName )
}
}

void QgsProjectProperties::generateTsFileButton_clicked()
void QgsProjectProperties::onGenerateTsFileButton()
{
QString l = cbtsLocale->currentData().toString();
QgsProject::instance()->generateTsFile( l );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsprojectproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
void scaleItemChanged( QListWidgetItem *changedScaleItem );

//! generate the ts file with the locale selected in the checkbox
void generateTsFileButton_clicked();
void onGenerateTsFileButton();

/**
* Set WMS default extent to current canvas extent
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ bool QgsProject::read()
else
{
//but delete the translator
delete mTranslator;
mTranslator.reset( nullptr );
}

return rc;
Expand All @@ -1010,7 +1010,7 @@ bool QgsProject::readProjectFile( const QString &filename )

if ( QFile( QStringLiteral( "%1/%2.qm" ).arg( QFileInfo( projectFile.fileName() ).absolutePath(), localeFileName ) ).exists() )
{
mTranslator = new QTranslator();
mTranslator.reset( new QTranslator() );
if ( mTranslator->load( localeFileName, QFileInfo( projectFile.fileName() ).absolutePath() ) )
{
QgsDebugMsg( "Translation loaded" );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera

QgsProjectMetadata mMetadata;

QTranslator *mTranslator = nullptr;
std::unique_ptr< QTranslator > mTranslator;

friend class QgsProjectDirtyBlocker;

Expand Down

0 comments on commit 283b1b4

Please sign in to comment.