listbox working as in windows lazarus / 32-Linux ---------------------------------------------------------------------- Blue1987 · 2012-08-06 17:32 I am porting an application I wrote for windows into linux... (in particular, I am using bodhilinux, a distro of ubuntu) but I noticed that listbox works differently than in windows... in particular, in the same panel, if I select an item of, say, listbox1 the itemindex of listbox2 is automatically set to -1. how can I change that? thank you, Paolo ---------------------------------------------------------------------- Leledumbo · 2012-08-06 17:54 That should never happen, unless there's a relationship between the two listboxes. Please post a compilable example. ---------------------------------------------------------------------- Blue1987 · 2012-08-07 11:42 you are right... I tried to create a brand new application with 2 listbox and it works well.. so there is a problem with my application... https://dl.dropbox.com/u/23296086/C4E_0511%2B.zip https://dl.dropbox.com/u/23296086/C4E_0511code.tar.gz there is something weird with that... it gives a sivseg error when you go on.. but I cannot understand where... in windows it works well, so I do not understand the problem... PS. I am completely refactoring the application dividing it in different units and forms, and this is the previous version I am not working on anymore... but I was trying to port it in linux before keeping working on the following refactored version of it! ---------------------------------------------------------------------- Leledumbo · 2012-08-07 11:53 Do both listboxes point to the same, say OnChange, event? Probably you'll need to ensure it. ---------------------------------------------------------------------- Blue1987 · 2012-08-07 12:49 Quote from: Leledumbo on August 07, 2012, 01:53:56 pmDo both listboxes point to the same, say OnChange, event? Probably you'll need to ensure it. ehr, no... they don't... mmh... if you compile and run it (you just need bgrabitmaps and bgracontrols) and click "new game" button, you understand what I mean... I think the problem is here (though I am not sure... because I do not understand what the SIVSEG error refers to) ---------------------------------------------------------------------- Leledumbo · 2012-08-07 14:51 QuoteI think the problem is here (though I am not sure... because I do not understand what the SIVSEG error refers to)Sorry I don't have bgracontrols installed (and too lazy to download one now :p) so I'll just try guessing. SIGSEGV is a signal for segmentation fault, sent when you're trying to access memory area outside of what your application has allocated or a nil pointer. If you run under debugger, it can show you where exactly it comes from (assuming the problematic code is compiled with debug info). ---------------------------------------------------------------------- Blue1987 · 2012-08-07 15:18 I admit I do not know how the debugger works  it comes up with the assembler... but I do not know how to read it  I guess it is the listbox, because I try to access arrays like array[listbox7.itemindex]... and if listbox7.itemindex = -1 (while I set it 0) it should try to access a wrong memory allocation... I will write a lot of showmessage(inttostr(listbox7.itemindex)) and try to understand where the problem is (I know... a bit brutal as solution... but do not know how to do it differently...) btw, is it possible that a listbox does not show any item selected even if, for instance, listbox.itemindex = 2 ?? ---------------------------------------------------------------------- Knipfty · 2012-08-07 15:47 Hi Blue, You did not mention if the list boxes are set up at design time or runtime.  IF its runtime, can you post the code for us to look at. Thanks Knipfty ---------------------------------------------------------------------- Blue1987 · 2012-08-07 15:52 sorry, but they are designed in the form... ---------------------------------------------------------------------- Knipfty · 2012-08-07 16:17 Did you check ListBox7.Items.Count?  Assuming that there is at least one item in the list, then you should be ablt to set the itemindex to zero.  I'm doing this in Windows, it could be a problem in Linux. ---------------------------------------------------------------------- Blue1987 · 2012-08-07 21:32 Quote from: Knipfty on August 07, 2012, 06:17:46 pmDid you check ListBox7.Items.Count?  Assuming that there is at least one item in the list, then you should be ablt to set the itemindex to zero.  I'm doing this in Windows, it could be a problem in Linux. ops, I did wrote a wrong link... here the source code https://dl.dropbox.com/u/23296086/C4E_0511code.tar.gz items are more than one (I add them one by one with items.add), then I manually set listbox.itemindex:=0 on runtime... ---------------------------------------------------------------------- Leledumbo · 2012-08-07 22:02 Quoteit comes up with the assembler... but I do not know how to read itIf this happens, you've reached the framework part (probably compiled without debug info). Open up call stack window and look for first entry pointing to your own source code, that's where the error comes from in your code. ---------------------------------------------------------------------- Blue1987 · 2012-08-07 23:09 Quote from: Leledumbo on August 08, 2012, 12:02:40 amQuoteit comes up with the assembler... but I do not know how to read itIf this happens, you've reached the framework part (probably compiled without debug info). Open up call stack window and look for first entry pointing to your own source code, that's where the error comes from in your code. ehr, sorry... but... where do I have to click? p.s. the list-assembler does not scroll! therefore I have some problem if I want to navigate the lines... ---------------------------------------------------------------------- avra · 2012-08-08 07:06 Quote from: Blue1987 on August 07, 2012, 05:18:49 pmI admit I do not know how the debugger works  it comes up with the assembler... but I do not know how to read it  You should really take a time and learn how to debug Pascal source, how to put breakpoints in your code, how to execute single step, how to use watches, inspect local variables... Time spent on this will get back to you 100 times. You don't have to deal with assembler at all if you set your environment right. http://wiki.lazarus.freepascal.org/Category:Debugging ---------------------------------------------------------------------- Blue1987 · 2012-08-08 11:07 I am trying to learn how to use the debugger... now I think the listbox is not the problem... but errors comes in lines of the source code which does not make sense to me!! I think it is better if I stop porting the application, and start the refactoring (which have to be made in any case) directly in linux! thank you for your support!!