AudioDeviceSelectorComponent bug?


#1

Hello,

When I was debugging my application, I got that jassert on closing it:

// doh! If you don't delete all your windows before exiting, you're going to // be leaking memory! jassert(desktopComponents.size() == 0)

However, my app has only one window and I’m sure I delete it before exiting, at the destructor of the JUCEApplication::MyApp.

So I began doing more tests and I noted that when I change the sound driver on the the AudioDeviceSelectorComponent I always get that assert on exiting.

May I be worried about that? I think Windows XP deletes all memory used by the application, doesn’t it?


#2

You should be very worried by assertions like that - that’s why they’re there!

It’s telling you that you’re leaking a window, and you say it only happens when you’re had an audio selector window open… hmm, maybe just perhaps you’re forgetting to delete your audio selector window…!


#3

Thanks, Jules!

My AudioDeviceSelectorComponent is inside my app’s main window, something like:

mainWindow->setContentComponent(contentComponent);
contentComponent->addAndMakeVisible(myAudioDeviceSelectorComponent);

So, when I delete the mainWindow its destructor doesn’t delete the components inside?


#4

No!


#5

Thanks. Is there a way where I can put a loop like

for(i=0;i<this->getNumChildComponents();i++){
   delete this->getChildComponent(i);

}

safely?


#6

Have a look at the destructor of almost any demo component I’ve ever written, and you’ll see a thing called deleteAllChildren() getting called…


#7

Thanks… however, I did a deleteAllChildren() on each component I have created (including the AudioDeviceSelectorComponent). Is there a way to find which is that hidden component?


#8

Maybe when I change a device on AudioDeviceSelectorComponent’s combo, a pointer/thread controlling the old device is not deleted… how can I assure that the old thread was stopped/deleted?


#9

Well, you’ve got an assert there telling you that the list of components isn’t empty. Components have names; just write a loop to dump out the contents of the list and print the names.


#10

More than that - you’ve got an assert telling you that a top-level window component hasn’t been deleted. That narrows it down a bit!


#11