Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: ICC (Read 15955 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

ICC

Reply #25
Quote
Don't do too much work with it, though.  I'll be putting out a new version with some new interface features sometime today. 

I hope that includes things like

play_focused

and some access to the things you are doing with your keyboard shortcut support, etc.

ICC

Reply #26
The playlist_oper "gets" seem to work from my component but not the "sets".

ICC

Reply #27
That's really odd that you're unable to set the focused item.  What exactly is it doing?  It is defocusing the currently selected, or just taking no action at all?  But I can't control what the playlist_oper does.  I'm only caching a reference to speed up searches.

Things like play_focused are done through the play_control and playlist_oper classes, so I won't be duplicating that functionality.

Most of the new functionality I'm adding is to allow searching of lists other than the playlist, and to have more control over exactly how they are searched.  I've also added code to show and close the search window, but there's no code to control the window.  It's just like pressing the hotkeys.


ICC

Reply #29
Quote
That's really odd that you're unable to set the focused item.  What exactly is it doing?  It is defocusing the currently selected, or just taking no action at all?  But I can't control what the playlist_oper does.  I'm only caching a reference to speed up searches.

Things like play_focused are done through the play_control and playlist_oper classes, so I won't be duplicating that functionality.

Most of the new functionality I'm adding is to allow searching of lists other than the playlist, and to have more control over exactly how they are searched.  I've also added code to show and close the search window, but there's no code to control the window.  It's just like pressing the hotkeys.

It simply does nothing.  The focus isn't changed at all.

I'll keep messing around with it.


ICC

Reply #31
Damn you.    I was going to tell you that you must have unzipped over the old one so it's still there, but it was my fault.  I forgot to remove the old one from the zip. 

P.S.  Gone now.  No other changes, though.  You can just delete it from the folder.

ICC

Reply #32
I included the new playlist_find.h and made no other changes but now I alwasy get -1 for the search result.

Still just calling

      int findPos = global_playlist_find::get()->search(m_Hot[Title1].GetText(),g_play_oper->get_focus());
      g_play_oper->set_focus_sel(findPos);

is there any other setup or did the search() semantics change?

ICC

Reply #33
The search semantics actually did change a little (start_index is now included in the search, whereas it was previously not included), but that doesn't explain why you're getting -1 as the result every time.  By sending the selected item, it should (likely) just be returning it every time.

int findPos = global_playlist_find::get()->search(m_Hot[Title1].GetText()); // you can drop the g_play_oper->get_focus()
g_play_oper->set_focus_sel(findPos);

edit:
Can you post an example of what m_Hot[Title1].GetText() returns, along with your playlist formatting string, your playlistfind string, and any other data you think might be important.  (If you've got "match only beginning" enabled, etc.)

ICC

Reply #34
Quote
The search semantics actually did change a little (start_index is now included in the search, whereas it was previously not included), but that doesn't explain why you're getting -1 as the result every time.  By sending the selected item, it should (likely) just be returning it every time.

int findPos = global_playlist_find::get()->search(m_Hot[Title1].GetText()); // you can drop the g_play_oper->get_focus()
g_play_oper->set_focus_sel(findPos);

edit:
Can you post an example of what m_Hot[Title1].GetText() returns, along with your playlist formatting string, your playlistfind string, and any other data you think might be important.  (If you've got "match only beginning" enabled, etc.)

I got it working again.  Here's how if you want to try to see what happened.

I delete playlistfind, ran foobar which cleaned out the config, reinstalled.

I think that just coping this most recent version over the one I had from this morning or yesterday, whenever it was caused some config problems.

EDIT

Actually, I can't get playlist_find to work reliably after I close foobar and restart.  Removing it, running foobar, the reinstalling seems to clear it up for the first run.  This is just via the supplied UI not from my component calling via the service ptr.

Hum, I can't reproduce that reliably either.  I have seen it not work from my code and from the default UI.  But its working now...
I should call it a night while I'm ahead.

/EDIT

now, still can't set the focused item.

I was wondering, would you consider from a design standpoint and as a test to include the focus setting in playlist find.

So something like

search(const char*, int index, bool wrap, bool updatefocus);

I'm wondering if this would work for me.  I have everythign in place to use playlist find except that I can't figure out why the focus stuff won't work from my message loop. (I still think foobar is locking me out somehow).

Also question.

You say don't derive from your playlist class yet the interface declares the methods as virtual and the class is preceded by NOVTABLE.

Just wondering about that one.

ICC

Reply #35
I'm not really understanding the problems you're having.  I'm not having any trouble getting playlistfind to work after restarting foobar.  :\

Also, if your code can't set the currently focused item as a result of threading issues, mine won't be able to either, because it'll be getting called from your thread.  It will run under your thread, not the main thread.

So search(const char*, int index, bool wrap, bool updatefocus); would be functionally identical to search(const char*, int index, bool wrap); followed by a call to playlist_oper::get()->set_focus_sel().

If you can work your code problems down into a small sample, I might be able to take a look at it.  I don't know if I'll be able to tell you anything, though.

As for not deriving from the interface, that message is for you ("you" meaning all other developers).  If you derive from the interface, you will cause problems.  There should be exactly one derivation of the interface, and my plugin provides it.

ICC

Reply #36
Here's the source of some of your problems:

from play_control.h:
//important: you should call api commands declared in this header ONLY from main thread !!

I've got no clue how you can work around that, but then, I don't know the internal structure of wsgui, so I've got no clue why you're even using separate threads.

ICC

Reply #37
Quote
Here's the source of some of your problems:

from play_control.h:
//important: you should call api commands declared in this header ONLY from main thread !!

I've got no clue how you can work around that, but then, I don't know the internal structure of wsgui, so I've got no clue why you're even using separate threads.

Well, that explains a lot.  This is my first attempt at using WTL (Windows Template Library) and I was under the mistaken impression that I needed something like this to drive my window.

Code: [Select]
    MSG msg;
    while (sRunning && GetMessage ( &msg, NULL, 0, 0 ) > 0 )
    {
 TranslateMessage ( &msg );
 DispatchMessage ( &msg );
    }


The only way to do that was with a thread and I was creating a thread to run that.

The above is not needed at all - I didn't realize how the message loop worked in general I guess.  My window still gets messages without the above and this happens in the context of the "main thread".

So, I removed the threaded message pump and voila I can set the focused item

Now I'm still having problems with playlist_find not working but I can focus on that now and try to get you some better information.

One thing I noticed is when it stops working I get access violations in foobar every time I type a key in the playlist_find edit box.

Quote
First-chance exception in foobar2000.exe: 0xC0000005: Access Violation.


I also noticed I get
Quote
metadb_handle leaks, 22 objects


when I close foobar if I have run playlist_find but not if I haven't run playlist_find.  I have 22 items in my playlist.

This might be related to

Code: [Select]
    bool do_matching(const char * str, int playlist_index) {
 static string8 out;
 out.reset();
 if (search_list)
     search_list->get_item(playlist_index)->handle_format_title(out,get_search_format(),NULL);
 else
     g_oper->get_item(playlist_index)->handle_format_title(out,get_search_format(),NULL);


but I'm not sure (ie. get_item returns a ref'ed handle? ).

ICC

Reply #38
OK, some progress but no explanations.  Everything seems to work but only in a release build.  If I run my component in the debugger playlist_find does not work.

In the release build it seems fine and working well  You can type a search directly into wsgui, it will pop up the foobar main window and set the focused item to the current playlist_find search hit.

I'll have to try another service and see if I have the same experience.

ICC

Reply #39
I'll look into it some more.

ICC

Reply #40
Hmm.  When I build playlistfind as a debug, I get some problems.  I'm trying to figure out what's going on.

ICC

Reply #41
Quote
Hmm.  When I build playlistfind as a debug, I get some problems.  I'm trying to figure out what's going on.

If it would help I can post my working version of wsgui that support playlist find and you can debug playlist find when wsgui is generating the calls into the service.

ICC

Reply #42
BTW

Quote
As for not deriving from the interface, that message is for you ("you" meaning all other developers). If you derive from the interface, you will cause problems. There should be exactly one derivation of the interface, and my plugin provides it.


I understand that I was just wondering why the methods were declared as virtual.  I'm just making sure I understand how the service set up works in case I ever want to make one.

ICC

Reply #43
Right now I don't need you to post your code.  I've got some other odd things I need to track down first.  Maybe later, though.

The interface methods must be declared as virtual, or it wouldn't be possible to override them in a subclass.

ICC

Reply #44
Quote
Right now I don't need you to post your code.  I've got some other odd things I need to track down first.  Maybe later, though.

The interface methods must be declared as virtual, or it wouldn't be possible to override them in a subclass.

Oh, OK, I didn't see this part

class global_playlist_find_impl : public global_playlist_find

global_playlist_find is an abstract interface.  I missed that.

ICC

Reply #45
Playlist Find 0.6.b11.012

compiled: 2003.06.07

Quote
[0.6.b11.012]
Fixed:   Potential memory leak
Added:   Pass keystrokes to foobar toggle
Changed:
  Reorganized config slightly.  Disables invalid options properly.
Changed:
  Now clears the current selection if a matching entry is not found.
Fixed:   Wierd bug with the "global" search format.


http://gelaed.com/resources/cplusplus/foo_...laylistfind.zip
http://gelaed.com/resources/cplusplus/foo_...istfind-src.zip

danZ, try it now.  I had a couple of wierd bugs sneak in.  I'm not sure if your issues will be fixed or not, though.

ICC

Reply #46
Quote
Playlist Find 0.6.b11.012

compiled: 2003.06.07

Quote
[0.6.b11.012]
Fixed:   Potential memory leak
Added:   Pass keystrokes to foobar toggle
Changed:
  Reorganized config slightly.  Disables invalid options properly.
Changed:
  Now clears the current selection if a matching entry is not found.
Fixed:   Wierd bug with the "global" search format.


http://gelaed.com/resources/cplusplus/foo_...laylistfind.zip
http://gelaed.com/resources/cplusplus/foo_...istfind-src.zip

danZ, try it now.  I had a couple of wierd bugs sneak in.  I'm not sure if your issues will be fixed or not, though.

Works!  Debug and Release builds.

Care to share what was up?  No crashes when I do search_backwards either which I had in the last build.

Cool, thanks.

ICC

Reply #47
Well, I'll give you a hint.

this (the original, broken code):
Code: [Select]
playlist_find_impl()
{
    search_list = NULL;
    char * search_format = NULL;
    srch_type = SEARCH_DEFAULT;
}


is definitely not the same as this (the new, not so messed-up code):
Code: [Select]
playlist_find_impl()
{
    search_list = NULL;
    search_format = NULL;
    srch_type = SEARCH_DEFAULT;
}


I'm honestly not sure why it was working for me.

ICC

Reply #48
One thing - might be how I'm calling pfind but I think I did it the same as foo_playlistfind

If I type 2 chars past the last match.

So

b - match
be - match
bec - no match
beck - no match

then backspace to

bec

I get a crash when it calls search_backwards

Happens every time but I can't repro on your edit box.

The callstack is in foo_playlistfind.dll when the exception occurs.

Code: [Select]
      int findPos = -1;

     if (wasBack)
         findPos = global_playlist_find::get()->search_backwards(m_KeyFocus->GetText());
     else
         findPos = global_playlist_find::get()->search(m_KeyFocus->GetText());

     playlist_oper::get()->set_focus_sel(findPos);


wasBack is true when I'm processing VK_BACK key.

ideas?

EDIT

m_KeyFocus->GetText() just returns a const char* ptr to "bec"

and I if I only type one char past the last match then backspace no crash.


/EDIT

ICC

Reply #49
Well, the obvious question is whether "m_KeyFocus->GetText()" could be returning NULL.

Assuming that's not the case, then the problem is apparently in search_backwards().  I'll take a look at it. 

I should mention, though, that search_backwards() probably isn't doing what you are expecting.  Search backwards searches from bottom to top, meaning that it should be finding the last entry when you are calling it, rather than the previously found entry.