Drag and drop source throwing assertion failure


#1

Hey all, hoping I could get some advice on this error.
I’ve got a parent component which is inheriting from DragAndDropContainer. This component creates a FileTreeComponent which I’m trying to allow users to drag files off of. As of now I haven’t declared any drop targets, but I keep getting an assertion failure as soon as I click and start dragging:

JUCE Assertion failure in /Users/Mac/Documents/Scratch/Builds/MacOSX/…/…/JuceLibraryCode/…/…/PROGRAMMING/lib/juce/amalgamation/…/src/gui/components/controls/juce_TreeView.cpp, line 151

My code which sets up the FileTreeComponent is the same as everyone else’s as far as I can tell:

        File folder (File::getSpecialLocation (File::userHomeDirectory));
	while (folder.getParentDirectory() != folder)
		folder = folder.getParentDirectory();
	
	directoryList = new DirectoryContentsList (0, thread);
	directoryList->setDirectory (folder, true, true);
	thread.startThread (3);
	
	fileTreeComp = new FileTreeComponent (*directoryList);
	fileTreeComp->setBoundsInset (BorderSize (40, 10, 10, 10));
	fileTreeComp->setDragAndDropDescription(T("fileList"));
        addAndMakeVisible (fileTreeComp);

As far as I understand it, the only thing for a drag and drop source to become functional is for its parent to inherit from DragAndDropContainer, and for itself to setDragAndDropDescription(String). Is this true?


#2

Sorry, I realized my error was because I didn’t include the ‘public’ modifier in front of DragAndDropContainer. smack


#3

That is a subtle error and I didn’t realize dynamic_cast returned 0 if the portion of the object you are trying to access is private.