Strange Crash Problem
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/08/2006 at 10:42, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.603
Platform: Windows ;
Language(s) : C++ ;---------
Hi alli try to make a copy paste system for polygons.
And i'm having some stability problems.Here is the code of the "copy" part. Sorry, i couln't simplify it anymore so that it still crashes.
#include "c4d.h" #include "c4d_symbols.h" struct Clipboard { ~Clipboard() { TakeObjects(NULL); } AutoAlloc<AtomArray> array; void TakeObjects( AtomArray* a ); }; void Clipboard::TakeObjects( AtomArray* a ) { if( !array ) return; // free all stored objects array->FilterObjectChildren(); for( LONG i=0; i<array->GetCount(); ++i ) { BaseObject* op = static_cast<BaseObject*>( array->GetIndex(i) ); BaseObject::Free( op ); } array->Flush(); GeAssert( array->GetCount()==0 ); // copy pointers from a to array if( a ) a->CopyTo( array ); } static Clipboard *g_clip = NULL; void FreeClipboard() { gDelete( g_clip ); } Clipboard* GetClipboard() { if( !g_clip ) { g_clip = gNew Clipboard; } return g_clip; } Bool DoCopy( BaseDocument* doc ) { Clipboard* clip = GetClipboard(); if( !clip ) return TRUE; AutoAlloc<AtomArray> active; doc->GetActivePolygonObjects( *active, TRUE ); if( active->GetCount()>0 ) { ModelingCommandData md; md.op = NULL; md.arr = active; md.doc = doc; md.result = NULL; md.mode = 0; md.flags = 0; md.result = NULL; SendModelingCommand( MCOMMAND_SPLIT, md ); clip->TakeObjects( md.result ); } else clip->TakeObjects( NULL ); return TRUE; } class MenuTest : public CommandData { public: virtual Bool Execute(BaseDocument *doc); }; Bool MenuTest::Execute(BaseDocument *doc) { DoCopy( doc ); return TRUE; } Bool RegisterMenuTest(void) { // decide by name if the plugin shall be registered - just for user convenience String name=GeLoadString(IDS_MENUTEST); if (!name.Content()) return TRUE; // be sure to use a unique ID obtained from www.plugincafe.com return RegisterCommandPlugin(1000956,name,0,"icon.tif","C++ SDK Menu Test Plugin",gNew MenuTest); } //In main.cpp: void FreeClipboard(); void PluginEnd(void) { FreeClipboard(); }
This code can crash reproducable when you do the following:
Create c4d_debug.txt file, so C4d runns in debug mode.
Run C4d.
Make a cube.
Make Editable.
Make a HNWeightTag ( use hn weight tool on some edges )
Select some polys
Call the plug
Quite Cinema
...
BOOM... wtf..it only crashes if you run in debug mode, and have the HN tag. I suspect some memory becomes corrupted somehow.
Okay this crash happens when you quit. But i'm also having other crashes which are harder to reproduce.
I have no idea what is going on. Help ??!!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/08/2006 at 12:31, xxxxxxxx wrote:
hmm... if i use this...
void Clipboard::TakeObjects( AtomArray* a ) { if( !array ) return; array->FilterObjectChildren(); for( LONG i=0; i<array->GetCount(); ++i ) { BaseObject* op = static_cast<BaseObject*>( array->GetIndex(i) ); BaseObject::Free( op ); } array->Flush(); GeAssert( array->GetCount()==0 ); if( a ) a->CopyTo( array ); for( LONG i=0; i<array->GetCount(); ++i ) { BaseObject* op = static_cast<BaseObject*>( array->GetIndex(i) ); BaseTag *t; while( t = op->GetTag( Tsds ) ) { t->Remove(); BaseTag::Free( t ); } } }
... the entire plug appears to work just fine.
best regards
Michael -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/08/2006 at 23:59, xxxxxxxx wrote:
bump
uhm.. mikael, can you reproduce ?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/08/2006 at 14:05, xxxxxxxx wrote:
Sorry, I thought that the last piece of code you posted was a fix. Perhaps I should take the time to actually read this thread through now...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/08/2006 at 10:21, xxxxxxxx wrote:
Yes please check it out. The code is no fix, it removes the HNWeight-Tags which seem to cause the problems. It should work with all kind of tags though.
Thanks
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/08/2006 at 01:31, xxxxxxxx wrote:
You should use:
C4DPL_ENDACTIVITY
in PluginMessage otherwise (from the sdk docs) :
Sent to all plugins before any PluginEnd() has been called. This allows you to close dialogs, end threads, delete temporary/undo buffers etc. In PluginEnd() it might crash as some resources from other plugins might already be freed.
HTH.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/08/2006 at 02:53, xxxxxxxx wrote:
Thanks David.