Page 19 of 30

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Sat Dec 12, 2009 5:50 pm
by GeBonet
Fine, Master, Gnozal...
But now... Telle me why.. This part of code .

Code: Select all

{=========   Boucle PRINCIPALE       ===============================================
; Initialise pour triage... 
    PureLVSORT_SelectGadgetToSort(#Liste, #True) 
    If PureLVSORT_SelectGadgetToSort(#Liste, #True) = #PureLVSORT_Ok
         For j=1 To Nb_Colonne       ;             Première ligne et première colonne... ENTETE
	               NomChamp$=TableFichier(1,j)    ;            Prise du nom d'entête 
                       If FindString(NomChamp$,"Date",1)<>0   ; C'EST une date... Alors   
	               PureLVSORT_SetColumnType(#Liste, j-1, #PureLVSORT_DateDDMMYYHHMM) ; On fixe un format date pour le trie de cette colonne.
		Else                              ; #PureLVSORT_DateDDMMYYYY                    
	            PureLVSORT_SetColumnType(#Liste, j-1, #PureLVSORT_String) ; default, not necessary
		EndIf
	Next j
    EndIf
    ;=============================================================================
    Repeat
	Event = WaitWindowEvent()
	If EventType() = #PB_EventType_LeftDoubleClick 
		PureLVSORT_ClearGadget(#Liste)
	Else
         ...................
Work fine in other code... And here, I receive this F... Error---> "POLINK : Error... " ???
And aloso at this day I, dont now a relation of this error whith something... The linker ! Ok but wat ?
Please sorry for my english... I thing wthis some year, perhaps, one day... :wink:

If you can, you can answers in french... :roll:
Thanks,

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Sat Dec 12, 2009 7:01 pm
by GeBonet
Sorry !!! :wink:
I receive the POLLINK Error ONLY With the IDE native... Withe JaPBe All is OK...
Now,why and where is the differnce between... JaPBe and the IDE From PB itselft ?
I suppose, JaPBe alway now where it is... And how do that wiht the IDE original !

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Mon Dec 21, 2009 1:23 pm
by gnozal
GeBonet wrote:Sorry !!! :wink:
I receive the POLLINK Error ONLY With the IDE native... Withe JaPBe All is OK...
Now,why and where is the differnce between... JaPBe and the IDE From PB itselft ?
I suppose, JaPBe alway now where it is... And how do that wiht the IDE original !
I assume you are using Threadsafe and/or Unicode mode ?
If so, you have to enable the corresponding subsystem (see PureLVSORT help, 'Unicode_Thread-safe' topic).

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Mon Dec 21, 2009 5:39 pm
by GeBonet
You are right, now it's resolved...
And sorry for the disturb... :wink:
Tanks ! :D

IMA with MultiThreading & MultiCPU

Posted: Fri Apr 02, 2010 7:51 am
by JJ
Hello,

I have a trouble with a the function PureLVSORT_SelectGadgetToSort() and PureCOLOR_SetGadgetColorEx() when I use it in a thread.
To test it, launch the simple application, and when it runs, move a window. On many PC multiCPU under XP you will have a invalid memory error on the instruction WaitWindowEvent(...
If you select only one CPU with the SetCPU_Affinity() or with the task manager of window the trouble doen't exist.

I would like to use all the power of my PC, if someone have an idea....

Code: Select all

#Nb_Thread = 4
#Nb_Line = 10
#Nb_Colone = 40
#DELAY_FOR_SYSTEM = 1
#RGB_Interligne_list_CONTACT=$D1FCD3

#ALL_CPU = 0
#MSK_CPU_0 = $01
#MSK_CPU_1 = #MSK_CPU_0 <<1
#MSK_CPU_2 = #MSK_CPU_1 <<1
#MSK_CPU_3 = #MSK_CPU_2 <<1

Procedure SetCPU_Affinity(CPU.L)
  If CPU
    hProcess.L = GetCurrentProcess_ ()
    SetProcessAffinityMask_ (hProcess, CPU)
  EndIf  
EndProcedure  
  
Procedure test(i.L)
  ThrdWin.L = OpenWindow(#PB_Any, 0, 0, 690, 300, "ListIconGadget "+Str(i), #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  LstIcon.L = ListIconGadget(#PB_Any,  10,  25, 680, 270, "Colonne ", 100)
  For i = 2 To #Nb_Colone
    AddGadgetColumn(LstIcon, i, "Colonne " + Str(i), GadgetWidth(LstIcon)/(#Nb_Colone+1))
  Next
  For i = 0 To #Nb_Line
    AddGadgetItem(LstIcon, i, Str(i))
  Next
  PureCOLOR_SetGadgetColorEx(LstIcon, #PureCOLOR_SystemColor, #PureCOLOR_SystemColor, #RGB_Interligne_list_CONTACT, #PureCOLOR_LV_AlternateColors)
  PureLVSORT_SelectGadgetToSort(LstIcon,#PureLVSORT_ShowClickedHeader_IconLeft)
  
  Repeat : Until WaitWindowEvent(#DELAY_FOR_SYSTEM) = #PB_Event_CloseWindow
  
  CloseWindow(ThrdWin)
EndProcedure


;- Main part
; Define how many CPU will run
SetCPU_Affinity(#ALL_CPU)  ; All cpu available
;SetCPU_Affinity(#MSK_CPU_0) ;only CPU_0

For i=1 To #Nb_Thread
  CreateThread(@test(),i)
Next  

test(0)
End

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Fri Apr 02, 2010 11:41 am
by DoubleDutch
On PureBasic v4.50b2 I get 2 unresolved external symbol errors: 'pb_callfunctionfast6' and 'pb_callfunctionfast5'

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Sat Apr 03, 2010 5:43 pm
by PBUser
Me too.
PureLVSORT_SetColumnType works, but PureLVSORT_SelectGadgetToSort returns unresolved external symbol errors.
Could you please recompile that library for PureBasic 4.50 Beta 2?

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Tue Apr 06, 2010 11:43 am
by dige
+1

... btw. where is gnozal?????

Re: IMA with MultiThreading & MultiCPU

Posted: Wed Apr 07, 2010 12:33 pm
by gnozal
Do you compile with the threadsafe switch ?

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Wed Apr 07, 2010 12:36 pm
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.

Re: IMA with MultiThreading & MultiCPU

Posted: Wed Apr 07, 2010 10:17 pm
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.

Re: IMA with MultiThreading & MultiCPU

Posted: Thu Apr 08, 2010 11:02 am
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 ?

Re: IMA with MultiThreading & MultiCPU

Posted: Thu Apr 08, 2010 5:36 pm
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.

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Mon Apr 12, 2010 3:57 pm
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?

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Posted: Mon Apr 12, 2010 4:27 pm
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.