PureLVSORT library : sorting ListIconGadgets (and more)
Moderator: gnozal
Re: PureLVSORT library : sorting ListIconGadgets (and more)
+1
... btw. where is gnozal?????
... btw. where is gnozal?????
"Daddy, I'll run faster, then it is not so far..."
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: IMA with MultiThreading & MultiCPU
Do you compile with the threadsafe switch ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureLVSORT library : sorting ListIconGadgets (and more)
I just came back from a trip, have a lot of work, so this PB4.50 thing will have to wait a little.dige wrote:+1
... btw. where is gnozal?????
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: IMA with MultiThreading & MultiCPU
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.
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.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: IMA with MultiThreading & MultiCPU
Then I guess the library isn't 100% threadsafe.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.
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).
Re: IMA with MultiThreading & MultiCPU
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.
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.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Thanks for your update to 4.5x. Unfortunately I still get this POLINK errors:
I am using PureBasic 4.50 Beta 2 x32
Did someone have the same problem with the new PureLVSort library?
Code: Select all
POLINK: error: Unresolved external symbol '_PB_StringBasePosition'.
POLINK fatal error: 1 unresolved external(s).
Did someone have the same problem with the new PureLVSort library?
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Probably a subsystem issue.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).
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).
Re: PureLVSORT library : sorting ListIconGadgets (and more)

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
Thats only occurs in W7! in WXPSP3 all runs fine.
Thanks for your help
QuimV
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureLVSORT library : sorting ListIconGadgets (and more)
I don't have Se7en, so I can only imagine what's going wrong.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.
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).
Re: PureLVSORT library : sorting ListIconGadgets (and more)

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
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Ok another try : I have updated http://freenet-homepage.de/gnozal/PureLVSORT_TEST.zip (PB4.50 ANSI library version, copy to \PureBasic450\PureLibraries\UserLibraries\).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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: PureLVSORT library : sorting ListIconGadgets (and more)

Thanks
QuimV
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureLVSORT library : sorting ListIconGadgets (and more)
ye old code looks like this (ANSI PB4.xx version)QuimV wrote:Nothing good. The same behaviour.
Thanks
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
...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Hi,
Would it be possible that you send a number to the callback filter function (TFilter\pszText) while the function should receive a string?
The problem always appears when the string is zero lenght an only in this case,
I'm sorry, I don't know enough programming to be more efective helping you.
Thanks
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

Thanks
QuimV