| 3644 | } |
| 3645 | |
| 3646 | void Config::addDisplaySharedView(const char * display, const char * sharedView) |
| 3647 | { |
| 3648 | if (!display || !*display) |
| 3649 | { |
| 3650 | throw Exception("Shared view could not be added to display: non-empty display name " |
| 3651 | "is needed."); |
| 3652 | } |
| 3653 | if (!sharedView || !*sharedView) |
| 3654 | { |
| 3655 | throw Exception("Shared view could not be added to display: non-empty view name " |
| 3656 | "is needed."); |
| 3657 | } |
| 3658 | |
| 3659 | bool invalidateCache = false; |
| 3660 | DisplayMap::iterator iter = FindDisplay(getImpl()->m_displays, display); |
| 3661 | if (iter == getImpl()->m_displays.end()) |
| 3662 | { |
| 3663 | const auto curSize = getImpl()->m_displays.size(); |
| 3664 | getImpl()->m_displays.resize(curSize + 1); |
| 3665 | getImpl()->m_displays[curSize].first = display; |
| 3666 | iter = std::prev(getImpl()->m_displays.end()); |
| 3667 | invalidateCache = true; |
| 3668 | } |
| 3669 | |
| 3670 | const ViewVec & existingViews = iter->second.m_views; |
| 3671 | auto viewIt = FindView(existingViews, sharedView); |
| 3672 | if (viewIt != existingViews.end()) |
| 3673 | { |
| 3674 | std::ostringstream os; |
| 3675 | os << "There is already a view named '" << sharedView; |
| 3676 | os << "' in the display '" << display << "'."; |
| 3677 | throw Exception(os.str().c_str()); |
| 3678 | } |
| 3679 | |
| 3680 | StringUtils::StringVec & views = iter->second.m_sharedViews; |
| 3681 | if (StringUtils::Contain(views, sharedView)) |
| 3682 | { |
| 3683 | std::ostringstream os; |
| 3684 | os << "There is already a shared view named '" << sharedView; |
| 3685 | os << "' in the display '" << display << "'."; |
| 3686 | throw Exception(os.str().c_str()); |
| 3687 | } |
| 3688 | views.push_back(sharedView); |
| 3689 | if (invalidateCache) |
| 3690 | { |
| 3691 | getImpl()->m_displayCache.clear(); |
| 3692 | } |
| 3693 | AutoMutex lock(getImpl()->m_cacheidMutex); |
| 3694 | getImpl()->resetCacheIDs(); |
| 3695 | } |
| 3696 | |
| 3697 | void Config::addDisplayView(const char * display, const char * view, |
| 3698 | const char * colorSpace, const char * looks) |