diff --git a/src/lib/component/controller/ErrorController.cpp b/src/lib/component/controller/ErrorController.cpp index 54e8d51b..1e46b4f4 100644 --- a/src/lib/component/controller/ErrorController.cpp +++ b/src/lib/component/controller/ErrorController.cpp @@ -20,7 +20,7 @@ void ErrorController::handleMessage(MessageFinishedParsing* message) { clear(); - getView()->addErrors(m_storageAccess->getAllErrors(), false); + getView()->addErrors(m_storageAccess->getErrors(), false); } void ErrorController::handleMessage(MessageNewErrors* message) @@ -42,8 +42,13 @@ void ErrorController::handleMessage(MessageShowErrors* message) clear(); - getView()->addErrors(m_storageAccess->getAllErrors(), false); - getView()->showDockWidget(); + std::vector errors = m_storageAccess->getErrors(); + getView()->addErrors(errors, false); + + if (errors.size()) + { + getView()->showDockWidget(); + } } ErrorView* ErrorController::getView() const diff --git a/src/lib/component/controller/StatusBarController.cpp b/src/lib/component/controller/StatusBarController.cpp index 4ad05d8a..24055f87 100644 --- a/src/lib/component/controller/StatusBarController.cpp +++ b/src/lib/component/controller/StatusBarController.cpp @@ -42,7 +42,7 @@ void StatusBarController::handleMessage(MessageRefresh* message) void StatusBarController::handleMessage(MessageShowErrors* message) { - if (message->errorId) + if (message->errorId || message->isReplayed()) { return; } diff --git a/src/lib/component/view/TabbedView.cpp b/src/lib/component/view/TabbedView.cpp index eebb90f7..1bc2efff 100644 --- a/src/lib/component/view/TabbedView.cpp +++ b/src/lib/component/view/TabbedView.cpp @@ -42,10 +42,10 @@ void TabbedView::removeView(View* view) void TabbedView::showView(View* view) { - getViewLayout()->showView(view); + getViewLayout()->showView(this); } void TabbedView::hideView(View* view) { - getViewLayout()->hideView(view); + getViewLayout()->hideView(this); } diff --git a/src/lib/data/PersistentStorage.cpp b/src/lib/data/PersistentStorage.cpp index e3949b14..ce03992c 100644 --- a/src/lib/data/PersistentStorage.cpp +++ b/src/lib/data/PersistentStorage.cpp @@ -6,9 +6,7 @@ #include "utility/Cache.h" #include "utility/file/FileSystem.h" #include "utility/logging/logging.h" -#include "utility/messaging/type/MessageClearErrorCount.h" #include "utility/messaging/type/MessageNewErrors.h" -#include "utility/messaging/type/MessageShowErrors.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/text/TextAccess.h" #include "utility/TimePoint.h" @@ -234,7 +232,7 @@ void PersistentStorage::forEachError(std::function errors = getErrors(); + for (const ErrorInfo& error : errors) + { + info.total++; + + if (error.fatal) + { + info.fatal++; + } + } + + return info; } std::vector PersistentStorage::getErrors() const { - LOG_ERROR("This should never be called."); - return std::vector(); -} + std::vector errors = m_sqliteStorage.getAllErrors(); + std::vector filteredErrors; -std::vector PersistentStorage::getAllErrors() const -{ - return m_sqliteStorage.getAllErrors(); + for (const ErrorInfo& error : errors) + { + if (m_errorFilter.filter(error)) + { + filteredErrors.push_back(error); + } + } + + return filteredErrors; } std::shared_ptr PersistentStorage::getErrorTokenLocations(std::vector* errors) const @@ -1072,16 +1087,19 @@ std::shared_ptr PersistentStorage::getErrorTokenLocatio TRACE(); std::shared_ptr errorCollection = std::make_shared(); - - *errors = m_sqliteStorage.getAllErrors(); - for (const ErrorInfo& error : *errors) + for (const ErrorInfo& error : m_sqliteStorage.getAllErrors()) { - // Set first bit to 1 to avoid collisions - Id locationId = ~(~size_t(0) >> 1) + error.id; + if (m_errorFilter.filter(error)) + { + errors->push_back(error); - errorCollection->addTokenLocation( - locationId, error.id, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber - )->setType(LOCATION_ERROR); + // Set first bit to 1 to avoid collisions + Id locationId = ~(~size_t(0) >> 1) + error.id; + + errorCollection->addTokenLocation( + locationId, error.id, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber + )->setType(LOCATION_ERROR); + } } return errorCollection; diff --git a/src/lib/data/PersistentStorage.h b/src/lib/data/PersistentStorage.h index 89546e00..58eaf3a9 100644 --- a/src/lib/data/PersistentStorage.h +++ b/src/lib/data/PersistentStorage.h @@ -119,7 +119,6 @@ public: virtual ErrorCountInfo getErrorCount() const; virtual std::vector getErrors() const; - virtual std::vector getAllErrors() const; virtual std::shared_ptr getErrorTokenLocations(std::vector* errors) const; diff --git a/src/lib/data/access/StorageAccess.cpp b/src/lib/data/access/StorageAccess.cpp index 7e5df89d..393f56c2 100644 --- a/src/lib/data/access/StorageAccess.cpp +++ b/src/lib/data/access/StorageAccess.cpp @@ -3,3 +3,8 @@ StorageAccess::~StorageAccess() { } + +void StorageAccess::setErrorFilter(const ErrorFilter& filter) +{ + m_errorFilter = filter; +} diff --git a/src/lib/data/access/StorageAccess.h b/src/lib/data/access/StorageAccess.h index 8f8342cb..47aa55f8 100644 --- a/src/lib/data/access/StorageAccess.h +++ b/src/lib/data/access/StorageAccess.h @@ -13,6 +13,7 @@ #include "data/graph/Node.h" #include "data/search/SearchMatch.h" #include "data/ErrorCountInfo.h" +#include "data/ErrorFilter.h" #include "data/ErrorInfo.h" #include "data/StorageStats.h" @@ -70,9 +71,13 @@ public: virtual ErrorCountInfo getErrorCount() const = 0; virtual std::vector getErrors() const = 0; - virtual std::vector getAllErrors() const = 0; virtual std::shared_ptr getErrorTokenLocations(std::vector* errors) const = 0; + + virtual void setErrorFilter(const ErrorFilter& filter); + +protected: + ErrorFilter m_errorFilter; }; #endif // STORAGE_ACCESS_H diff --git a/src/lib/data/access/StorageAccessProxy.cpp b/src/lib/data/access/StorageAccessProxy.cpp index 8b5ac8f4..8e031c37 100644 --- a/src/lib/data/access/StorageAccessProxy.cpp +++ b/src/lib/data/access/StorageAccessProxy.cpp @@ -32,6 +32,8 @@ bool StorageAccessProxy::hasSubject() const void StorageAccessProxy::setSubject(StorageAccess* subject) { m_subject = subject; + + setErrorFilter(m_errorFilter); } Id StorageAccessProxy::getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const @@ -272,48 +274,19 @@ StorageStats StorageAccessProxy::getStorageStats() const ErrorCountInfo StorageAccessProxy::getErrorCount() const { - ErrorCountInfo info; - - std::vector errors = getErrors(); - for (const ErrorInfo& error : errors) + if (hasSubject()) { - info.total++; - - if (error.fatal) - { - info.fatal++; - } + return m_subject->getErrorCount(); } - return info; + return ErrorCountInfo(); } std::vector StorageAccessProxy::getErrors() const { if (hasSubject()) { - std::vector errors = m_subject->getAllErrors();; - std::vector filteredErrors; - - for (const ErrorInfo& error : errors) - { - if (m_errorFilter.filter(error)) - { - filteredErrors.push_back(error); - } - } - - return filteredErrors; - } - - return std::vector(); -} - -std::vector StorageAccessProxy::getAllErrors() const -{ - if (hasSubject()) - { - return m_subject->getAllErrors(); + return m_subject->getErrors();; } return std::vector(); @@ -323,32 +296,25 @@ std::shared_ptr StorageAccessProxy::getErrorTokenLocati { if (hasSubject()) { - std::shared_ptr collection = m_subject->getErrorTokenLocations(errors); - std::vector unfilteredErrors = *errors; - errors->clear(); - - for (const ErrorInfo& error : unfilteredErrors) - { - if (m_errorFilter.filter(error)) - { - errors->push_back(error); - } - else - { - // Set first bit to 1 to avoid collisions - Id locationId = ~(~size_t(0) >> 1) + error.id; - collection->removeTokenLocation(collection->findTokenLocationById(locationId)); - } - } - - return collection; + return m_subject->getErrorTokenLocations(errors); } return std::make_shared(); } +void StorageAccessProxy::setErrorFilter(const ErrorFilter& filter) +{ + StorageAccess::setErrorFilter(filter); + + if (hasSubject()) + { + m_subject->setErrorFilter(filter); + } +} + void StorageAccessProxy::handleMessage(MessageErrorFilterChanged* message) { - m_errorFilter = message->errorFilter; + setErrorFilter(message->errorFilter); + MessageShowErrors(getErrorCount()).dispatch(); } diff --git a/src/lib/data/access/StorageAccessProxy.h b/src/lib/data/access/StorageAccessProxy.h index e266cc20..f0873bce 100644 --- a/src/lib/data/access/StorageAccessProxy.h +++ b/src/lib/data/access/StorageAccessProxy.h @@ -3,8 +3,6 @@ #include "data/access/StorageAccess.h" -#include "data/ErrorFilter.h" - #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/MessageErrorFilterChanged.h" @@ -65,16 +63,16 @@ public: virtual ErrorCountInfo getErrorCount() const; virtual std::vector getErrors() const; - virtual std::vector getAllErrors() const; virtual std::shared_ptr getErrorTokenLocations(std::vector* errors) const; +protected: + virtual void setErrorFilter(const ErrorFilter& filter); + private: void handleMessage(MessageErrorFilterChanged* message); StorageAccess* m_subject; - - ErrorFilter m_errorFilter; }; #endif // STORAGE_ACCESS_PROXY_H diff --git a/src/lib_gui/qt/view/QtDialogView.cpp b/src/lib_gui/qt/view/QtDialogView.cpp index 6902eca9..38574813 100644 --- a/src/lib_gui/qt/view/QtDialogView.cpp +++ b/src/lib_gui/qt/view/QtDialogView.cpp @@ -224,6 +224,11 @@ void QtDialogView::handleMessage(MessageNewErrors* message) void QtDialogView::handleMessage(MessageShowErrors* message) { + if (message->isReplayed()) + { + return; + } + ErrorCountInfo errorInfo = message->errorCount; m_onQtThread2( diff --git a/src/lib_gui/qt/view/QtTabbedView.cpp b/src/lib_gui/qt/view/QtTabbedView.cpp index 2d87fd20..8ca2cef3 100644 --- a/src/lib_gui/qt/view/QtTabbedView.cpp +++ b/src/lib_gui/qt/view/QtTabbedView.cpp @@ -56,6 +56,13 @@ void QtTabbedView::addViewWidget(View* view) doRefreshView(); } +void QtTabbedView::showView(View* view) +{ + TabbedView::showView(view); + + m_widget->setCurrentWidget(QtViewWidgetWrapper::getWidgetOfView(view)); +} + void QtTabbedView::setStyleSheet() { utility::setWidgetBackgroundColor(QtViewWidgetWrapper::getWidgetOfView(this), ColorScheme::getInstance()->getColor("tab/background")); diff --git a/src/lib_gui/qt/view/QtTabbedView.h b/src/lib_gui/qt/view/QtTabbedView.h index 625b9e9c..05a58b58 100644 --- a/src/lib_gui/qt/view/QtTabbedView.h +++ b/src/lib_gui/qt/view/QtTabbedView.h @@ -20,6 +20,7 @@ public: // TabbedView implementation virtual void addViewWidget(View* view); + virtual void showView(View* view); private: void setStyleSheet();