Skip to content

Commit

Permalink
Fixed bug #419 where opening a file without permission would cause th…
Browse files Browse the repository at this point in the history
…e ChangeCheckerThread to continuously spam lerror log message boxes.
  • Loading branch information
ajpalkovic committed Oct 25, 2010
1 parent 82ba331 commit 6c17ac0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/ChangeCheckerThread.cpp
Expand Up @@ -58,7 +58,13 @@ void* ChangeCheckerThread::Entry() {

// file could be locked by another app
// or the remote site could be unavailable
if (!modDate.IsValid()) continue;
// or we could not have permission to see it
// handle this in the event thread
if (!modDate.IsValid()) {
changedFiles.Add(p->path);
modDates.push_back(modDate);
continue;
}

// Check if this change have been marked to be skipped
if (p->skipDate.IsValid() && modDate == p->skipDate) continue;
Expand Down
28 changes: 25 additions & 3 deletions src/EditorFrame.cpp
Expand Up @@ -1110,18 +1110,40 @@ void EditorFrame::OnFilesChanged(wxFilesChangedEvent& event) {
const unsigned int count = paths.GetCount();
for (unsigned int i = 0; i < count; ++i) {
const wxString& path = paths[i];
bool close = false;

wxDateTime modTime = modDates[i];
if(!modTime.IsValid()) {
int answer = wxMessageBox(wxString::Format(wxT("Unable to read file %s. Would you like to close it?"), path), wxT("Error"), wxYES_NO);
if(answer == wxYES) {
close = true;
}
}

// Find doc with current path
const unsigned int pageCount = m_tabBar->GetPageCount();
for (unsigned int p = 0; p < pageCount; ++p) {
unsigned int p;
for (p = 0; p < pageCount; ++p) {
const EditorCtrl* page = GetEditorCtrlFromPage(p);
const wxString filePath = page->GetPath();
if (path == filePath) {
pathsToPages.push_back(p);
pageDates.push_back(modDates[i]);
if(!close) {
pathsToPages.push_back(p);
pageDates.push_back(modDates[i]);
}
break;
}
}

if(close && p < pageCount) {
Freeze(); // optimize redrawing
DeletePage(p, true);

// If we deleted last editCtrl, then we have to create a new empty one
if (m_tabBar->GetPageCount() == 0) AddTab();

Thaw(); // optimize redrawing
}
}

AskToReloadMulti(pathsToPages, pageDates);
Expand Down

0 comments on commit 6c17ac0

Please sign in to comment.