Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. Index: kis_node.cpp
  2. ===================================================================
  3. --- kis_node.cpp (revision 1189045)
  4. +++ kis_node.cpp (working copy)
  5. @@ -51,10 +51,13 @@
  6. {
  7. public:
  8. Private()
  9. - : graphListener(0)
  10. - , nodeProgressProxy(0) {
  11. + : nastyMutex(QMutex::Recursive)
  12. + , graphListener(0)
  13. + , nodeProgressProxy(0) {
  14. }
  15.  
  16. + QMutex nastyMutex;
  17. +
  18. KisNodeWSP parent;
  19. KisNodeGraphListener * graphListener;
  20. QList<KisNodeSP> nodes;
  21. @@ -62,7 +65,7 @@
  22. };
  23.  
  24. KisNode::KisNode()
  25. - : m_d(new Private())
  26. + : m_d(new Private())
  27. {
  28. m_d->parent = 0;
  29. m_d->graphListener = 0;
  30. @@ -70,8 +73,8 @@
  31.  
  32.  
  33. KisNode::KisNode(const KisNode & rhs)
  34. - : KisBaseNode(rhs)
  35. - , m_d(new Private())
  36. + : KisBaseNode(rhs),
  37. + m_d(new Private())
  38. {
  39. m_d->parent = 0;
  40. m_d->graphListener = rhs.m_d->graphListener;
  41. @@ -143,6 +146,8 @@
  42.  
  43. KisNodeSP KisNode::firstChild() const
  44. {
  45. + QMutexLocker locker(&m_d->nastyMutex);
  46. +
  47. if (!m_d->nodes.isEmpty())
  48. return m_d->nodes.first();
  49. else
  50. @@ -151,6 +156,8 @@
  51.  
  52. KisNodeSP KisNode::lastChild() const
  53. {
  54. + QMutexLocker locker(&m_d->nastyMutex);
  55. +
  56. if (!m_d->nodes.isEmpty())
  57. return m_d->nodes.last();
  58. else
  59. @@ -180,6 +187,8 @@
  60.  
  61. KisNodeSP KisNode::at(quint32 index) const
  62. {
  63. + QMutexLocker locker(&m_d->nastyMutex);
  64. +
  65. if (!m_d->nodes.isEmpty() && index < (quint32)m_d->nodes.size()) {
  66. return m_d->nodes.at(index);
  67. }
  68. @@ -189,6 +198,8 @@
  69.  
  70. int KisNode::index(const KisNodeSP node) const
  71. {
  72. + QMutexLocker locker(&m_d->nastyMutex);
  73. +
  74. if (m_d->nodes.contains(node)) {
  75. return m_d->nodes.indexOf(node);
  76. }
  77. @@ -198,6 +209,8 @@
  78.  
  79. QList<KisNodeSP> KisNode::childNodes(const QStringList & nodeTypes, const KoProperties & properties) const
  80. {
  81. + QMutexLocker locker(&m_d->nastyMutex);
  82. +
  83. QList<KisNodeSP> nodes;
  84.  
  85. foreach(const KisNodeSP & node, m_d->nodes) {
  86. @@ -216,6 +229,8 @@
  87.  
  88. bool KisNode::add(KisNodeSP newNode, KisNodeSP aboveThis)
  89. {
  90. + QMutexLocker locker(&m_d->nastyMutex);
  91. +
  92. Q_ASSERT(newNode);
  93.  
  94. if (!newNode) return false;
  95. @@ -257,6 +272,8 @@
  96.  
  97. bool KisNode::remove(quint32 index)
  98. {
  99. + QMutexLocker locker(&m_d->nastyMutex);
  100. +
  101. if (index < childCount()) {
  102. KisNodeSP removedNode = at(index);
  103. removedNode->prepareForRemoval();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement