| 3750 | } |
| 3751 | |
| 3752 | void Config::removeDisplayView(const char * display, const char * view) |
| 3753 | { |
| 3754 | if (!display || !*display) |
| 3755 | { |
| 3756 | throw Exception("Can't remove a view from a display with an empty display name."); |
| 3757 | } |
| 3758 | if (!view || !*view) |
| 3759 | { |
| 3760 | throw Exception("Can't remove a view from a display with an empty view name."); |
| 3761 | } |
| 3762 | |
| 3763 | const std::string displayNameRef(display); |
| 3764 | |
| 3765 | // Check if the display exists. |
| 3766 | |
| 3767 | DisplayMap::iterator iter = FindDisplay(getImpl()->m_displays, display); |
| 3768 | if (iter==getImpl()->m_displays.end()) |
| 3769 | { |
| 3770 | std::ostringstream os; |
| 3771 | os << "Could not find a display named '" << display << "' to be removed from config."; |
| 3772 | throw Exception(os.str().c_str()); |
| 3773 | } |
| 3774 | |
| 3775 | ViewVec & views = iter->second.m_views; |
| 3776 | StringUtils::StringVec & sharedViews = iter->second.m_sharedViews; |
| 3777 | |
| 3778 | const std::string viewNameRef(view); |
| 3779 | if (!StringUtils::Remove(sharedViews, view)) |
| 3780 | { |
| 3781 | // view is not a shared view. |
| 3782 | // Is it a view? |
| 3783 | auto viewIt = FindView(views, view); |
| 3784 | if (viewIt == views.end()) |
| 3785 | { |
| 3786 | std::ostringstream os; |
| 3787 | os << "Could not find a view named '" << view; |
| 3788 | os << " to be removed from the display named '" << display << "'."; |
| 3789 | throw Exception(os.str().c_str()); |
| 3790 | } |
| 3791 | |
| 3792 | views.erase(viewIt); |
| 3793 | } |
| 3794 | |
| 3795 | // Check if the display needs to be removed also. |
| 3796 | if (views.empty() && sharedViews.empty()) |
| 3797 | { |
| 3798 | getImpl()->m_displays.erase(iter); |
| 3799 | } |
| 3800 | |
| 3801 | getImpl()->m_displayCache.clear(); |
| 3802 | |
| 3803 | AutoMutex lock(getImpl()->m_cacheidMutex); |
| 3804 | getImpl()->resetCacheIDs(); |
| 3805 | } |
| 3806 | |
| 3807 | void Config::clearDisplays() |
| 3808 | { |