What is KVR Audio? | Submit News | Advertise | Developer Account

Options (Affects News & Product results only):

OS:
Format:
Include:
Quick Search KVR

"Quick Search" KVR Audio's Product Database, News Items, Developer Listings, Forum Topics and videos here. For advanced Product Database searching please use the full product search. For the forum you can use the phpBB forum search.

To utilize the power of Google you can use the integrated Google Site Search.

Products 0

Developers 0

News 0

Forum 0

Videos 0

Search  

CFileSelector crash my host

DSP, Plug-in and Host development discussion.

Moderator: Moderators (Main)

Totovai
KVRer
 
9 posts since 26 Mar, 2012, from Liège,Belgique

Postby Totovai; Wed Dec 05, 2012 4:44 am CFileSelector crash my host

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]
LemonLime
KVRist
 
226 posts since 15 Apr, 2012, from Toronto, ON

Postby LemonLime; Wed Dec 05, 2012 8:04 am

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? */
Benutzername
KVRist
 
213 posts since 23 Jan, 2008, from Hamburg, Germany

Postby Benutzername; Wed Dec 05, 2012 8:37 am

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.
Totovai
KVRer
 
9 posts since 26 Mar, 2012, from Liège,Belgique

Postby Totovai; Wed Dec 05, 2012 11:31 pm

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. :)
Xenakios
KVRian
 
700 posts since 9 Sep, 2005, from Oulu, Finland

Postby Xenakios; Thu Dec 06, 2012 5:52 am

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.
arakula
KVRAF
 
1932 posts since 16 Aug, 2004, from Vienna, Austria

Postby arakula; Thu Dec 06, 2012 7:41 am

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
DaveHoskins
KVRian
 
569 posts since 7 Jan, 2009, from Gloucestershire

Postby DaveHoskins; Thu Dec 06, 2012 9:22 am

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*
Totovai
KVRer
 
9 posts since 26 Mar, 2012, from Liège,Belgique

Postby Totovai; Fri Dec 07, 2012 10:06 am

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
arakula
KVRAF
 
1932 posts since 16 Aug, 2004, from Vienna, Austria

Postby arakula; Fri Dec 07, 2012 11:28 am

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

Moderator: Moderators (Main)

Return to DSP and Plug-in Development