[vlmc-devel] [PATCH 2/2] project name should not contain special characters

Sanket Markan sanketmarkan at gmail.com
Thu Mar 17 10:55:43 CET 2016


problems may exist for instance adding / to project name make half of name a directory
---
 src/Gui/wizard/GeneralPage.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/Gui/wizard/GeneralPage.cpp b/src/Gui/wizard/GeneralPage.cpp
index da986ba..c1fc561 100644
--- a/src/Gui/wizard/GeneralPage.cpp
+++ b/src/Gui/wizard/GeneralPage.cpp
@@ -87,6 +87,7 @@ GeneralPage::validatePage()
     if ( m_valid == false )
         return false;
     const QString       &defaultProjectName = Project::unNamedProject;
+    QString invalid_char = "/?:*\\|";
     if ( ui.lineEditName->text().isEmpty() ||
          ui.lineEditName->text() == defaultProjectName )
     {
@@ -95,6 +96,14 @@ GeneralPage::validatePage()
         ui.lineEditName->setFocus();
         return false;
     }
+    for ( int i = 0; i < invalid_char.length() ; ++i )
+        if ( ui.lineEditName->text().contains( invalid_char[i] ) )
+        {
+            QMessageBox::information( this, tr( "Invalid project name" ),
+                                      tr( "Special characters are not allowed" ) );
+            ui.lineEditName->setFocus();
+            return false;
+        }
 
     //Create the project directory in the workspace dir.
     QString     projectPath = ui.lineEditName->text().replace( ' ', '_' );
-- 
1.9.1



More information about the Vlmc-devel mailing list