[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Fri Jun 4 19:48:05 CEST 2004


CVS commit by arwalker: 

Fixed a couple of FIXMEs.

Now correctly delete the windows when closing Kst and close all open windows when opening a new document.


  M +40 -9     kstdoc.cpp   1.80


--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.79:1.80
@@ -466,4 +466,7 @@ bool KstDoc::saveDocument(const QString 
 
 void KstDoc::deleteContents() {
+  KMdiIterator<KMdiChildView*>* pIterator;
+  KstViewWindow* pView;
+
   KST::vectorDefaults.sync();
 
@@ -472,6 +475,17 @@ void KstDoc::deleteContents() {
   KST::filterSetList.lock().writeUnlock();
 
-// FIXMEPLOTLIST
-//  KST::plotList.clear();
+  if (KstApp::inst()) {
+    pIterator = KstApp::inst()->createIterator();
+    if (pIterator) {
+      while (pIterator->currentItem()) {
+        pView = dynamic_cast<KstViewWindow*>(pIterator->currentItem());
+        if (pView) {
+          pView->close( );
+        }
+        pIterator->next();
+      }
+      KstApp::inst()->deleteIterator(pIterator);
+    }
+  }
 
   KST::vectorList.lock().writeLock();
@@ -691,11 +705,26 @@ void KstDoc::forceUpdate() {
 
 bool KstDoc::event(QEvent *e) {
+  KMdiIterator<KMdiChildView*>* pIterator;
+  KstViewWindow* pView;
+
   if (e->type() == KstEventTypeThread) {
     ThreadEvent *te = static_cast<ThreadEvent*>(e);
     if (te->_eventType == ThreadEvent::UpdateDialogs) {
       kdDebug() << "Update dialogs" << endl;
-      //KstView *view = static_cast<KstApp*>(parent())->viewObject();
-      //view->update();
-      // FIXME
+
+      if (KstApp::inst()) {
+        pIterator = KstApp::inst()->createIterator();
+        if (pIterator) {
+          while (pIterator->currentItem()) {
+            pView = dynamic_cast<KstViewWindow*>(pIterator->currentItem());
+            if (pView) {
+              pView->view()->update( );
+            }
+            pIterator->next();
+          }
+          KstApp::inst()->deleteIterator(pIterator);
+        }
+      }
+
       updateDialogs();
     } else if (te->_eventType == ThreadEvent::Done) {
@@ -810,12 +839,14 @@ static bool backupFile(const QString& qF
        if (n == -1)
        {
-          if (errno == EINTR)
+          if (errno == EINTR) {
               continue;
+          }
           ::close(fd);
           ::close(fd2);
           return false;
        }
-       if (n == 0)
+       if (n == 0) {
           break; // Finished
+       }
 
        if (write_all( fd2, buffer, n))





More information about the Kst mailing list