Bug 111570 - Change Data File's 'All From" should only include files that are currently in use.
Summary: Change Data File's 'All From" should only include files that are currently in...
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-26 18:06 UTC by Matthew Truch
Modified: 2005-09-30 17:25 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Truch 2005-08-26 18:06:59 UTC
Version:           1.2.0_devel (using KDE KDE 3.4.0)
OS:                Linux

Currently if you use Change Data File alot in an instance of kst, the All From list will become cluttered with files that are no longer in use, in addition to data files that are in use.  Furthermore, selecting a file that is no longer in use will select none of the vectors, making them useless to include in the list.  

Expected behavior: The 'All From' pull down in Change Data File only includes a list of files that are used by the vectors currently loaded, not past ones that are not in use.
Comment 1 George Staikos 2005-09-16 04:39:32 UTC
The reason the rest are listed is because they are cached (a sort of fly-weight pattern implementation).  We could remove the unused files from the combobox but I still want to keep them around in memory for performance reasons.
Comment 2 Nicolas Brisset 2005-09-16 09:23:18 UTC
Interesting. That problem also bugged me in the past, and I definitely second Matthew's suggestion to remove them from the list. Now, I have a question about the caching: what exactly is cached ? What would happen if I do the following:
- load a few vectors from file1.dat
- change the vectors to be read from file2.dat
- modify file1.dat (possibly including some changes to the list of fields, or reduction of number of samples)
- try to read vectors from file1.dat again.
Will the field list and sample numbers be updated correctly ?
Comment 3 Netterfield 2005-09-17 23:39:05 UTC
Perhaps we should reconsider this... some data sources (eg, ascii) can keep a 
fair amount of data around....  Maybe a 'purge files' type option?

> The reason the rest are listed is because they are cached (a sort of
> fly-weight pattern implementation).  We could remove the unused files from
> the combobox but I still want to keep them around in memory for performance
> reasons.

Comment 4 Andrew Walker 2005-09-29 23:49:16 UTC
SVN commit 465477 by arwalker:

BUG:111570 The change data file dialog will only contain that files that are actually in use, whereas previously it showed all files.

 M  +8 -4      kstchangefiledialog_i.cpp  


--- trunk/extragear/graphics/kst/kst/kstchangefiledialog_i.cpp #465476:465477
@@ -69,15 +69,17 @@
 void KstChangeFileDialogI::updateChangeFileDialog() {
   KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
   KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
-
+  QMap<QString, QString> filesUsed;
+  int i;
+  
   // clear list
   ChangeFileCurveList->clear();
   
   // first add vectors
-  int i;
   for (i = 0; i < (int)rvl.count(); i++) {
     rvl[i]->readLock();
     ChangeFileCurveList->insertItem(rvl[i]->tagName());
+    filesUsed.insert(rvl[i]->filename(), rvl[i]->filename()); 
     rvl[i]->readUnlock();
   }
   
@@ -85,6 +87,7 @@
   for (i = 0; i < (int)rml.count(); i++) {
     rml[i]->readLock();
     ChangeFileCurveList->insertItem(rml[i]->tagName());
+    filesUsed.insert(rml[i]->filename(), rml[i]->filename()); 
     rml[i]->readUnlock();  
   } 
 
@@ -96,9 +99,10 @@
   _files->clear();
   KstReadLocker ml(&KST::dataSourceList.lock());
   for (KstDataSourceList::Iterator it = KST::dataSourceList.begin(); it != KST::dataSourceList.end(); ++it) {
-    _files->insertItem((*it)->fileName());
+    if (filesUsed.contains((*it)->fileName())) {
+      _files->insertItem((*it)->fileName());
+    }
   }
-
   if (_files->contains(currentFile)) {
     _files->setCurrentText(currentFile);
   }
Comment 5 George Staikos 2005-09-30 01:55:51 UTC
  There's another interesting side effect from this.  Now it's impossible to 
change file and then change back unless you leave at least one vector using 
that file.  This isn't a useful case?
Comment 6 Nicolas Brisset 2005-09-30 11:25:29 UTC
George, I don't quite understand your point. Changing back should always be possible, it is not different from changing the data file in the first place. But sure, when there is someday a Undo/Redo framework, this kind of operation (changing data file) should be included in the list of revertable actions :-)
Comment 7 George Staikos 2005-09-30 17:25:27 UTC
  Yes ignore that last comment. :-)  No-one would try to do what I was 
thinking.