[Ktutorial-commits] SF.net SVN: ktutorial:[115] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-03-06 22:53:00
|
Revision: 115
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=115&view=rev
Author: danxuliu
Date: 2010-03-06 22:52:52 +0000 (Sat, 06 Mar 2010)
Log Message:
-----------
Fix crash when an empty string or a spaces only string is converted to lowerCamelCase.
Modified Paths:
--------------
trunk/ktutorial/ktutorial-editor/src/Tutorial.cpp
trunk/ktutorial/ktutorial-editor/tests/unit/TutorialTest.cpp
Modified: trunk/ktutorial/ktutorial-editor/src/Tutorial.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/Tutorial.cpp 2010-03-06 20:52:29 UTC (rev 114)
+++ trunk/ktutorial/ktutorial-editor/src/Tutorial.cpp 2010-03-06 22:52:52 UTC (rev 115)
@@ -84,6 +84,10 @@
QString Tutorial::toLowerCamelCase(const QString& text) const {
QStringList words = text.split(' ', QString::SkipEmptyParts);
+ if (words.count() == 0) {
+ return "";
+ }
+
QString lowerCamelCase;
words[0][0] = words[0][0].toLower();
lowerCamelCase += words[0];
Modified: trunk/ktutorial/ktutorial-editor/tests/unit/TutorialTest.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/tests/unit/TutorialTest.cpp 2010-03-06 20:52:29 UTC (rev 114)
+++ trunk/ktutorial/ktutorial-editor/tests/unit/TutorialTest.cpp 2010-03-06 22:52:52 UTC (rev 115)
@@ -26,6 +26,8 @@
private slots:
void testId();
+ void testIdWithEmptyName();
+ void testIdWithSpaceName();
void testSetName();
@@ -46,6 +48,20 @@
QCOMPARE(tutorial.id(), QString("thENameOfATutoRial"));
}
+void TutorialTest::testIdWithEmptyName() {
+ Tutorial tutorial;
+ tutorial.setName("");
+
+ QCOMPARE(tutorial.id(), QString(""));
+}
+
+void TutorialTest::testIdWithSpaceName() {
+ Tutorial tutorial;
+ tutorial.setName(" ");
+
+ QCOMPARE(tutorial.id(), QString(""));
+}
+
//Tutorial* must be declared as a metatype to be used in qvariant_cast
Q_DECLARE_METATYPE(Tutorial*);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|