Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
CFileSelector crash my host
Totovai
KVRer
- profile
- pm
- e-mail
PostPosted: Wed Dec 05, 2012 4:44 am reply with quote
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 :

   
 //-- 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 :

  CFileSelector* selector;
   CTextLabel* fileSelectorDisplay;


Do you have any clues ? (or code that working ? Laughing )

Thanks a lot, Thomas.[/u]
^ Joined: 26 Mar 2012  Member: #277611  Location: Liège,Belgique
LemonLime
KVRist
- profile
- pm
- e-mail
PostPosted: Wed Dec 05, 2012 8:04 am reply with quote
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.

if (canHostDo("openFileSelector")) /*report result to a text file maybe? */
^ Joined: 15 Apr 2012  Member: #278696  Location: Toronto, ON
Benutzername
KVRist
- profile
- pm
PostPosted: Wed Dec 05, 2012 8:37 am reply with quote
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.
^ Joined: 23 Jan 2008  Member: #171645  Location: Hamburg, Germany
Totovai
KVRer
- profile
- pm
- e-mail
PostPosted: Wed Dec 05, 2012 11:31 pm reply with quote
Hi thank you for answer.

I put this in my processReplacing function :

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 ?


Quote:
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. Smile
^ Joined: 26 Mar 2012  Member: #277611  Location: Liège,Belgique
Xenakios
KVRian
- profile
- pm
- e-mail
PostPosted: Thu Dec 06, 2012 5:52 am reply with quote
Totovai wrote:
Hi thank you for answer.

I put this in my processReplacing function :

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.
^ Joined: 09 Sep 2005  Member: #80666  Location: Oulu, Finland
arakula
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Thu Dec 06, 2012 7:41 am reply with quote
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...
    // ...
    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,
    selector = new CFileSelector  (effect); should work better.
----
"Until you spread your wings, you'll have no idea how far you can walk."
^ Joined: 16 Aug 2004  Member: #37236  Location: Vienna, Austria
DaveHoskins
KVRian
- profile
- pm
- www
PostPosted: Thu Dec 06, 2012 9:22 am reply with quote
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*
^ Joined: 07 Jan 2009  Member: #197745  Location: Gloucestershire
Totovai
KVRer
- profile
- pm
- e-mail
PostPosted: Fri Dec 07, 2012 10:06 am reply with quote
Quote:
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 Very Happy
^ Joined: 26 Mar 2012  Member: #277611  Location: Liège,Belgique
arakula
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Fri Dec 07, 2012 11:28 am reply with quote
Totovai wrote:
Wowowow can I kiss you master genious Love

Only if you're one of my daughters, and somehow I doubt that Cool
Glad it works.
----
"Until you spread your wings, you'll have no idea how far you can walk."
^ Joined: 16 Aug 2004  Member: #37236  Location: Vienna, Austria
All times are GMT - 8 Hours

Printable version
Page 1 of 1
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Username: Password:  
KVR Developer Challenge 2012