diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp index bad7643..2bd4d7f 100644 --- a/pgadmin/frm/frmQuery.cpp +++ b/pgadmin/frm/frmQuery.cpp @@ -216,7 +216,7 @@ frmQuery::frmQuery(frmMain *form, const wxString &_title, pgConn *_conn, const w pgScript(new pgsApplication(_conn)), pgsStringOutput(&pgsOutputString), pgsOutput(pgsStringOutput, wxEOL_UNIX), - pgsTimer(new pgScriptTimer(this)) + pgsTimer(new pgScriptTimer(this)), m_loading(false) { pgScript->SetCaller(this, PGSCRIPT_COMPLETE); @@ -1623,6 +1623,14 @@ void frmQuery::OnClose(wxCloseEvent &event) wxSleep(1); } + if (m_loading && event.CanVeto()) + { + wxMessageBox(_("You can not close the query tool, while the file loading is in progress"), _("Warning"), wxICON_INFORMATION | wxOK); + event.Veto(); + + return; + } + if (CheckChanged(event.CanVeto()) && event.CanVeto()) { event.Veto(); @@ -1695,6 +1703,7 @@ void frmQuery::OpenLastFile() bool modeUnicode = settings->GetUnicodeFile(); wxUtfFile file(lastPath, wxFile::read, modeUnicode ? wxFONTENCODING_UTF8 : wxFONTENCODING_DEFAULT); + m_loading = true; if (file.IsOpened()) file.Read(str); @@ -1712,6 +1721,7 @@ void frmQuery::OpenLastFile() mainForm->UpdateAllRecentFiles(); } } + m_loading = false; } diff --git a/pgadmin/include/frm/frmQuery.h b/pgadmin/include/frm/frmQuery.h index e9de7f6..708f3f2 100644 --- a/pgadmin/include/frm/frmQuery.h +++ b/pgadmin/include/frm/frmQuery.h @@ -258,6 +258,7 @@ private: bool aborted; bool lastFileFormat; + bool m_loading; // A simple mutex-like flag to prevent concurrent script execution. // Required because the pgScript parser isn't currently thread-safe :-(