Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
efcb8d2e
Commit
efcb8d2e
authored
6 years ago
by
Pospelov, Gennady
Browse files
Options
Downloads
Patches
Plain Diff
Fix for autosave bug: mutexes against saving the data on disk while tuning it in real time
parent
015e00c0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/coregui/Models/DataItem.cpp
+13
-0
13 additions, 0 deletions
GUI/coregui/Models/DataItem.cpp
GUI/coregui/Models/DataItem.h
+4
-0
4 additions, 0 deletions
GUI/coregui/Models/DataItem.h
GUI/coregui/Models/JobItemUtils.cpp
+2
-4
2 additions, 4 deletions
GUI/coregui/Models/JobItemUtils.cpp
with
19 additions
and
4 deletions
GUI/coregui/Models/DataItem.cpp
+
13
−
0
View file @
efcb8d2e
...
@@ -16,12 +16,14 @@
...
@@ -16,12 +16,14 @@
#include
"BornAgainNamespace.h"
#include
"BornAgainNamespace.h"
#include
"ComboProperty.h"
#include
"ComboProperty.h"
#include
"GUIHelpers.h"
#include
"GUIHelpers.h"
#include
"IntensityDataIOFactory.h"
const
QString
DataItem
::
P_FILE_NAME
=
"FileName"
;
const
QString
DataItem
::
P_FILE_NAME
=
"FileName"
;
const
QString
DataItem
::
P_AXES_UNITS
=
"Axes Units"
;
const
QString
DataItem
::
P_AXES_UNITS
=
"Axes Units"
;
void
DataItem
::
setOutputData
(
OutputData
<
double
>*
data
)
void
DataItem
::
setOutputData
(
OutputData
<
double
>*
data
)
{
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_update_data_mutex
);
m_data
.
reset
(
data
);
m_data
.
reset
(
data
);
}
}
...
@@ -31,6 +33,7 @@ void DataItem::setRawDataVector(const OutputData<double>* data)
...
@@ -31,6 +33,7 @@ void DataItem::setRawDataVector(const OutputData<double>* data)
throw
GUIHelpers
::
Error
(
"DataItem::setRawDataVector() -> Error. "
throw
GUIHelpers
::
Error
(
"DataItem::setRawDataVector() -> Error. "
"Different dimensions of data."
);
"Different dimensions of data."
);
}
}
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_update_data_mutex
);
m_data
->
setRawDataVector
(
data
->
getRawDataVector
());
m_data
->
setRawDataVector
(
data
->
getRawDataVector
());
}
}
...
@@ -56,6 +59,16 @@ QString DataItem::selectedAxesUnits() const
...
@@ -56,6 +59,16 @@ QString DataItem::selectedAxesUnits() const
return
combo
.
getValue
();
return
combo
.
getValue
();
}
}
void
DataItem
::
saveData
(
const
QString
&
projectDir
)
{
if
(
!
getOutputData
())
return
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_update_data_mutex
);
IntensityDataIOFactory
::
writeOutputData
(
*
getOutputData
(),
fileName
(
projectDir
).
toStdString
());
}
void
DataItem
::
resetToDefault
()
void
DataItem
::
resetToDefault
()
{
{
ComboProperty
combo
=
ComboProperty
()
<<
Constants
::
UnitsNbins
;
ComboProperty
combo
=
ComboProperty
()
<<
Constants
::
UnitsNbins
;
...
...
This diff is collapsed.
Click to expand it.
GUI/coregui/Models/DataItem.h
+
4
−
0
View file @
efcb8d2e
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include
"SessionItem.h"
#include
"SessionItem.h"
#include
"OutputData.h"
#include
"OutputData.h"
#include
<QDateTime>
#include
<QDateTime>
#include
<mutex>
class
InstrumentItem
;
class
InstrumentItem
;
...
@@ -50,11 +51,14 @@ public:
...
@@ -50,11 +51,14 @@ public:
//! Returns data to default state (no dimensional units, default axes' names)
//! Returns data to default state (no dimensional units, default axes' names)
virtual
void
resetToDefault
()
=
0
;
virtual
void
resetToDefault
()
=
0
;
void
saveData
(
const
QString
&
projectDir
);
protected
:
protected
:
DataItem
(
const
QString
&
modelType
);
DataItem
(
const
QString
&
modelType
);
std
::
unique_ptr
<
OutputData
<
double
>>
m_data
;
//!< simulation results
std
::
unique_ptr
<
OutputData
<
double
>>
m_data
;
//!< simulation results
QDateTime
m_last_modified
;
QDateTime
m_last_modified
;
std
::
mutex
m_update_data_mutex
;
};
};
#endif // DATAITEM_H
#endif // DATAITEM_H
This diff is collapsed.
Click to expand it.
GUI/coregui/Models/JobItemUtils.cpp
+
2
−
4
View file @
efcb8d2e
...
@@ -115,12 +115,10 @@ void JobItemUtils::loadIntensityData(DataItem *intensityItem, const QString &pro
...
@@ -115,12 +115,10 @@ void JobItemUtils::loadIntensityData(DataItem *intensityItem, const QString &pro
void
JobItemUtils
::
saveIntensityData
(
DataItem
*
intensityItem
,
const
QString
&
projectDir
)
void
JobItemUtils
::
saveIntensityData
(
DataItem
*
intensityItem
,
const
QString
&
projectDir
)
{
{
if
(
!
intensityItem
||
!
intensityItem
->
getOutputData
()
)
if
(
!
intensityItem
)
return
;
return
;
QString
filename
=
intensityItem
->
fileName
(
projectDir
);
intensityItem
->
saveData
(
projectDir
);
IntensityDataIOFactory
::
writeOutputData
(
*
intensityItem
->
getOutputData
(),
filename
.
toStdString
());
}
}
//! Correspondance of domain detector axes types to their gui counterpart.
//! Correspondance of domain detector axes types to their gui counterpart.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment