diff options
Diffstat (limited to 'src/desktop.cpp')
| -rw-r--r-- | src/desktop.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp index 6314621c1..f58864955 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -720,7 +720,13 @@ void SPDesktop::set_display_area(NR::Rect const &a, NR::Coord b, bool log) void SPDesktop::add_perspective (Box3D::Perspective3D * const persp) { + // check that the perspective is not yet linked to another desktop + if (persp->desktop != NULL) { + g_assert (persp->desktop == this); + } + // FIXME: Should we handle the case that the perspectives have equal VPs but are not identical? + // If so, we need to take care of relinking the boxes, etc. if (persp == NULL || g_slist_find (this->perspectives, persp)) return; this->perspectives = g_slist_prepend (this->perspectives, persp); persp->desktop = this; @@ -729,15 +735,24 @@ SPDesktop::add_perspective (Box3D::Perspective3D * const persp) void SPDesktop::remove_perspective (Box3D::Perspective3D * const persp) { if (persp == NULL) return; - if (!g_slist_find (this->perspectives, persp)) { g_warning ("Could not find perspective in current desktop. Not removed.\n"); return; } - this->perspectives = g_slist_remove (this->perspectives, persp); } +// find an existing perspective whose VPs are equal to those of persp +Box3D::Perspective3D * SPDesktop::find_perspective (Box3D::Perspective3D * const persp) +{ + for (GSList *p = this->perspectives; p != NULL; p = p->next) { + if (*((Box3D::Perspective3D *) p->data) == *persp) { + return ((Box3D::Perspective3D *) p->data); + } + } + return NULL; // perspective was not found +} + /** * Return viewbox dimensions. */ |
