From 28682f3550da13e50c02b46238cdacf8d3cebac1 Mon Sep 17 00:00:00 2001 From: antonvw Date: Sun, 8 Apr 2018 09:47:20 +0200 Subject: [PATCH] final msw fixes --- README.md | 37 +++++++++++------------- extension/easyloggingpp | 2 +- extension/include/shunting-yard/eval.hpp | 11 ++++--- extension/include/wx/extension/frame.h | 14 +++++---- extension/pugixml | 2 +- extension/sample/app.cpp | 4 +-- extension/sample/report/app.cpp | 4 +-- extension/src/app.cpp | 2 ++ extension/src/frame.cpp | 14 +++++++-- extension/src/lexer.cpp | 17 ++++++----- extension/src/stc-bind.cpp | 4 +-- extension/tclap | 2 +- extension/test/doctest | 2 +- syncped/app.cpp | 2 +- syncped/frame.cpp | 9 +++--- syncped/frame.h | 3 -- syncped/support.cpp | 4 +-- 17 files changed, 73 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index f102b8228..f1f406d6c 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ one of these applications, being a full featured source code text editor. - [doctest lib](https://github.com/onqtam/doctest) -- [easylogging++ lib](https://github.com/muflihun/easyloggingpp) +- [easylogging++ lib](https://github.com/muflihun/easyloggingpp) - [eval lib](https://github.com/r-lyeh/eval) -- [fsm lib](https://github.com/eglimi/cppfsm) +- [fsm lib](https://github.com/eglimi/cppfsm) - [OTL database lib](http://otl.sourceforge.net/) @@ -37,14 +37,16 @@ one of these applications, being a full featured source code text editor. ## Building wxWidgets - under windows: - -- using Microsoft Visual Studio 2017 in build/msw: - `nmake /f makefile.vc` or - `nmake /f makefile.vc BUILD=release` - -- using mingw in build/msw: - `make -f makefile.gcc` - -- using cygwin 1.7.9: - in buildmsw (created): - `../configure --with-msw --disable-shared && make` + -- using Microsoft Visual Studio 2017: + `git clone --recursive` + `mkdir build` + `cd build` + + (or make a `debug` directory and use `-DCMAKE_BUILD_TYPE=Debug`) + + `cmake.exe -DwxBUILD_SHARED=OFF -DCMAKE_BUILD_TYPE=Release ..` + `nmake` + copy generated lib\vc_lib to wxWidgets\lib - under Linux g++ 7.1.1: install gtk: @@ -61,17 +63,14 @@ one of these applications, being a full featured source code text editor. see g++ - under MacOS: - `brew install wxwidgets` - `brew install xcode` + `brew install wxwidgets` + `brew install xcode` ## Building wxExtension -- clone with submodules: - `git clone --recursive` - -- start with: - `mkdir build` - `cd build` +- `git clone --recursive` + `mkdir build` + `cd build` - under windows: -- using Visual Studio: @@ -81,8 +80,6 @@ one of these applications, being a full featured source code text editor. `cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..` `mingw32-make` - (or make a `debug` directory and use `-DCMAKE_BUILD_TYPE=Debug`) - - under Linux or MacOS: `cmake ..` `make` diff --git a/extension/easyloggingpp b/extension/easyloggingpp index c03b2c1d8..f508c0c21 160000 --- a/extension/easyloggingpp +++ b/extension/easyloggingpp @@ -1 +1 @@ -Subproject commit c03b2c1d8bdb44148468cb01472d737a96dfeabf +Subproject commit f508c0c213d2a0eabf9e57b394be918955a7d773 diff --git a/extension/include/shunting-yard/eval.hpp b/extension/include/shunting-yard/eval.hpp index 30e597936..0f1688b89 100644 --- a/extension/include/shunting-yard/eval.hpp +++ b/extension/include/shunting-yard/eval.hpp @@ -86,9 +86,9 @@ struct evaluator { { bool operator() (const std::string &lhs, const std::string &rhs) const { - if (equal(lhs.begin(), lhs.end(), rhs.begin())) // lhs is prefix of rhs + if (equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end())) // lhs is prefix of rhs return false; - else if (equal(rhs.begin(), rhs.end(), lhs.begin())) // rhs is prefix of lhs + else if (equal(rhs.begin(), rhs.end(), lhs.begin(), lhs.begin())) // rhs is prefix of lhs return true; else return lhs < rhs; @@ -205,8 +205,11 @@ struct evaluator { for (; it2 != in.cend() && numbers.find(*it2) != std::string::npos; ++it2); // TODO: find_first_not_of if (it2 != it) { - if (lasttok.first == ")" || (opers.find(lasttok.first) == opers.end() && funcs.find(lasttok.first) != funcs.end()) || lasttok.second == -1) - throw parse_error("Missing operator", i); + if (!lasttok.first.empty()) + { + if (lasttok.first == ")" || (opers.find(lasttok.first) == opers.end() && funcs.find(lasttok.first) != funcs.end()) || lasttok.second == -1) + throw parse_error("Missing operator", i); + } out.push_back(lasttok = token_t(std::string(it, it2), -1)); it = it2; diff --git a/extension/include/wx/extension/frame.h b/extension/include/wx/extension/frame.h index 2cbb4a686..e0672837f 100644 --- a/extension/include/wx/extension/frame.h +++ b/extension/include/wx/extension/frame.h @@ -2,7 +2,7 @@ // Name: frame.h // Purpose: Declaration of wxExFrame class // Author: Anton van Wezenbeek -// Copyright: (c) 2017 Anton van Wezenbeek +// Copyright: (c) 2018 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// #pragma once @@ -118,6 +118,9 @@ class WXDLLIMPEXP_BASE wxExFrame : public wxFrame /// Updates the specified statusbar pane with values from specified stc. static bool UpdateStatusBar(wxExSTC* stc, const std::string& pane); + + /// Are we closing? + static bool IsClosing() {return m_IsClosing;}; #endif // wxUSE_STATUSBAR protected: #if wxUSE_STATUSBAR @@ -130,10 +133,11 @@ class WXDLLIMPEXP_BASE wxExFrame : public wxFrame static wxExStatusBar* m_StatusBar; #endif private: - wxWindow* m_FindFocus = nullptr; - wxFindReplaceDialog* m_FindReplaceDialog = nullptr; - wxMenuBar* m_MenuBar = nullptr; + static bool m_IsClosing; - bool m_IsCommand = false; + bool m_IsCommand {false}; + wxWindow* m_FindFocus {nullptr}; + wxFindReplaceDialog* m_FindReplaceDialog {nullptr}; + wxMenuBar* m_MenuBar {nullptr}; }; #endif // wxUSE_GUI diff --git a/extension/pugixml b/extension/pugixml index 2ec3579f2..900a1cc94 160000 --- a/extension/pugixml +++ b/extension/pugixml @@ -1 +1 @@ -Subproject commit 2ec3579f296fdea783a806179424b28b2f3c0100 +Subproject commit 900a1cc94353b9202dcaee66b95d67e31331940e diff --git a/extension/sample/app.cpp b/extension/sample/app.cpp index 12f23be5b..9409bcab3 100644 --- a/extension/sample/app.cpp +++ b/extension/sample/app.cpp @@ -2,13 +2,12 @@ // Name: app.cpp // Purpose: Implementation of sample classes for wxExtension // Author: Anton van Wezenbeek -// Copyright: (c) 2017 Anton van Wezenbeek +// Copyright: (c) 2018 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// #include #include #include -#include #include #ifndef WX_PRECOMP #include @@ -25,6 +24,7 @@ #include #include #include +#include #include "app.h" #ifndef __WXMSW__ #include "app.xpm" diff --git a/extension/sample/report/app.cpp b/extension/sample/report/app.cpp index 9003edce8..4eb8dbcb3 100644 --- a/extension/sample/report/app.cpp +++ b/extension/sample/report/app.cpp @@ -2,10 +2,9 @@ // Name: app.cpp // Purpose: Implementation of sample classes for wxExRep // Author: Anton van Wezenbeek -// Copyright: (c) 2017 Anton van Wezenbeek +// Copyright: (c) 2018 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// -#include #include #ifndef WX_PRECOMP #include @@ -20,6 +19,7 @@ #include #include #include +#include #include "app.h" #ifndef __WXMSW__ #include "app.xpm" diff --git a/extension/src/app.cpp b/extension/src/app.cpp index 4f7eeb38d..d18270187 100644 --- a/extension/src/app.cpp +++ b/extension/src/app.cpp @@ -121,10 +121,12 @@ bool wxExApp::OnInit() START_EASYLOGGINGPP(argc_elp, argv_elp); +#ifndef __WXMSW__ for (int i = 0; i < argc_elp; i++) { free(argv_elp[i]); } +#endif VLOG(1) << "started: " diff --git a/extension/src/frame.cpp b/extension/src/frame.cpp index 1c02a979c..34e1eb535 100644 --- a/extension/src/frame.cpp +++ b/extension/src/frame.cpp @@ -91,6 +91,8 @@ wxExStatusBar* wxExFrame::m_StatusBar = nullptr; #endif +bool wxExFrame::m_IsClosing = false; + #if wxUSE_DRAG_AND_DROP class FileDropTarget : public wxFileDropTarget { @@ -209,6 +211,10 @@ wxExFrame::wxExFrame(const wxExWindowData& data) Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { (GetMenuBar() != nullptr ? event.Check(GetMenuBar()->IsShown()): event.Check(false));}, ID_VIEW_MENUBAR); + + Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& event) { + m_IsClosing = true; + event.Skip(); }); } wxExFrame::~wxExFrame() @@ -359,12 +365,14 @@ void wxExFrame::StatusBarClicked(const std::string& pane) bool wxExFrame::StatusText(const std::string& text, const std::string& pane) { - return (m_StatusBar == nullptr ? false: m_StatusBar->SetStatusText(text, pane)); + return (m_IsClosing || m_StatusBar == nullptr ? + false: + m_StatusBar->SetStatusText(text, pane)); } bool wxExFrame::UpdateStatusBar(const wxListView* lv) { - if (lv->IsShown()) + if (!m_IsClosing && lv->IsShown()) { const std::string text = std::to_string(lv->GetItemCount()) + (lv->GetSelectedItemCount() > 0 ? "," + std::to_string(lv->GetSelectedItemCount()): @@ -379,7 +387,7 @@ bool wxExFrame::UpdateStatusBar(const wxListView* lv) // Do not make it const, too many const_casts needed, bool wxExFrame::UpdateStatusBar(wxExSTC* stc, const std::string& pane) { - if (stc == nullptr) + if (stc == nullptr || m_IsClosing) { return false; } diff --git a/extension/src/lexer.cpp b/extension/src/lexer.cpp index f1bc61cea..f029abb5b 100644 --- a/extension/src/lexer.cpp +++ b/extension/src/lexer.cpp @@ -130,9 +130,9 @@ bool wxExLexer::AddKeywords(const std::string& value, int setno) bool wxExLexer::Apply() const { if (m_STC == nullptr) return false; - + m_STC->ClearDocumentStyle(); - + for (const auto& it : m_Properties) { it.ApplyReset(m_STC); @@ -152,15 +152,20 @@ bool wxExLexer::Apply() const { m_STC->SetKeyWords(k.first, wxExGetStringSet(k.second)); } - + wxExLexers::Get()->Apply(m_STC); - + for (const auto& p : m_Properties) p.Apply(m_STC); for (const auto& s : m_Styles) s.Apply(m_STC); } // And finally colour the entire document. - m_STC->Colourise(0, m_STC->GetLength() - 1); + const auto length = m_STC->GetLength(); + + if (length > 0) + { + m_STC->Colourise(0, length - 1); + } return true; } @@ -365,8 +370,6 @@ const std::string wxExLexer::MakeSingleLineComment( return out; } - - void wxExLexer::Reset() { m_CommentBegin.clear(); diff --git a/extension/src/stc-bind.cpp b/extension/src/stc-bind.cpp index a2abf7c83..6c2e6a9a4 100644 --- a/extension/src/stc-bind.cpp +++ b/extension/src/stc-bind.cpp @@ -500,7 +500,7 @@ void wxExSTC::BindAll() base10_val = std::stol(word); base10_ok = (base10_val != 0); } - catch (std::exception& e) + catch (std::exception&) { base10_ok = false; } @@ -509,7 +509,7 @@ void wxExSTC::BindAll() { base16_val = std::stol(word, nullptr, 16); } - catch (std::exception& e) + catch (std::exception&) { base16_ok = false; } diff --git a/extension/tclap b/extension/tclap index 1e1cc4fb9..4970b7e79 160000 --- a/extension/tclap +++ b/extension/tclap @@ -1 +1 @@ -Subproject commit 1e1cc4fb9abbc4bfcd62c73085c3c446fca681dd +Subproject commit 4970b7e79329bb0ef85f32597540f8e2ef021b6c diff --git a/extension/test/doctest b/extension/test/doctest index fec6e4a5f..bdb5c2b1b 160000 --- a/extension/test/doctest +++ b/extension/test/doctest @@ -1 +1 @@ -Subproject commit fec6e4a5f570dfa8ba4b715bc8fa4f51a8b70557 +Subproject commit bdb5c2b1b1f392135afdeb51f02538e423c6ccb2 diff --git a/syncped/app.cpp b/syncped/app.cpp index 59cfa10c8..17092213a 100644 --- a/syncped/app.cpp +++ b/syncped/app.cpp @@ -5,7 +5,6 @@ // Copyright: (c) 2018 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// -#include #include #ifndef WX_PRECOMP #include @@ -15,6 +14,7 @@ #include #include #include +#include #include "app.h" #include "frame.h" diff --git a/syncped/frame.cpp b/syncped/frame.cpp index dbd5d8c37..af10749ed 100644 --- a/syncped/frame.cpp +++ b/syncped/frame.cpp @@ -259,7 +259,6 @@ Frame::Frame(App* app) GetDebug()->Execute(event.GetId() - ID_EDIT_DEBUG_FIRST);}, ID_EDIT_DEBUG_FIRST, ID_EDIT_DEBUG_LAST); Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& event) { - m_IsClosing = true; long count = 0; for (size_t i = 0; i < m_Editors->GetPageCount(); i++) { @@ -280,7 +279,6 @@ Frame::Frame(App* app) { wxLogStatus(_("Process is running")); } - m_IsClosing = false; return; } } @@ -292,8 +290,8 @@ Frame::Frame(App* app) if (m_App->GetData().Control().Command().empty()) { wxDELETE(m_Process); - event.Skip(); } + event.Skip(); }); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { @@ -916,7 +914,8 @@ void Frame::OnUpdateUI(wxUpdateUIEvent& event) switch (event.GetId()) { case wxID_EXECUTE: - event.Enable( !m_Process->GetExecuteCommand().empty() && + event.Enable( !IsClosing() && m_Process != nullptr && + !m_Process->GetExecuteCommand().empty() && !m_Process->IsRunning()); break; case wxID_STOP: event.Enable(m_Process->IsRunning()); break; @@ -1420,7 +1419,7 @@ void Frame::SyncCloseAll(wxWindowID id) { DecoratedFrame::SyncCloseAll(id); - if (m_IsClosing) return; + if (IsClosing()) return; switch (id) { diff --git a/syncped/frame.h b/syncped/frame.h index 84f869b97..ddfc147ae 100644 --- a/syncped/frame.h +++ b/syncped/frame.h @@ -19,8 +19,6 @@ class Frame : public DecoratedFrame { public: explicit Frame(App* app); - - bool IsClosing() const {return m_IsClosing;}; protected: void OnCommand(wxCommandEvent& event); void OnUpdateUI(wxUpdateUIEvent& event); @@ -63,7 +61,6 @@ class Frame : public DecoratedFrame const wxString m_ProjectWildcard = _("Project Files") + " (*.prj)|*.prj"; - bool m_IsClosing = false; int m_NewProjectNo = 1, m_SplitId = 1; wxCheckBox *m_CheckBoxDirCtrl, *m_CheckBoxHistory; diff --git a/syncped/support.cpp b/syncped/support.cpp index 7890c5164..dc919b0a0 100644 --- a/syncped/support.cpp +++ b/syncped/support.cpp @@ -2,10 +2,9 @@ // Name: support.cpp // Purpose: Implementation of DecoratedFrame class // Author: Anton van Wezenbeek -// Copyright: (c) 2017 Anton van Wezenbeek +// Copyright: (c) 2018 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// -#include #include #ifndef WX_PRECOMP #include @@ -21,6 +20,7 @@ #include #include #include +#include #ifndef __WXMSW__ #include "app.xpm" #endif