This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[Kourse 3] Fixing krazy2 issues

Tags: None
(comma "," separated)
User avatar
msoeken
Mentor
Posts
300
Karma
4
OS

RE: [Kourse 3] Fixing krazy2 issues

Wed Jan 21, 2009 7:18 am
bruno wrote:
Code: Select all
Index: lancelot/app/src/models/OpenDocuments.cpp
===================================================================
--- lancelot/app/src/models/OpenDocuments.cpp   (révision 913851)
+++ lancelot/app/src/models/OpenDocuments.cpp   (copie de travail)
@@ -110,11 +110,10 @@
     Q_ASSERT(task);

     // kDebug() className() classClass();
-    QRegExp * extractor = NULL;
+    const QRegExp * extractor = NULL;
     QString className = task->className();

-    SupportedTask st;
-    foreach (st, m_supportedTasks) {
+    foreach (const SupportedTask &st, m_supportedTasks) {
         if (st.m_classPattern.exactMatch(task->className())) {
             extractor = & st.m_documentNameExtractor;
             break;


[ 72%] Building CXX object applets/lancelot/app/src/CMakeFiles/plasma_applet_lancelot_part.dir/models/OpenDocuments.o
/home/kdesvn/kdesvn/kdeplasma-addons/applets/lancelot/app/src/models/OpenDocuments.cpp: In member function ‘bool Models::OpenDocuments::setDataForTask(TaskManager::TaskPtr)’:
/home/kdesvn/kdesvn/kdeplasma-addons/applets/lancelot/app/src/models/OpenDocuments.cpp:138: erreur: passing ‘const QRegExp’ as ‘this’ argument of ‘QString QRegExp::cap(int)’ discards qualifiers
/home/kdesvn/kdesvn/kdeplasma-addons/applets/lancelot/app/src/models/OpenDocuments.cpp:139: erreur: passing ‘const QRegExp’ as ‘this’ argument of ‘QString QRegExp::cap(int)’ discards qualifiers
/home/kdesvn/kdesvn/kdeplasma-addons/applets/lancelot/app/src/models/OpenDocuments.cpp: In member function ‘bool Models::OpenDocuments::setDataForTask(TaskManager::TaskPtr)’:
/home/kdesvn/kdesvn/kdeplasma-addons/applets/lancelot/app/src/models/OpenDocuments.cpp:138: erreur: passing ‘const QRegExp’ as ‘this’ argument of ‘QString QRegExp::cap(int)’ discards qualifiers
/home/kdesvn/kdesvn/kdeplasma-addons/applets/lancelot/app/src/models/OpenDocuments.cpp:139: erreur: passing ‘const QRegExp’ as ‘this’ argument of ‘QString QRegExp::cap(int)’ discards qualifiers
make[2]: *** [applets/lancelot/app/src/CMakeFiles/lancelot-menu.dir/models/OpenDocuments.o] Erreur 1



Ok, it does not work ;) I am suggesting to use SupportedTask& as a reference but not const. There are good reasons to do it and perhaps you should put a krazy2 ignore comment on that line.


Image
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size]
bruno
KDE Developer
Posts
40
Karma
0
OS

RE: [Kourse 3] Fixing krazy2 issues

Wed Jan 21, 2009 7:25 am
msoeken wrote:Ok, it does not work ;) I am suggesting to use SupportedTask& as a reference but not const. There are good reasons to do it and perhaps you should put a krazy2 ignore comment on that line.


What if extractor shouldn't be a pointer?

Code: Select all
Index: lancelot/app/src/models/OpenDocuments.cpp
===================================================================
--- lancelot/app/src/models/OpenDocuments.cpp   (révision 913851)
+++ lancelot/app/src/models/OpenDocuments.cpp   (copie de travail)
@@ -110,17 +110,16 @@
     Q_ASSERT(task);

     // kDebug() className() classClass();
-    QRegExp * extractor = NULL;
+    QRegExp extractor;
     QString className = task->className();

-    SupportedTask st;
-    foreach (st, m_supportedTasks) {
+    foreach (const SupportedTask &st, m_supportedTasks) {
         if (st.m_classPattern.exactMatch(task->className())) {
-            extractor = & st.m_documentNameExtractor;
+            extractor = st.m_documentNameExtractor;
             break;
         }
     }
-    if (extractor == NULL) {
+    if (extractor.isEmpty()) {
         return false;
     }

@@ -135,9 +134,9 @@

     QString title = task->visibleName();
     QString description;
-    if (extractor->exactMatch(title)) {
-        title = extractor->cap(1);
-        description = extractor->cap(2);
+    if (extractor.exactMatch(title)) {
+        title = extractor.cap(1);
+        description = extractor.cap(2);
     }

     QIcon icon = QIcon(task->icon(32, 32));


bruno, proud to be a member of KDE forums since 2008-Oct.
User avatar
msoeken
Mentor
Posts
300
Karma
4
OS

RE: [Kourse 3] Fixing krazy2 issues

Thu Jan 22, 2009 7:02 am
bruno wrote:
msoeken wrote:Ok, it does not work ;) I am suggesting to use SupportedTask& as a reference but not const. There are good reasons to do it and perhaps you should put a krazy2 ignore comment on that line.


What if extractor shouldn't be a pointer?

Code: Select all
Index: lancelot/app/src/models/OpenDocuments.cpp
===================================================================
--- lancelot/app/src/models/OpenDocuments.cpp   (révision 913851)
+++ lancelot/app/src/models/OpenDocuments.cpp   (copie de travail)
@@ -110,17 +110,16 @@
     Q_ASSERT(task);

     // kDebug() className() classClass();
-    QRegExp * extractor = NULL;
+    QRegExp extractor;
     QString className = task->className();

-    SupportedTask st;
-    foreach (st, m_supportedTasks) {
+    foreach (const SupportedTask &st, m_supportedTasks) {
         if (st.m_classPattern.exactMatch(task->className())) {
-            extractor = & st.m_documentNameExtractor;
+            extractor = st.m_documentNameExtractor;
             break;
         }
     }
-    if (extractor == NULL) {
+    if (extractor.isEmpty()) {
         return false;
     }

@@ -135,9 +134,9 @@

     QString title = task->visibleName();
     QString description;
-    if (extractor->exactMatch(title)) {
-        title = extractor->cap(1);
-        description = extractor->cap(2);
+    if (extractor.exactMatch(title)) {
+        title = extractor.cap(1);
+        description = extractor.cap(2);
     }

     QIcon icon = QIcon(task->icon(32, 32));



Now we call the copy constructor on QRegExp, but it looks like the best solution for now.


Image
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size]
User avatar
msoeken
Mentor
Posts
300
Karma
4
OS

RE: [Kourse 3] Fixing krazy2 issues

Thu Jan 22, 2009 7:05 am
I will now close this kourse. Thanks to all students for their great work. Many patches have been send and so many krazy2 issues could have been fixed. Hopefully you could learned something about krazy2, sending patches and registering to mailing lists. I know that some of you got a svn account after sending some krazy2 patches. If you want to give some feedback (good and bad) to this kourse, feel free to reply it to the discussion thread.

Cheers, m.

Last edited by msoeken on Thu Jan 22, 2009 10:19 am, edited 1 time in total.


Image
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kesang, Sogou [Bot], Yahoo [Bot]