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
ccf7532a
Commit
ccf7532a
authored
Feb 25, 2014
by
-f
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
waiting the end of worker thread correctly
parent
c053c7a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+15
-1
UBPersistenceManager.h
src/core/UBPersistenceManager.h
+2
-0
No files found.
src/core/UBPersistenceManager.cpp
View file @
ccf7532a
...
...
@@ -65,6 +65,7 @@ UBPersistenceManager * UBPersistenceManager::sSingleton = 0;
UBPersistenceManager
::
UBPersistenceManager
(
QObject
*
pParent
)
:
QObject
(
pParent
)
,
mHasPurgedDocuments
(
false
)
,
mIsWorkerFinished
(
false
)
{
mDocumentSubDirectories
<<
imageDirectory
;
...
...
@@ -81,6 +82,7 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent)
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
)));
...
...
@@ -105,11 +107,24 @@ void UBPersistenceManager::destroy()
sSingleton
=
NULL
;
}
void
UBPersistenceManager
::
onWorkerFinished
()
{
mIsWorkerFinished
=
true
;
}
UBPersistenceManager
::~
UBPersistenceManager
()
{
if
(
mWorker
)
mWorker
->
applicationWillClose
();
QTime
time
;
time
.
start
();
qDebug
()
<<
"start waiting"
;
while
(
!
mIsWorkerFinished
)
QCoreApplication
::
processEvents
(
QEventLoop
::
AllEvents
,
100
);
qDebug
()
<<
"stop waiting after "
<<
time
.
elapsed
()
<<
" ms"
;
foreach
(
QPointer
<
UBDocumentProxy
>
proxyGuard
,
documentProxies
)
{
if
(
!
proxyGuard
.
isNull
())
...
...
@@ -117,7 +132,6 @@ UBPersistenceManager::~UBPersistenceManager()
}
// to be sure that all the scenes are stored on disk
mThread
->
wait
(
10
*
1000
);
}
void
UBPersistenceManager
::
errorString
(
QString
error
)
...
...
src/core/UBPersistenceManager.h
View file @
ccf7532a
...
...
@@ -153,11 +153,13 @@ class UBPersistenceManager : public QObject
UBPersistenceWorker
*
mWorker
;
QThread
*
mThread
;
bool
mIsWorkerFinished
;
private
slots
:
void
documentRepositoryChanged
(
const
QString
&
path
);
void
errorString
(
QString
error
);
void
onSceneLoaded
(
QByteArray
,
UBDocumentProxy
*
,
int
);
void
onWorkerFinished
();
};
...
...
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