<< std::endl;
}
}
+ // In case we do not abort
+ // on error, this will tell
+ // do_unsubscribe below that the
+ // object is unused now.
+ counter = 0;
#endif
}
{
#ifdef DEBUG
Assert (counter>0, ExcNotUsed());
+ // This is for the case that we do
+ // not abort after the exception
+ if (counter == 0)
+ return;
+
Threads::ThreadMutex::ScopedLock lock (subscription_lock);
--counter;
#if DEAL_USE_MT == 0
const char* name = (id != 0) ? id : unknown_subscriber;
-
map_iterator it = counter_map.find(name);
Assert (it != counter_map.end(), ExcNoSubscriber(object_info->name(), name));
Assert (it->second > 0, ExcNoSubscriber(object_info->name(), name));
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
#include <base/smartpointer.h>
#include <base/logstream.h>
#include <iomanip>
+#include <iostream>
+#include <vector>
+// Provide memory for objects of type T such that access to a deleted
+// object does not cause a segmentation fault
+std::vector<char> memory(10000);
+int next = 0;
class Test : public Subscriptor
{
if (true)
{
Test a("A");
- const Test b("B");
+ const Test& b("B");
+
SmartPointer<Test> r(&a, "Test R");
SmartPointer<const Test> s(&a, "const Test S");
// SmartPointer<Test> t=&b; // this one should not work
r = &c;
Test d("D");
r = &d;
+ // Destruction of "Test R" will
+ // cause a spurious ExcNotUsed
+ // here, since D was deleted first
}
}
DEAL::Destruct D
DEAL::ExcInUse (counter, object_info->name(), infostring)
DEAL::Destruct C
-DEAL::ExcNoSubscriber(object_info->name(), name)
-DEAL::ExcNoSubscriber(object_info->name(), name)
+DEAL::ExcNotUsed()
DEAL::Destruct B
DEAL::Destruct A
+++ /dev/null
-
-DEAL::Construct A
-DEAL::Construct B
-DEAL::a mutable
-DEAL::b const
-DEAL::r mutable
-DEAL::s const
-DEAL::t mutable
-DEAL::u const
-DEAL::Construct C
-DEAL::Construct D
-DEAL::Destruct D
-DEAL::ExcInUse(counter, object_info->name(), infostring)
-DEAL::Destruct C
-DEAL::Destruct B
-DEAL::Destruct A
+++ /dev/null
-
-DEAL::Construct A
-DEAL::Construct B
-DEAL::a mutable
-DEAL::b const
-DEAL::r mutable
-DEAL::s const
-DEAL::t mutable
-DEAL::u const
-DEAL::Construct C
-DEAL::Construct D
-DEAL::Destruct D
-DEAL::ExcInUse(counter, object_info->name(), infostring)
-DEAL::Destruct C
-DEAL::Destruct B
-DEAL::Destruct A
+++ /dev/null
-
-DEAL::Construct A
-DEAL::Construct B
-DEAL::a mutable
-DEAL::b const
-DEAL::r mutable
-DEAL::s const
-DEAL::t mutable
-DEAL::u const
-DEAL::Construct C
-DEAL::Construct D
-DEAL::Destruct D
-DEAL::ExcInUse(counter, object_info->name(), infostring)
-DEAL::Destruct C
-DEAL::Destruct B
-DEAL::Destruct A
+++ /dev/null
-
-DEAL::Construct A
-DEAL::Construct B
-DEAL::a mutable
-DEAL::b const
-DEAL::r mutable
-DEAL::s const
-DEAL::t mutable
-DEAL::u const
-DEAL::Construct C
-DEAL::Construct D
-DEAL::Destruct D
-DEAL::ExcInUse(counter, object_info->name(), infostring)
-DEAL::Destruct C
-DEAL::ExcNoSubscriber(object_info->name(), name)
-DEAL::ExcNoSubscriber(object_info->name(), name)
-DEAL::Destruct B
-DEAL::Destruct A
+++ /dev/null
-
-DEAL::Construct A
-DEAL::Construct B
-DEAL::a mutable
-DEAL::b const
-DEAL::r mutable
-DEAL::s const
-DEAL::t mutable
-DEAL::u const
-DEAL::Construct C
-DEAL::Construct D
-DEAL::Destruct D
-DEAL::ExcInUse(counter, object_info->name(), infostring)
-DEAL::Destruct C
-DEAL::Destruct B
-DEAL::Destruct A
+++ /dev/null
-
-DEAL::Construct A
-DEAL::Construct B
-DEAL::a mutable
-DEAL::b const
-DEAL::r mutable
-DEAL::s const
-DEAL::t mutable
-DEAL::u const
-DEAL::Construct C
-DEAL::Construct D
-DEAL::Destruct D
---------------------------------------------------------
-An error occurred in file <subscriptor.cc> in function
- Subscriptor::~Subscriptor()
-The violated condition was:
- counter == 0
-The name and call sequence of the exception was:
- ExcInUse(counter, object_info->name(), infostring)
-Additional Information:
-Object of class 4Test is still used by 1 other objects.
- from Subscriber Test R
---------------------------------------------------------
-DEAL::Abort!!!
-DEAL::Destruct C
---------------------------------------------------------
-An error occurred in file <subscriptor.cc> in function
- void Subscriptor::unsubscribe(const char *) const
-The violated condition was:
- it != counter_map.end()
-The name and call sequence of the exception was:
- ExcNoSubscriber(object_info->name(), name)
-Additional Information:
-No subscriber with identifier "Test R" did subscribe to this object of class 4Test
---------------------------------------------------------
-DEAL::Abort!!!
---------------------------------------------------------
-An error occurred in file <subscriptor.cc> in function
- void Subscriptor::unsubscribe(const char *) const
-The violated condition was:
- it->second > 0
-The name and call sequence of the exception was:
- ExcNoSubscriber(object_info->name(), name)
-Additional Information:
-No subscriber with identifier "Test R" did subscribe to this object of class 4Test
---------------------------------------------------------
-DEAL::Abort!!!
-DEAL::Destruct B
-DEAL::Destruct A