Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
59207cbb
Commit
59207cbb
authored
8 years ago
by
Craig Watson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved document metadata saving to UBPersistenceManager's worker thread
(Reading is still done synchronously, for now at least)
parent
46ce553d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
27 deletions
+85
-27
UBBoardController.cpp
src/board/UBBoardController.cpp
+1
-1
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+43
-15
UBPersistenceManager.h
src/core/UBPersistenceManager.h
+2
-1
UBPersistenceWorker.cpp
src/core/UBPersistenceWorker.cpp
+15
-1
UBPersistenceWorker.h
src/core/UBPersistenceWorker.h
+4
-1
UBDocumentController.cpp
src/document/UBDocumentController.cpp
+8
-8
UBDocumentProxy.cpp
src/document/UBDocumentProxy.cpp
+10
-0
UBDocumentProxy.h
src/document/UBDocumentProxy.h
+2
-0
No files found.
src/board/UBBoardController.cpp
View file @
59207cbb
...
...
@@ -1552,7 +1552,7 @@ void UBBoardController::moveSceneToIndex(int source, int target)
UBDocumentContainer
::
movePageToIndex
(
source
,
target
);
selectedDocument
()
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
selectedDocument
());
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
selectedDocument
());
mMovingSceneIndex
=
source
;
setActiveDocumentScene
(
target
);
mMovingSceneIndex
=
-
1
;
...
...
This diff is collapsed.
Click to expand it.
src/core/UBPersistenceManager.cpp
View file @
59207cbb
...
...
@@ -79,14 +79,33 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent)
mThread
=
new
QThread
;
mWorker
=
new
UBPersistenceWorker
();
mWorker
->
moveToThread
(
mThread
);
connect
(
mWorker
,
SIGNAL
(
error
(
QString
)),
this
,
SLOT
(
errorString
(
QString
)));
connect
(
mThread
,
SIGNAL
(
started
()),
mWorker
,
SLOT
(
process
()));
connect
(
mWorker
,
SIGNAL
(
finished
()),
mThread
,
SLOT
(
quit
()));
connect
(
mWorker
,
SIGNAL
(
finished
()),
this
,
SLOT
(
onWorkerFinished
()));
connect
(
mWorker
,
SIGNAL
(
finished
()),
mWorker
,
SLOT
(
deleteLater
()));
connect
(
mThread
,
SIGNAL
(
finished
()),
mThread
,
SLOT
(
deleteLater
()));
connect
(
mWorker
,
SIGNAL
(
sceneLoaded
(
QByteArray
,
UBDocumentProxy
*
,
int
)),
this
,
SLOT
(
onSceneLoaded
(
QByteArray
,
UBDocumentProxy
*
,
int
)));
connect
(
mWorker
,
SIGNAL
(
scenePersisted
(
UBGraphicsScene
*
)),
this
,
SLOT
(
onScenePersisted
(
UBGraphicsScene
*
)));
connect
(
mWorker
,
SIGNAL
(
error
(
QString
)),
this
,
SLOT
(
errorString
(
QString
)));
connect
(
mThread
,
SIGNAL
(
started
()),
mWorker
,
SLOT
(
process
()));
connect
(
mWorker
,
SIGNAL
(
finished
()),
mThread
,
SLOT
(
quit
()));
connect
(
mWorker
,
SIGNAL
(
finished
()),
this
,
SLOT
(
onWorkerFinished
()));
connect
(
mWorker
,
SIGNAL
(
finished
()),
mWorker
,
SLOT
(
deleteLater
()));
connect
(
mThread
,
SIGNAL
(
finished
()),
mThread
,
SLOT
(
deleteLater
()));
connect
(
mWorker
,
SIGNAL
(
sceneLoaded
(
QByteArray
,
UBDocumentProxy
*
,
int
)),
this
,
SLOT
(
onSceneLoaded
(
QByteArray
,
UBDocumentProxy
*
,
int
)));
connect
(
mWorker
,
SIGNAL
(
scenePersisted
(
UBGraphicsScene
*
)),
this
,
SLOT
(
onScenePersisted
(
UBGraphicsScene
*
)));
connect
(
mWorker
,
SIGNAL
(
metadataPersisted
(
UBDocumentProxy
*
)),
this
,
SLOT
(
onMetadataPersisted
(
UBDocumentProxy
*
)));
mThread
->
start
();
}
...
...
@@ -114,6 +133,11 @@ void UBPersistenceManager::onScenePersisted(UBGraphicsScene* scene)
scene
=
NULL
;
}
void
UBPersistenceManager
::
onMetadataPersisted
(
UBDocumentProxy
*
proxy
)
{
delete
proxy
;
}
void
UBPersistenceManager
::
onWorkerFinished
()
{
mIsWorkerFinished
=
true
;
...
...
@@ -752,14 +776,14 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
mSceneCache
.
insert
(
pDocumentProxy
,
pSceneIndex
,
pScene
);
if
(
pDocumentProxy
->
isModified
())
UBMetadataDcSubsetAdaptor
::
persist
(
pDocumentProxy
);
persistDocumentMetadata
(
pDocumentProxy
,
forceImmediateSaving
);
if
(
pScene
->
isModified
())
{
UBThumbnailAdaptor
::
persistScene
(
pDocumentProxy
,
pScene
,
pSceneIndex
);
if
(
forceImmediateSaving
)
UBSvgSubsetAdaptor
::
persistScene
(
pDocumentProxy
,
pScene
,
pSceneIndex
);
else
{
else
{
UBGraphicsScene
*
copiedScene
=
pScene
->
sceneDeepCopy
();
mWorker
->
saveScene
(
pDocumentProxy
,
copiedScene
,
pSceneIndex
);
pScene
->
setModified
(
false
);
...
...
@@ -769,13 +793,17 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
}
UBDocumentProxy
*
UBPersistenceManager
::
persistDocumentMetadata
(
UBDocumentProxy
*
pDocumentProxy
)
void
UBPersistenceManager
::
persistDocumentMetadata
(
UBDocumentProxy
*
pDocumentProxy
,
bool
forceImmediateSaving
)
{
UBMetadataDcSubsetAdaptor
::
persist
(
pDocumentProxy
);
emit
documentMetadataChanged
(
pDocumentProxy
);
if
(
forceImmediateSaving
)
{
UBMetadataDcSubsetAdaptor
::
persist
(
pDocumentProxy
);
emit
documentMetadataChanged
(
pDocumentProxy
);
}
return
pDocumentProxy
;
else
{
UBDocumentProxy
*
copy
=
pDocumentProxy
->
deepCopy
();
mWorker
->
saveMetadata
(
copy
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/core/UBPersistenceManager.h
View file @
59207cbb
...
...
@@ -64,7 +64,7 @@ class UBPersistenceManager : public QObject
virtual
UBDocumentProxy
*
createDocument
(
const
QString
&
pGroupName
=
""
,
const
QString
&
pName
=
""
,
bool
withEmptyPage
=
true
);
virtual
UBDocumentProxy
*
createDocumentFromDir
(
const
QString
&
pDocumentDirectory
,
const
QString
&
pGroupName
=
""
,
const
QString
&
pName
=
""
);
virtual
UBDocumentProxy
*
persistDocumentMetadata
(
UBDocumentProxy
*
pDocumentProxy
);
virtual
void
persistDocumentMetadata
(
UBDocumentProxy
*
pDocumentProxy
,
bool
forceImmediateSaving
=
false
);
virtual
UBDocumentProxy
*
duplicateDocument
(
UBDocumentProxy
*
pDocumentProxy
);
...
...
@@ -161,6 +161,7 @@ class UBPersistenceManager : public QObject
void
onSceneLoaded
(
QByteArray
,
UBDocumentProxy
*
,
int
);
void
onWorkerFinished
();
void
onScenePersisted
(
UBGraphicsScene
*
scene
);
void
onMetadataPersisted
(
UBDocumentProxy
*
proxy
);
};
...
...
This diff is collapsed.
Click to expand it.
src/core/UBPersistenceWorker.cpp
View file @
59207cbb
...
...
@@ -25,6 +25,7 @@
#include "UBPersistenceWorker.h"
#include "adaptors/UBSvgSubsetAdaptor.h"
#include "adaptors/UBThumbnailAdaptor.h"
#include "adaptors/UBMetadataDcSubsetAdaptor.h"
UBPersistenceWorker
::
UBPersistenceWorker
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
@@ -48,6 +49,13 @@ void UBPersistenceWorker::readScene(UBDocumentProxy* proxy, const int pageIndex)
mSemaphore
.
release
();
}
void
UBPersistenceWorker
::
saveMetadata
(
UBDocumentProxy
*
proxy
)
{
PersistenceInformation
entry
=
{
WriteMetadata
,
proxy
,
NULL
,
0
};
saves
.
append
(
entry
);
mSemaphore
.
release
();
}
void
UBPersistenceWorker
::
applicationWillClose
()
{
qDebug
()
<<
"applicaiton Will close signal received"
;
...
...
@@ -65,9 +73,15 @@ void UBPersistenceWorker::process()
UBSvgSubsetAdaptor
::
persistScene
(
info
.
proxy
,
info
.
scene
,
info
.
sceneIndex
);
emit
scenePersisted
(
info
.
scene
);
}
else
{
else
if
(
info
.
action
==
ReadScene
)
{
emit
sceneLoaded
(
UBSvgSubsetAdaptor
::
loadSceneAsText
(
info
.
proxy
,
info
.
sceneIndex
),
info
.
proxy
,
info
.
sceneIndex
);
}
else
if
(
info
.
action
==
WriteMetadata
)
{
if
(
info
.
proxy
->
isModified
())
{
UBMetadataDcSubsetAdaptor
::
persist
(
info
.
proxy
);
emit
metadataPersisted
(
info
.
proxy
);
}
}
mSemaphore
.
acquire
();
}
while
(
!
mReceivedApplicationClosing
);
qDebug
()
<<
"process will stop"
;
...
...
This diff is collapsed.
Click to expand it.
src/core/UBPersistenceWorker.h
View file @
59207cbb
...
...
@@ -32,7 +32,8 @@
typedef
enum
{
WriteScene
=
0
,
ReadScene
ReadScene
,
WriteMetadata
}
ActionType
;
typedef
struct
{
...
...
@@ -50,12 +51,14 @@ public:
void
saveScene
(
UBDocumentProxy
*
proxy
,
UBGraphicsScene
*
scene
,
const
int
pageIndex
);
void
readScene
(
UBDocumentProxy
*
proxy
,
const
int
pageIndex
);
void
saveMetadata
(
UBDocumentProxy
*
proxy
);
signals
:
void
finished
();
void
error
(
QString
string
);
void
sceneLoaded
(
QByteArray
text
,
UBDocumentProxy
*
proxy
,
const
int
pageIndex
);
void
scenePersisted
(
UBGraphicsScene
*
scene
);
void
metadataPersisted
(
UBDocumentProxy
*
proxy
);
public
slots
:
void
process
();
...
...
This diff is collapsed.
Click to expand it.
src/document/UBDocumentController.cpp
View file @
59207cbb
...
...
@@ -517,7 +517,7 @@ void UBDocumentController::duplicateSelectedItem()
duplicatePages
(
selectedSceneIndexes
);
emit
documentThumbnailsUpdated
(
this
);
selectedDocument
()
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
selectedDocument
());
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
selectedDocument
());
mDocumentUI
->
thumbnailWidget
->
selectItemAt
(
selectedSceneIndexes
.
last
()
+
selectedSceneIndexes
.
size
());
}
}
...
...
@@ -534,7 +534,7 @@ void UBDocumentController::duplicateSelectedItem()
UBDocumentProxy
*
duplicatedDoc
=
UBPersistenceManager
::
persistenceManager
()
->
duplicateDocument
(
source
);
duplicatedDoc
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
duplicatedDoc
);
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
duplicatedDoc
);
selectDocument
(
duplicatedDoc
,
false
);
...
...
@@ -1104,7 +1104,7 @@ void UBDocumentController::addFolderOfImages()
else
{
document
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
document
);
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
document
);
reloadThumbnails
();
}
}
...
...
@@ -1150,7 +1150,7 @@ bool UBDocumentController::addFileToDocument(UBDocumentProxy* document)
if
(
success
)
{
document
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
document
);
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
document
);
}
else
{
...
...
@@ -1169,7 +1169,7 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source,
if
(
UBDocumentContainer
::
movePageToIndex
(
source
,
target
))
{
proxy
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
proxy
);
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
proxy
);
mDocumentUI
->
thumbnailWidget
->
hightlightItem
(
target
);
}
...
...
@@ -1497,7 +1497,7 @@ void UBDocumentController::addToDocument()
mDocumentUI
->
thumbnailWidget
->
selectItemAt
(
newActiveSceneIndex
,
false
);
selectDocument
(
mBoardController
->
selectedDocument
());
mBoardController
->
selectedDocument
()
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
mBoardController
->
selectedDocument
());
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
mBoardController
->
selectedDocument
());
UBApplication
::
applicationController
->
showBoard
();
}
...
...
@@ -1678,7 +1678,7 @@ void UBDocumentController::addImages()
else
{
document
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
document
);
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
document
);
reloadThumbnails
();
}
}
...
...
@@ -1791,7 +1791,7 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
UBDocumentContainer
::
deletePages
(
sceneIndexes
);
proxy
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
UB
MetadataDcSubsetAdaptor
::
persist
(
proxy
);
UB
PersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
proxy
);
int
minIndex
=
proxy
->
pageCount
()
-
1
;
foreach
(
int
i
,
sceneIndexes
)
...
...
This diff is collapsed.
Click to expand it.
src/document/UBDocumentProxy.cpp
View file @
59207cbb
...
...
@@ -69,6 +69,16 @@ UBDocumentProxy::~UBDocumentProxy()
// NOOP
}
UBDocumentProxy
*
UBDocumentProxy
::
deepCopy
()
const
{
UBDocumentProxy
*
copy
=
new
UBDocumentProxy
();
copy
->
mPersistencePath
=
QString
(
mPersistencePath
);
copy
->
mMetaDatas
=
QHash
<
QString
,
QVariant
>
(
mMetaDatas
);
copy
->
mIsModified
=
mIsModified
;
copy
->
mPageCount
=
mPageCount
;
}
int
UBDocumentProxy
::
pageCount
()
{
...
...
This diff is collapsed.
Click to expand it.
src/document/UBDocumentProxy.h
View file @
59207cbb
...
...
@@ -49,6 +49,8 @@ class UBDocumentProxy : public QObject
virtual
~
UBDocumentProxy
();
UBDocumentProxy
*
deepCopy
()
const
;
QString
persistencePath
()
const
;
void
setPersistencePath
(
const
QString
&
pPersistencePath
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment