<< 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