File tree 2 files changed +21
-4
lines changed
2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 39
39
#include < assert.h>
40
40
41
41
ProjectPages::ProjectPages (Qt::LayoutDirection const layout_direction)
42
+ : m_refCounter(0 )
42
43
{
43
44
initSubPagesInOrder (layout_direction);
44
45
}
45
46
46
47
ProjectPages::ProjectPages (
47
- std::vector<ImageInfo> const & info,
48
+ std::vector<ImageInfo> const & info,
48
49
Qt::LayoutDirection const layout_direction)
50
+ : m_refCounter(0 )
49
51
{
50
52
initSubPagesInOrder (layout_direction);
51
53
@@ -74,8 +76,9 @@ ProjectPages::ProjectPages(
74
76
}
75
77
76
78
ProjectPages::ProjectPages (
77
- std::vector<ImageFileInfo> const & files,
79
+ std::vector<ImageFileInfo> const & files,
78
80
Pages const pages, Qt::LayoutDirection const layout_direction)
81
+ : m_refCounter(0 )
79
82
{
80
83
initSubPagesInOrder (layout_direction);
81
84
Original file line number Diff line number Diff line change 20
20
#define PROJECT_PAGES_H_
21
21
22
22
#include " NonCopyable.h"
23
- #include " RefCountable.h"
24
23
#include " ImageMetadata.h"
25
24
#include " ImageId.h"
26
25
#include " PageId.h"
27
26
#include " PageInfo.h"
28
27
#include " PageView.h"
29
28
#include " BeforeOrAfter.h"
30
29
#include " VirtualFunction.h"
30
+ #include < QAtomicInt>
31
31
#include < QObject>
32
32
#include < QMutex>
33
33
#include < QString>
@@ -45,7 +45,7 @@ class AbstractRelinker;
45
45
class QDomElement ;
46
46
class QSize ;
47
47
48
- class ProjectPages : public QObject , public RefCountable
48
+ class ProjectPages : public QObject
49
49
{
50
50
Q_OBJECT
51
51
DECLARE_NON_COPYABLE (ProjectPages)
@@ -63,6 +63,19 @@ class ProjectPages : public QObject, public RefCountable
63
63
64
64
virtual ~ProjectPages ();
65
65
66
+ void ref () const
67
+ {
68
+ m_refCounter.fetchAndAddRelaxed (1 );
69
+ }
70
+
71
+ void unref () const
72
+ {
73
+ if (m_refCounter.fetchAndAddRelease (-1 ) == 1 )
74
+ {
75
+ delete this ;
76
+ }
77
+ }
78
+
66
79
Qt::LayoutDirection layoutDirection () const ;
67
80
68
81
PageSequence toPageSequence (PageView view) const ;
@@ -167,6 +180,7 @@ class ProjectPages : public QObject, public RefCountable
167
180
168
181
PageInfo unremovePageImpl (PageId const & page_id, bool & modified);
169
182
183
+ mutable QAtomicInt m_refCounter;
170
184
mutable QMutex m_mutex;
171
185
std::vector<ImageDesc> m_images;
172
186
PageId::SubPage m_subPagesInOrder[2 ];
You can’t perform that action at this time.
0 commit comments