[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdebase/ktip
From:       CVS by gebauer <kde-cvs () kde ! org>
Date:       2000-09-30 23:19:40
[Download RAW message or body]


kdebase/ktip ktipwindow.cpp,1.3,1.4
Author: gebauer
Sat Sep 30 23:19:40 UTC 2000

Modified Files:
	ktipwindow.cpp 
Log Message:
don't crash if no tips are found
(SIGFPE, qlistview assert())
the nextTip() is not necessary, there
is already one in newInstance() 

RCS file: /home/kde/kdebase/ktip/ktipwindow.cpp,v
retrieving revision 1.3
diff -u -3 -p -r1.3 ktipwindow.cpp
--- ktipwindow.cpp      2000/09/28 16:43:43     1.3
+++ ktipwindow.cpp      2000/09/30 23:16:38
@@ -106,13 +106,16 @@ TipWindow::TipWindow()

   loadTips();

-  current = kapp->random() % tips.count();
-
   KConfig *config = new KConfig("kdewizardrc", true);
   config->setGroup("General");
   startup->setChecked(config->readBoolEntry("TipsOnStart", true));

-  nextTip();
+  if (tips.count() != 0) {
+    current = kapp->random() % tips.count();
+  } else {
+    prev->setEnabled(false);
+    next->setEnabled(false);
+  }
 }
 
 
@@ -184,6 +187,8 @@ void TipWindow::loadTips()
 
 void TipWindow::nextTip()
 {
+  if (tips.count()==0)
+    return;
   current += 1;
   if (current >= (int) tips.count())
     current = 0;
@@ -193,6 +198,8 @@ void TipWindow::nextTip()
 
 void TipWindow::prevTip()
 {
+  if (tips.count()==0)
+    return;
   current -= 1;
   if (current < 0)
     current = tips.count()-1;    

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic