reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 70c5a23e0331102e525305a152f8dd49bed3dda9
parent 7a1e9c16b0107ee6d0e253ebde94a58f31a9efc4
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Mon,  1 Feb 2016 18:28:40 -0500

handle invalid remotes when displaying an about dialog

Diffstat:
Msrc/about.cpp | 2+-
Msrc/about.hpp | 4++--
Msrc/manager.cpp | 25++++++++++++++++++++++++-
3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -26,7 +26,7 @@ using namespace std; -About::About(RemoteIndex *index) +About::About(const RemoteIndex *index) : Dialog(IDD_ABOUT_DIALOG), m_index(index), m_currentCat(-255) { RichEdit::Init(); diff --git a/src/about.hpp b/src/about.hpp @@ -27,7 +27,7 @@ class TabBar; class About : public Dialog { public: - About(RemoteIndex *index); + About(const RemoteIndex *); protected: void onInit() override; @@ -37,7 +37,7 @@ private: void populate(); void updatePackages(); - RemoteIndex *m_index; + const RemoteIndex *m_index; int m_currentCat; TabBar *m_tabs; diff --git a/src/manager.cpp b/src/manager.cpp @@ -20,6 +20,7 @@ #include "about.hpp" #include "config.hpp" #include "encoding.hpp" +#include "errors.hpp" #include "index.hpp" #include "menu.hpp" #include "reapack.hpp" @@ -180,7 +181,29 @@ void Manager::about() if(remote.isNull()) return; - RemoteIndex *index = RemoteIndex::load(remote.name()); + RemoteIndex *index = nullptr; + + try { + index = RemoteIndex::load(remote.name()); + } + catch(const reapack_error &e) { + const auto_string &desc = make_autostring(e.what()); + + auto_char msg[512] = {}; + auto_snprintf(msg, sizeof(msg), + AUTO_STR("ReaPack could not read %s's index.\n\n") + + AUTO_STR("Synchronize your packages and try again.\n") + AUTO_STR("If the problem persist, contact the repository maintainer.\n\n") + + AUTO_STR("[error description: %s]"), + make_autostring(remote.name()).c_str(), desc.c_str() + ); + + MessageBox(handle(), msg, AUTO_STR("ReaPack Warning"), MB_OK); + return; + } + unique_ptr<RemoteIndex> ptr(index); Dialog::Show<About>(instance(), handle(), index);