From c870f9116410fbf8138c517bbb17031600e461ea Mon Sep 17 00:00:00 2001 From: fgerlits Date: Tue, 28 Jun 2005 19:03:54 +0000 Subject: [PATCH] fixed bug #1078 --- .../gLiveSupport/src/GLiveSupport.cxx | 29 ++++++++++++------- .../products/gLiveSupport/src/GLiveSupport.h | 8 ++--- .../src/SimplePlaylistManagementWindow.cxx | 8 ++--- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index a2f73f7ad..61261d590 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.52 $ + Version : $Revision: 1.53 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ ------------------------------------------------------------------------------*/ @@ -637,29 +637,31 @@ LiveSupport :: GLiveSupport :: GLiveSupport :: openPlaylistForEditing(Ptr::Ref playlistId) throw (XmlRpcException) { - releaseEditedPlaylist(); + cancelEditedPlaylist(); if (!playlistId.get()) { playlistId = storage->createPlaylist(sessionId); } editedPlaylist = storage->editPlaylist(sessionId, playlistId); + editedPlaylist->createSavedCopy(); return editedPlaylist; } /*------------------------------------------------------------------------------ - * Release the edited playlist. + * Cancel the edited playlist: undo changes and release the lock. *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: releaseEditedPlaylist(void) +GLiveSupport :: cancelEditedPlaylist(void) throw (XmlRpcException) { - if (editedPlaylist.get()) { + if (editedPlaylist) { if (editedPlaylist->isLocked()) { - storage->releasePlaylist(editedPlaylist); + editedPlaylist->revertToSavedCopy(); + storage->savePlaylist(sessionId, editedPlaylist); } editedPlaylist.reset(); } @@ -703,12 +705,17 @@ LiveSupport :: GLiveSupport :: GLiveSupport :: savePlaylist(void) throw (XmlRpcException) { - storage->savePlaylist(sessionId, editedPlaylist); + Ptr::Ref playlist; - Ptr::Ref playlist = storage->getPlaylist(sessionId, - editedPlaylist->getId()); - addToScratchpad(playlist); - editedPlaylist.reset(); + if (editedPlaylist) { + if (editedPlaylist->isLocked()) { + editedPlaylist->deleteSavedCopy(); + storage->savePlaylist(sessionId, editedPlaylist); + playlist = storage->getPlaylist(sessionId, editedPlaylist->getId()); + addToScratchpad(playlist); + } + editedPlaylist.reset(); + } return playlist; } diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index 122fe1490..5413ab394 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.40 $ + Version : $Revision: 1.41 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ ------------------------------------------------------------------------------*/ @@ -102,7 +102,7 @@ class MasterPanelWindow; * respective documentation. * * @author $Author: fgerlits $ - * @version $Revision: 1.40 $ + * @version $Revision: 1.41 $ * @see LocalizedObject#getBundle(const xmlpp::Element &) * @see AuthenticationClientFactory * @see StorageClientFactory @@ -546,13 +546,13 @@ class GLiveSupport : public LocalizedConfigurable, savePlaylist(void) throw (XmlRpcException); /** - * Release the playlist that was opened for editing. + * Cancel the edited playlist: undo changes and release the lock. * * @exception XmlRpcException on XML-RPC errors. * @see #openPlaylistForEditing */ void - releaseEditedPlaylist(void) throw (XmlRpcException); + cancelEditedPlaylist(void) throw (XmlRpcException); /** * Return the scheduled entries for a specified time interval. diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx index ad5c5b5fb..59ee56e4a 100644 --- a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx +++ b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.14 $ + Version : $Revision: 1.15 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -175,6 +175,7 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () Ptr::Ref playlist; title.reset(new Glib::ustring(nameEntry->get_text())); + // TODO: check for empty title and display "are you sure?" message playlist = gLiveSupport->getEditedPlaylist(); if (!playlist) { @@ -190,8 +191,6 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () *playlist->getTitle()); statusBar->set_text(*statusText); - gLiveSupport->releaseEditedPlaylist(); - // clean the entry fields nameEntry->set_text(""); entriesModel->clear(); @@ -207,7 +206,8 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () void SimplePlaylistManagementWindow :: onCloseButtonClicked (void) throw () { - gLiveSupport->releaseEditedPlaylist(); + // TODO: display "are you sure?" message + gLiveSupport->cancelEditedPlaylist(); hide(); }