From 627311178c69e6ee650e0e84b02e08d904b74afa Mon Sep 17 00:00:00 2001 From: lsv Date: Thu, 29 Jun 2023 10:32:46 +0500 Subject: [PATCH] Add OnFatalException method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавил обработку аврийных завершений. Мелкие правки. --- .gitignore | 1 + ctl/ctlSQLGrid.cpp | 8 +++--- frm/frmMain.cpp | 2 +- frm/frmStatus.cpp | 2 +- include/pgAdmin3.h | 4 +-- pgAdmin3.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 78 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 2c2975c..0e76ddb 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ x64/Release_(3.0)/*.res x64/Release_(3.0)/*.sbr x64/Release_(3.0)/*.ilk x64/Release_(3.0)/*.txt +x64/Release_(3.0)/svg *.sbr *.obj *.cod diff --git a/ctl/ctlSQLGrid.cpp b/ctl/ctlSQLGrid.cpp index 9a3c064..450c1e1 100644 --- a/ctl/ctlSQLGrid.cpp +++ b/ctl/ctlSQLGrid.cpp @@ -52,6 +52,8 @@ void ctlSQLGrid::setresizedpi() { SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE); SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_TOP); SetRowLabelSize(FromDIP(50)); + SetDefaultRowSize(fntCells.GetPointSize() * 2 + 2); + SetColLabelSize(fntLabel.GetPointSize() * 4); } @@ -66,8 +68,6 @@ ctlSQLGrid::ctlSQLGrid(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons */ setresizedpi(); - //SetDefaultRowSize(fntCells.GetPointSize() * 2 + 2); - //SetColLabelSize(fntLabel.GetPointSize() * 4); SetDefaultCellOverflow(false); //SetDefaultRenderer(new wxGridCellAutoWrapStringRenderer); SetDefaultRenderer(new CursorCellRenderer); @@ -962,8 +962,8 @@ void ctlSQLGrid::AutoSizeColumns(bool setAsMin) } SetColLabelSize(maxH+ FromDIP(EXTRAEXTENT_HEIGHT)); availSize = GetClientSize().GetWidth() - GetRowLabelSize(); - int newDef = GetDefaultRowSize()+FromDIP(1); - SetDefaultRowSize(newDef, true); + //int newDef = GetDefaultRowSize()+FromDIP(1); + //SetDefaultRowSize(newDef, true); // Second pass: shrink wide columns if exceeded available width if (totalSize > availSize) { diff --git a/frm/frmMain.cpp b/frm/frmMain.cpp index 76a1bb3..a08904d 100644 --- a/frm/frmMain.cpp +++ b/frm/frmMain.cpp @@ -1482,7 +1482,7 @@ faqFactory::faqFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolb wxWindow *faqFactory::StartDialog(frmMain *form, pgObject *obj) { - wxLaunchDefaultBrowser(wxT("http://www.pgadmin.org/support/faq.php")); + wxLaunchDefaultBrowser(wxT("https://github.com/levinsv/pgadmin3/issues")); return 0; } diff --git a/frm/frmStatus.cpp b/frm/frmStatus.cpp index b71647e..b1e842e 100644 --- a/frm/frmStatus.cpp +++ b/frm/frmStatus.cpp @@ -322,7 +322,7 @@ frmStatus::frmStatus(frmMain *form, const wxString &_title, pgConn *conn) : pgFr toolBar->AddSeparator(); toolBar->AddTool(MNU_CANCEL, wxEmptyString, *GetBundleSVG(query_cancel_png_bmp, "query_cancel.svg", wxSize(16, 16)), _("Cancel query"), wxITEM_NORMAL); toolBar->AddTool(MNU_TERMINATE, wxEmptyString, *GetBundleSVG(terminate_backend_png_bmp, "terminate_backend.svg", wxSize(16, 16)), _("Terminate backend"), wxITEM_NORMAL); - toolBar->AddTool(MNU_COMMIT, wxEmptyString, *GetBundleSVG(storedata_png_bmp, "file_save.svg", wxSize(16, 16)), _("Commit transaction"), wxITEM_NORMAL); + toolBar->AddTool(MNU_COMMIT, wxEmptyString, *GetBundleSVG(storedata_png_bmp, "storedata.svg", wxSize(16, 16)), _("Commit transaction"), wxITEM_NORMAL); toolBar->AddTool(MNU_ROLLBACK, wxEmptyString, *GetBundleSVG(delete_png_bmp, "drop.svg", wxSize(16, 16)), _("Rollback transaction"), wxITEM_NORMAL); toolBar->AddSeparator(); toolBar->AddTool(MNU_CLEAR_FILTER_SERVER_STATUS, wxEmptyString, *GetBundleSVG(sortfilterclear_png_bmp, "sortfilterclear.svg", wxSize(16, 16)), _("Clear filter"), wxITEM_NORMAL); diff --git a/include/pgAdmin3.h b/include/pgAdmin3.h index 411c991..dd809f5 100644 --- a/include/pgAdmin3.h +++ b/include/pgAdmin3.h @@ -169,7 +169,7 @@ class pgAdmin3 : public wxApp public: virtual bool OnInit(); virtual int OnExit(); - + virtual void OnFatalException() wxOVERRIDE; #ifdef __WXMAC__ void MacOpenFile(const wxString &fileName); #endif @@ -190,7 +190,7 @@ protected: void InitLogger(); void InitNetwork(); void InitXml(); - + #ifdef __WXMSW__ void InitLibpq(); #endif diff --git a/pgAdmin3.cpp b/pgAdmin3.cpp index c04b77e..d78973f 100644 --- a/pgAdmin3.cpp +++ b/pgAdmin3.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "wx/stackwalk.h" // wxOGL #include @@ -200,8 +201,75 @@ void frmDlgTest::OnSelect(wxCommandEvent &ev) } } +class MyStackWalker : public wxStackWalker +{ +public: + MyStackWalker(wxString &rez) + { + Rez = &rez; + } + +// bool IsOk() const { return m_isOk; } + +protected: + virtual void OnStackFrame(const wxStackFrame& frame) wxOVERRIDE; + wxString* Rez; +}; +void MyStackWalker::OnStackFrame(const wxStackFrame& frame) +{ + + Rez->Append(wxString::Format("level: %lu\n", (unsigned long) frame.GetLevel())); + wxString func = frame.GetName(); + if (!func.empty()) + Rez->Append(wxString::Format("function: %s\n", func)); + Rez->Append(wxString::Format(" offset: %08lx\n address: %08lx\n", (unsigned long) frame.GetOffset(), (unsigned long)wxPtrToUInt(frame.GetAddress()))); + + + wxString module = frame.GetModule(); + if (!module.empty()) + Rez->Append(wxString::Format("module: %s\n", module)); + + if (frame.HasSourceLocation()) + { + Rez->Append(wxString::Format("file: %s\n", frame.GetFileName())); + Rez->Append(wxString::Format("line: %lu\n", (unsigned long)frame.GetLine())); + } + + const size_t nParams = frame.GetParamCount(); + if (nParams) + { + for (size_t n = 0; n < nParams; n++) + { + Rez->Append(wxString::Format(" P%lu: %lu\n", (unsigned long)n)); + + wxString type, name, value; + if (!frame.GetParam(n, &type, &name, &value)) + continue; + + if (!type.empty()) + Rez->Append(wxString::Format(" type: %s\n", type)); + + if (!name.empty()) + Rez->Append(wxString::Format(" name: %s\n", name)); + + if (!value.empty()) + Rez->Append(wxString::Format(" value: %s\n", value)); + } + + } + Rez->Append(wxString::Format("----------------\n")); + +} // The Application! +void pgAdmin3::OnFatalException() { + wxString err = "fatal error"; + MyStackWalker sw(err); + sw.WalkFromException(); + wxLogError(err); + wxMessageBox(err, + "wxExcept", wxOK | wxICON_ERROR); +} bool pgAdmin3::OnInit() { // Force logging off until we're ready @@ -463,6 +531,7 @@ bool pgAdmin3::OnInit() // Attempt to dynamically load PGgetOutResult from libpq. this // is only present in EDB versions. InitLibpq(); + #endif if (configMode)