I have found the problem and have a solution.
When you call close by right clicking on the tab , you end up in this function :
bool EditorManager::Close(EditorBase* editor,bool dontsave)
{
SANITY_CHECK(false);
if (editor)
{
int idx = FindPageFromEditor(editor);
if (idx != -1)
{
if(!dontsave)
if(!QueryClose(editor))
return false;
wxString filename = editor->GetFilename();
// LOGSTREAM << wxString::Format(_T("Close(): ed=%p, title=%s\n"), editor, editor ? editor->GetTitle().c_str() : _T(""));
m_pNotebook->DeletePage(idx);
}
}
m_pData->m_NeedsRefresh = true;
return true;
}
-> The QueryClose() call shows the message box. When the user clicks on no, the function returns true, so it ends up at m_pNoteBook->DeletePage(idx), and that one will call OnPageClosing
void EditorManager::OnPageClosing(wxFlatNotebookEvent& event)
{
EditorBase* eb = static_cast<EditorBase*>(m_pNotebook->GetPage(event.GetSelection()));
// LOGSTREAM << wxString::Format(_T("OnPageClosing(): ed=%p, title=%s\n"), eb, eb ? eb->GetTitle().c_str() : _T(""));
if (!QueryClose(eb))
event.Veto();
event.Skip(); // allow others to process it too
}
Which calls .... QueryClose() --> so a second message box.
If you close with the x button, then you end up immediately in OnPageClosing -> 1 message box.
My suggestion is to remove the part :
if(!dontsave)
if(!QueryClose(editor))
return false;
wxString filename = editor->GetFilename();
// LOGSTREAM << wxString::Format(_T("Close(): ed=%p, title=%s\n"), editor, editor ? editor->GetTitle().c_str() : _T(""));
EditorManager::QueryClose returns false, only when the saving faild for some reason or the user pressed cancel, then EditorManager::Close will return after the QueryClose call and not call the notebook anymore, so no problem for this either, the one time change is in both cases best suited inthe notebook.
Another thing is then the QueryClose checks on ed->GetModified() and on a NO click it will do ed->SetModified(false); so that means in our secon call the GetModified should return false (and hence no message box), but it seems again this returns true.
But Yiannis could you take a look at it ? Maybe the functions is also called in other flows where it is still needed
![Huh ???](https://forums.codeblocks.org/Smileys/default/huh.gif)
[EDIT], the reason why the second modify again gets returned true is :
bool cbEditor::GetModified()
{
return m_Modified || m_pControl->GetModify();
}
m_Modified was set to false, but it is the second part that make the whole evaluate to true.