PureLVSORT library : sorting ListIconGadgets (and more)

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by dige »

+1

... btw. where is gnozal?????
"Daddy, I'll run faster, then it is not so far..."
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: IMA with MultiThreading & MultiCPU

Post by gnozal »

Do you compile with the threadsafe switch ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

dige wrote:+1
... btw. where is gnozal?????
I just came back from a trip, have a lot of work, so this PB4.50 thing will have to wait a little.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
JJ
User
User
Posts: 23
Joined: Fri Feb 16, 2007 12:41 am
Location: Paris, France

Re: IMA with MultiThreading & MultiCPU

Post by JJ »

Yes, I compile with the switch theadsafe. If I try to run the application with switch threadsafe off, the "Invalid memory error" comes immedialtely.

I make the test on diferent PC
PC with only one core Mobile centrino under XP SP2: No trouble
* Pentium 4 (monocore with multitreading active) under XP SP2 and SP3: Trouble
* Dual core under XP SP3: Trouble
* Quad core under XP SP3: Trouble
* I7-860 under Window 7 ultimate: No trouble
I don't do any test on PC with AMD processor.

I would like to know if someone who test my code have the same trouble.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: IMA with MultiThreading & MultiCPU

Post by gnozal »

JJ wrote:Yes, I compile with the switch theadsafe. If I try to run the application with switch threadsafe off, the "Invalid memory error" comes immedialtely.
Then I guess the library isn't 100% threadsafe.
I simply compile the library with the threadsafe option, without any further changes.
Anyway, I am not sure that it's very safe to manipulate gadgets in threads. Maybe you should add semaphores to your code ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
JJ
User
User
Posts: 23
Joined: Fri Feb 16, 2007 12:41 am
Location: Paris, France

Re: IMA with MultiThreading & MultiCPU

Post by JJ »

I think this 2 procedure PureLVSORT_SelectGadgetToSort() and PureCOLOR_SetGadgetColorEx() must used callback procedure.
If I don't use this procedure, my application runs fine. Many other procedure in the library PureColor works fine too in this context.

I make the test with semaphore to protect the WaitWindowEvent(), it reduce the risk of crash but the risk is not null. And the performance are very bad.

When I try to fix this trouble, the only solution that I find, is to limited the application to run on only one CPU. This is the best solution for the moment, but I continue to have around 1 crash up 20 hours running.
PBUser
User
User
Posts: 20
Joined: Mon Aug 20, 2007 6:03 pm
Location: Germany

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by PBUser »

Thanks for your update to 4.5x. Unfortunately I still get this POLINK errors:

Code: Select all

POLINK: error: Unresolved external symbol '_PB_StringBasePosition'.
POLINK fatal error: 1 unresolved external(s).
I am using PureBasic 4.50 Beta 2 x32

Did someone have the same problem with the new PureLVSort library?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

PBUser wrote:Thanks for your update to 4.5x. Unfortunately I still get this POLINK errors:

Code: Select all

POLINK: error: Unresolved external symbol '_PB_StringBasePosition'.
POLINK fatal error: 1 unresolved external(s).
Probably a subsystem issue.
PureLVSORT.chm wrote:This library exists in several versions :
- the standard version, located in %Purebasic%\PureLibraries\UserLibraries\ ;
- the thread-safe version, located in %Purebasic%\SubSystems\UserLibThreadSafe\PureLibraries\ .
- the unicode version, located in %Purebasic%\SubSystems\UserLibUnicode\PureLibraries\ .
- the unicode + thread-safe version, located in %Purebasic%\SubSystems\UserLibunicodeThreadSafe\PureLibraries\ .
In order to use this library in thread-safe mode (compiler option /THREAD), you have to enable the subsystem 'UserLibThreadSafe' in the PB IDE, or add '/SUBSYSTEM UserLibThreadSafe' to the PBCompiler arguments.
In jaPBe, do nothing : it will automatically enable the 'UserLibThreadSafe' subsystem to use the threadsafe versions of the installed userlibraries.
It's the same logic for unicode and unicode + thread-safe modes.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

:) Hi,
I'm testing the Filter Callback Function (in windows 7 and PB 4.41) using this code:

Code: Select all

Procedure MyFilterCallback(GadgetNumber.l, FilterString.s, ListIconColumn.l, EventCode.l) ; simple search example
  Protected itemNumber.l, I.l
  
  Debug FilterString 
  
  If FilterString 
    itemNumber = -1
    If IsGadget(GadgetNumber)
      ; Search for string
      For I = 0 To CountGadgetItems(GadgetNumber) - 1 
        If FilterString = GetGadgetItemText(GadgetNumber, I, ListIconColumn) 
          itemNumber = I
          Break
        EndIf 
      Next 
      ;
      If itemNumber <> -1 ; if string found, scroll to row
        PureLVSORT_ScrollToRow(GadgetNumber, itemNumber)
        SetGadgetItemState(GadgetNumber, itemNumber, GetGadgetItemState(GadgetNumber, itemNumber) | #PB_ListIcon_Selected)
      EndIf
    EndIf
  EndIf
EndProcedure
;
#Window_0 = 0 
#ListIcon_0 = 0 
;
Procedure Open_Window_0() 
  If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT Test",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered) 
      ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "String", 110) 
      AddGadgetColumn(#ListIcon_0, 1, "Numeric", 110) 
      AddGadgetColumn(#ListIcon_0, 2, "Float", 110) 
      AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120) 
      AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120) 
      AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "0.9" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004") 
      AddGadgetItem(#ListIcon_0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "1.9" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004") 
      AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "7.0" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003") 
      AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "524" + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001") 
  EndIf 
EndProcedure 
;
Open_Window_0() 
;
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok 
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String) ; default, not necessary 
  PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_Numeric) 
  PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_Float) 
  PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY) 
  PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY) 
  PureLVSORT_SortListIconNow(#ListIcon_0, 3, 1)
  PureLVSORT_DefineFilterCallback(@MyFilterCallback())
  PureLVSORT_SetFilterTimeOut(100)
  PureLVSORT_SetFilter(#ListIcon_0)
EndIf 
; 
Repeat 
  Event = WaitWindowEvent() 
Until Event = #PB_Event_CloseWindow 
End

and I have found that when I erase a previous FilterString entered by keyboard, the callback function receive a FilterString strange (look at "Debug FilterString "), that is not "" (empty).

Thats only occurs in W7! in WXPSP3 all runs fine.

Thanks for your help
QuimV
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

QuimV wrote::) Hi,
I'm testing the Filter Callback Function (in windows 7 and PB 4.41) ... and I have found that when I erase a previous FilterString entered by keyboard, the callback function receive a FilterString strange (look at "Debug FilterString "), that is not "" (empty).
Thats only occurs in W7! in WXPSP3 all runs fine.
I don't have Se7en, so I can only imagine what's going wrong.
Anyway, I made a little change.
Could you test http://freenet-homepage.de/gnozal/PureLVSORT_TEST.zip (PB4.50 ANSI library version, copy to \PureBasic450\PureLibraries\UserLibraries\) ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

:( Hi gnozal,

The behaviour continue being wrong. I mean that when I erase the string entered by the keyboard, the gadget callback function receive a string different from "" (void string), in fact the string received by the callback function is garbage.

Thanks
QuimV
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

QuimV wrote::( Hi gnozal,

The behaviour continue being wrong. I mean that when I erase the string entered by the keyboard, the gadget callback function receive a string different from "" (void string), in fact the string received by the callback function is garbage.
Ok another try : I have updated http://freenet-homepage.de/gnozal/PureLVSORT_TEST.zip (PB4.50 ANSI library version, copy to \PureBasic450\PureLibraries\UserLibraries\).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

:( Nothing good. The same behaviour.
Thanks
QuimV
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

QuimV wrote::( Nothing good. The same behaviour.
Thanks
ye old code looks like this (ANSI PB4.xx version)

Code: Select all

...
        ElseIf *pNMHdr\hdr\code = #HDN_FILTERCHANGE Or *pNMHdr\hdr\code = #HDN_FILTERBTNCLICK ; filter string changed
          ; hHDItem.HDITEM, TFilter.HDTEXTFILTER
          TmpHeaderText = Space(#MAX_pszText + 1)
          TFilter\pszText = @TmpHeaderText
          TFilter\cchTextMax = #MAX_pszText
          hHDItem\mask = #HDI_FILTER 
          hHDItem\type = #HDFT_ISSTRING 
          hHDItem\pvFilter = @TFilter 
          hHeader = SendMessage_(WindowId, #LVM_GETHEADER, 0, 0) ; <--- get header handle
          If hHeader
            SendMessage_(hHeader,#HDM_GETITEM,*pNMHdr\iItem,@hHDItem) ; <--- get filter text
            If PureLVSORT_FilterCallBack
              CallFunctionFast(PureLVSORT_FilterCallBack, GetDlgCtrlID_(WindowId), TFilter\pszText, *pNMHdr\iItem, *pNMHdr\hdr\code) ; passes info to the user callback
...
I don't know where the problem might be...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

Hi,

Would it be possible that you send a number to the callback filter function (TFilter\pszText) while the function should receive a string?

Code: Select all

Procedure MyFilterCallback(GadgetNumber.l, FilterString.s, ListIconColumn.l, EventCode.l)

   TFilter\pszText = @TmpHeaderText

CallFunctionFast(PureLVSORT_FilterCallBack, GetDlgCtrlID_(WindowId), TFilter\pszText, *pNMHdr\iItem, *pNMHdr\hdr\code) ; passes info to the user callback

The problem always appears when the string is zero lenght an only in this case,

:o I'm sorry, I don't know enough programming to be more efective helping you.

Thanks
QuimV
Post Reply