From 48704877ca1dc44b9215ec834e93f34fd953b2fb Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 2 Feb 2014 00:09:03 +0100 Subject: - bugfix: upon moving files between mods, an attempt was made to access origins for both, even if one (or both) mods weren't active - bugfix: plugin-list should now deal with nested "layoutAboutToBeChanged" calls gracefully. May be the reason of a bug. --- src/pluginlist.h | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/pluginlist.h') diff --git a/src/pluginlist.h b/src/pluginlist.h index f8c69e11..95f90e09 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -33,13 +33,46 @@ along with Mod Organizer. If not, see . #include + +template +class ChangeBracket { +public: + ChangeBracket(C *model) + : m_Model(nullptr) + { + QVariant var = model->property("__aboutToChange"); + bool aboutToChange = var.isValid() && var.toBool(); + if (!aboutToChange) { + model->layoutAboutToBeChanged(); + model->setProperty("__aboutToChange", true); + m_Model = model; + } + } + ~ChangeBracket() { + finish(); + } + + void finish() { + if (m_Model != nullptr) { + m_Model->layoutChanged(); + m_Model->setProperty("__aboutToChange", false); + m_Model = nullptr; + } + } + +private: + C *m_Model; +}; + + + /** * @brief model representing the plugins (.esp/.esm) in the current virtual data folder **/ class PluginList : public QAbstractTableModel, public MOBase::IPluginList { Q_OBJECT - + friend class ChangeBracket; public: enum EColumn { @@ -225,7 +258,6 @@ private: friend bool ByDate(const ESPInfo& LHS, const ESPInfo& RHS); friend bool ByPriority(const ESPInfo& LHS, const ESPInfo& RHS); - class BossDLL : public PDLL { DECLARE_CLASS(BossDLL) @@ -353,4 +385,6 @@ private: }; + + #endif // PLUGINLIST_H -- cgit v1.3.1