Skip to content

Commit

Permalink
Fix creation of default composer names (fix #13339)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 11, 2015
1 parent 9251fae commit 8731065
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -2717,8 +2717,8 @@ void QgsComposer::on_mActionSaveProject_triggered()

void QgsComposer::on_mActionNewComposer_triggered()
{
QString title = mQgis->uniqueComposerTitle( this, true );
if ( title.isNull() )
QString title;
if ( !mQgis->uniqueComposerTitle( this, title, true ) )
{
return;
}
Expand All @@ -2727,8 +2727,8 @@ void QgsComposer::on_mActionNewComposer_triggered()

void QgsComposer::on_mActionDuplicateComposer_triggered()
{
QString newTitle = mQgis->uniqueComposerTitle( this, false, title() + tr( " copy" ) );
if ( newTitle.isNull() )
QString newTitle;
if ( !mQgis->uniqueComposerTitle( this, newTitle, false, title() + tr( " copy" ) ) )
{
return;
}
Expand Down Expand Up @@ -2827,8 +2827,8 @@ void QgsComposer::loadTemplate( const bool newComposer )

if ( newComposer )
{
QString newTitle = mQgis->uniqueComposerTitle( this, true );
if ( newTitle.isNull() )
QString newTitle;
if ( !mQgis->uniqueComposerTitle( this, newTitle, true ) )
{
return;
}
Expand Down
14 changes: 7 additions & 7 deletions src/app/composer/qgscomposermanager.cpp
Expand Up @@ -193,8 +193,8 @@ void QgsComposerManager::on_mAddButton_clicked()
QgsComposer* newComposer = 0;
bool loadedOK = false;

QString title = QgisApp::instance()->uniqueComposerTitle( this, true );
if ( title.isNull() )
QString title;
if ( !QgisApp::instance()->uniqueComposerTitle( this, title, true ) )
{
return;
}
Expand Down Expand Up @@ -255,7 +255,7 @@ void QgsComposerManager::on_mTemplatePathBtn_pressed()
tr( "Choose template" ),
lastTmplDir,
tr( "Composer templates" ) + " (*.qpt)" );
if ( !tmplPath.isNull() )
if ( !tmplPath.isEmpty() )
{
mTemplatePathLineEdit->setText( tmplPath );
settings.setValue( "UI/ComposerManager/templatePath", tmplPath );
Expand Down Expand Up @@ -420,8 +420,8 @@ void QgsComposerManager::duplicate_clicked()
return;
}

QString newTitle = QgisApp::instance()->uniqueComposerTitle( this, false, currentTitle + tr( " copy" ) );
if ( newTitle.isNull() )
QString newTitle;
if ( !QgisApp::instance()->uniqueComposerTitle( this, newTitle, false, currentTitle + tr( " copy" ) ) )
{
return;
}
Expand Down Expand Up @@ -469,8 +469,8 @@ void QgsComposerManager::rename_clicked()
{
return;
}
QString newTitle = QgisApp::instance()->uniqueComposerTitle( this, false, currentTitle );
if ( newTitle.isNull() )
QString newTitle;
if ( !QgisApp::instance()->uniqueComposerTitle( this, newTitle, false, currentTitle ) )
{
return;
}
Expand Down
12 changes: 7 additions & 5 deletions src/app/qgisapp.cpp
Expand Up @@ -4596,8 +4596,8 @@ void QgisApp::openFile( const QString & fileName )

void QgisApp::newPrintComposer()
{
QString title = uniqueComposerTitle( this, true );
if ( title.isNull() )
QString title;
if ( !uniqueComposerTitle( this, title, true ) )
{
return;
}
Expand Down Expand Up @@ -5695,7 +5695,7 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
return unionGeom;
}

QString QgisApp::uniqueComposerTitle( QWidget* parent, bool acceptEmpty, const QString& currentName )
bool QgisApp::uniqueComposerTitle( QWidget* parent, QString& composerTitle, bool acceptEmpty, const QString& currentName )
{
if ( !parent )
{
Expand Down Expand Up @@ -5729,7 +5729,7 @@ QString QgisApp::uniqueComposerTitle( QWidget* parent, bool acceptEmpty, const Q
&ok );
if ( !ok )
{
return QString::null;
return false;
}

if ( newTitle.isEmpty() )
Expand All @@ -5754,7 +5754,9 @@ QString QgisApp::uniqueComposerTitle( QWidget* parent, bool acceptEmpty, const Q
}
}

return newTitle;
composerTitle = newTitle;

return true;
}

QgsComposer* QgisApp::createNewComposer( QString title )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Expand Up @@ -256,7 +256,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* @param currentTitle base name for initial title choice
* @return QString::null if user cancels input dialog
*/
QString uniqueComposerTitle( QWidget *parent, bool acceptEmpty, const QString& currentTitle = QString() );
bool uniqueComposerTitle( QWidget *parent, QString& composerTitle, bool acceptEmpty, const QString& currentTitle = QString() );
/** Creates a new composer and returns a pointer to it*/
QgsComposer* createNewComposer( QString title = QString() );
/** Deletes a composer and removes entry from Set*/
Expand Down

0 comments on commit 8731065

Please sign in to comment.