Author Topic: Removing dead entries from reopened list  (Read 4904 times)

Offline artoj

  • Almost regular
  • **
  • Posts: 206
  • Location: Supporting my team
    • http://ajonsson.kapsi.fi/
Removing dead entries from reopened list
« on: October 27, 2005, 04:28:13 pm »
Hi,

I created a patch to SourceForge.net to fix this issue but I think I need some help.

Originally I thought this was an trivial issue to fix but, well, it ended up to being something very different.

Here's the original patch:

Code
Index: main.cpp
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/src/main.cpp,v
retrieving revision 1.108
diff -u -r1.108 main.cpp
--- main.cpp 21 Oct 2005 09:58:05 -0000 1.108
+++ main.cpp 27 Oct 2005 11:14:56 -0000
@@ -1297,7 +1297,8 @@
 void MainFrame::OnFileReopen(wxCommandEvent& event)
 {
     wxString fname = m_FilesHistory.GetHistoryFile(event.GetId() - wxID_FILE1);
-    Open(fname, true);
+    if (!Open(fname, true))
+        m_FilesHistory.RemoveFileFromHistory(event.GetId() - wxID_FILE1); // Remove files that cannot be found
 }
 
 void MainFrame::OnFileOpenRecentClearHistory(wxCommandEvent& event)

Nothing special there, but when I tried to make a better patch with some user interaction:

Code
if (!Open(fname, true)) {
    if (wxMessageBox(_("There was an error opening the file. Remove it from the list?"), _("Confirm"), wxYES_NO | wxICON_QUESTION) == wxYES)
        m_FilesHistory.RemoveFileFromHistory(event.GetId() - wxID_FILE1); // Remove files that cannot be found
}

In the original patch Code::Blocks creates a error saying that the file could not be opened but in the "better patch" it doesn't, why? Does Code::Blocks even check that the file exist or was the error in the original patch created by an extension?

Just tested it: disabling the Default MIME handler plugin and then trying to open a dead entry from the list does nothing. I guess it makes sense, in a way, but I think Code::Blocks should check if the file exists.

The second issue is with the "Start here" page because it also shows the recent files. Should I try to write a patch that removes the recent file that was just deleted from the menu (don't know if it's even possible).