CFileSelector crash my host

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi everybody, I have some trouble with CFileSelector in vstSDK 2.4.

What I want to do :


- Open windows selector
- Select a file
- Return path to the file.
- Display path in my plugins

Here is my code :

Code: Select all

   
 //-- File Selector------------------------------------------------------
    //-------------------------------------------------------------------

    VstFileType waveType ("Wave File", "WAVE", "wav", "wav",  "audio/wav", "audio/x-wav");
    VstFileType types[] = {waveType}; //only One type for now.

    VstFileSelect vstFileSelect;
    memset (&vstFileSelect, 0, sizeof (VstFileSelect));

    vstFileSelect.command     = kVstFileLoad;
    vstFileSelect.type        = kVstFileType;
    strcpy (vstFileSelect.title, "Test for open file selector");
    vstFileSelect.nbFileTypes = 1;
    vstFileSelect.fileTypes   = (VstFileType*)&types;
    vstFileSelect.returnPath  = new char[1024];
    vstFileSelect.initialPath = 0;
    
    selector = new CFileSelector  (ptr); 
// I am in SDEditor::open (void *ptr) function 
   
    fileSelectorDisplay = new CTextLabel (size, 0, 0,0); 
// size is my CRect display
    
    if (selector->run (&vstFileSelect))
    {
       if (fileSelectorDisplay)
          fileSelectorDisplay->setText (vstFileSelect.returnPath);
    }
    else
    {
       if (fileSelectorDisplay)
         fileSelectorDisplay->setText ("OpenFileSelector: canceled!!!!");
    }
    lFrame->addView (fileSelectorDisplay);
    delete selector;
    delete []vstFileSelect.returnPath;
    if (vstFileSelect.initialPath)
       delete []vstFileSelect.initialPath;
When I launch myplugin.dll in Reaper it crash => Reaper_host32.exe stop.

In my header :

Code: Select all

  CFileSelector* selector;
	CTextLabel* fileSelectorDisplay;
Do you have any clues ? (or code that working ? :lol: )

Thanks a lot, Thomas.[/u]

Post

Have you tried checking with the host to see if it supports opening a file selector? I'm not too familiar with Reaper, but you can check by calling canHostDo(). i.e.

Code: Select all

if (canHostDo("openFileSelector")) /*report result to a text file maybe? */

Post

Totovai wrote:When I launch myplugin.dll in Reaper it crash => Reaper_host32.exe stop.
Do you use the bit bridge of reaper? If yes then this might be the problem.

Post

Hi thank you for answer.

I put this in my processReplacing function :

Code: Select all

if(canHostDo("openFileSelector"))
{
    monFlux<< "YES"<<endl;
}
else monFlux<< "No"<<endl;
And the answer is No...

Do you have an alternative ? How can I select file in myPlugin ?

Do you use the bit bridge of reaper? If yes then this might be the problem.
Yes I use it, if I set "disable" it say "The following effect plug-in could not be loaded.

What is this setting "bridge" do ?

Thomas. :)

Post

Totovai wrote:Hi thank you for answer.

I put this in my processReplacing function :

Code: Select all

if(canHostDo("openFileSelector"))
{
    monFlux<< "YES"<<endl;
}
else monFlux<< "No"<<endl;
And the answer is No...
Are you trying to open the file selector in the audio processing function of your plugin? That's a massively bad idea! There's basically no chance that would ever work.

However, if you already have or will solve that mess...I don't think the VST spec in any way requires the host to implement the file dialog functionality. I bet most plugins just open the dialog on their own, using OS specific API calls directly or via a wrapper in their programming framework.

Post

Xenakios wrote:I don't think the VST spec in any way requires the host to implement the file dialog functionality.
CFileSelector already takes care of that, the problem must lie somewhere else.

OK, so let's look at the code as presented in the original posting...

Code: Select all

    // ...
    selector = new CFileSelector  (ptr); 
// I am in SDEditor::open (void *ptr) function 
   
    fileSelectorDisplay = new CTextLabel (size, 0, 0,0); 
// size is my CRect display
    
    if (selector->run (&vstFileSelect))
    {
       if (fileSelectorDisplay)
          fileSelectorDisplay->setText (vstFileSelect.returnPath);
    }
    else
    {
       if (fileSelectorDisplay)
         fileSelectorDisplay->setText ("OpenFileSelector: canceled!!!!");
    }
    lFrame->addView (fileSelectorDisplay);
    delete selector;
    // ...
There's a massive error in there. The pointer passed to CFileSelector's constructor should be a pointer to the effect, not to the editor's parent window.

So, to keep the OP's coding style,

Code: Select all

    selector = new CFileSelector  (effect);
should work better.
"Until you spread your wings, you'll have no idea how far you can walk." Image

Post

Which VSTGUI version are you using?
3.6 is incomplete for Windows I seem to remember, and you have back-port the VSTGUI 4.0 stuff for it to work properly. *joy*

Post

There's a massive error in there. The pointer passed to CFileSelector's constructor should be a pointer to the effect, not to the editor's parent window.

So, to keep the OP's coding style,
selector = new CFileSelector (effect); should work better.
Wowowow can I kiss you master genious :love:

it works, thanks a lot every body :D

Post

Totovai wrote:Wowowow can I kiss you master genious :love:
Only if you're one of my daughters, and somehow I doubt that 8-)
Glad it works.
"Until you spread your wings, you'll have no idea how far you can walk." Image

Post Reply

Return to “DSP and Plugin Development”