Hi all,

Yeah! Rostislav, it works with both modifications. As you said, creating a smart pointer to a dead object fails.

I'm pretty sure this bug wasn't in 2014.03. The way we work here, we usually delete everything in the datamanager and start some other test. It seems highly probable that we would have seen this bug before 2014.10 if it was there. I may be wrong though :)

Thank you for your help.

Le 2015-01-13 05:26, Rostislav Khlebnikov a écrit :
Hi Ingmar,

I think you are referring to the autosave/incremental save conversation
(which I will finally start working on soon) where the multi-threaded
access to the data objects (not the data storage) was discussed.
I also think that the problem with "multiple deletion" of data nodes
existed before 2014.10.

Cheers,
    Rostislav.

On 12/01/2015 22:52, Wegner wrote:
Hi,
did this Problem also exist in earlier releases, so before 2014.10.0
or is it related to the "thread-safety refactoring" of the DataStore,
that I red lately in this list?
Best,
Ingmar


Am 12.01.2015 22:23, schrieb Rostislav Khlebnikov:
Hi,

I see. Seems like the reason why my code works is that I actually
support undo/redo for node deletion (for some data types) and therefore
the nodes are still alive while the deletion process is working and node
guard doesn't crash. I think that the idea is the same though - creating
a smart pointer from a raw pointer to a dead object leads to crash.
The simple solution is actually changing Remove method to start like:

void mitk::StandaloneDataStorage::Remove(const mitk::DataNode* node)
{
    if (!IsInitialized())
      throw std::logic_error("DataStorage not initialized");
    if (node == NULL || !Exists(node))
      return;
...

Something tells me that the without the fix I mentioned before it would
crash in Exists() call, but with it everything seems to work fine.

Rostislav.

On 12/01/2015 20:40, Nil Goyette wrote:
Hi all, ,

Pierre-Yves Menguy
I have the exact same problem using GetDataManagerSelection(). I tried
cout << selection.size(); many times (always selecting 2 nodes) and
the answer changes often :) The program crashes when it's 0 and it
"works" when it's 1. I never saw 2, strangely. I'm pretty sure it's a
race between two or more threads. The first thread is deleting the
user selection and the other thread(s) are reading
GetDataManagerSelection() and trying to delete more nodes.

Rostislav Khlebnikov
It doesn't change anything. I forgot to say that the program crashes
on line 116
mitk::DataNode::ConstPointer nodeGuard(node);
in void mitk::StandaloneDataStorage::Remove(const mitk::DataNode*
node) I thnk Exists() is never called.

Le 2015-01-12 14:27, Pierre-Yves Menguy a écrit :
Hello,
I can't test anything at the moment, but when the event is thrown,
can you request for "this->GetDataManagerSelection();" ?
It is available in the main plugin class, inheriting
QmitkAbstractView.
Doing so, you'll be able to check if children nodes are also selected.


Best regards,

Pierre-Yves Menguy.

Le 2015-01-12 14:30, Rostislav Khlebnikov a écrit :
Hi Nil,

I have the following changes to mitkStandaloneDataStorage.cpp (from
line 128):

bool mitk::StandaloneDataStorage::Exists(const mitk::DataNode* node)
const
{
itk::MutexLockHolder<itk::SimpleFastMutexLock> locked(m_Mutex);

   // Avoid creating smart pointer which would lead to crash
   // return (m_SourceNodes.find(node) != m_SourceNodes.end());

   for (AdjacencyList::const_iterator iter = m_SourceNodes.begin();
iter != m_SourceNodes.end(); ++iter) {
       if (iter->first.GetPointer() == node) {
           return true;
       }
   }
   return false;
}

Likely this is the crash you experience - and this was the way I
fixed it in my fork of MITK (at least I think so as the commit was
done quite some time ago - in May - and the commit message is: "Avoid
creating smart pointer when the node might have been deleted." :)).

Rostislav.

On 12 January 2015 at 20:18, Nil Goyette <[email protected]
<mailto:[email protected]>> wrote:

     Hi all,

     I have at least two nodes (I have drawn more, but I can reproduce
     the bug with 2 nodes)
     - Node1
     --- Node2  (child of Node1)
     --- Node3
     ----- Node4
     ----- Node5
     - Some other nodes

     When the user deletes Node1, I want to delete all children nodes
     (2, 3, 4, 5).
     To do so, I use NodeDeleted(), I ask the DataStorage for all
     derivative nodes of the deleted node and delete them all.
     A problem arises when the user highlights all nodes and delete
     them. Some nodes are deleted more then one time. Of course, there
     are conditions in mitk and in my own code that check if the node
     is null, but it still fails about half of the time. Since the
     NodeRemoved() event is thrown *before* the actual deletion, the
     null/exists checks are useless.

     I'm probably not the first that want to delete all the children
     of a node. I feel that this should be simple. Is there a feature
     to do it that I'm not aware of?

        

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to