View Issue Details

IDProjectCategoryView StatusLast Update
0005620Multi Theft Auto : San AndreasClientpublic2015-03-04 10:31
ReporterMdbelenAssigned To 
Status closedResolutionno change required 
Product Version 
Target VersionFixed in Version 
Summary0005620: guiGridListAddColumn returns wrong index after deleting Columns

The returned index of guiGridListAddColumn increases, though Columns added before have been deleted. e.g.:

guiGridListAddColumn(..) returns 1
guiGridListAddColumn(..) returns 2 though there is no 1

if you use guiGridListGetSelectedItem() then it returns the value guiGridListAddColumn should have but hasn't returned: 1

Steps To Reproduce

function testfunc()
agrid = guiCreateGridList(500,500, 300,300, false);

local col1 = guiGridListAddColumn(agrid, 'test1', 0.1);
guiGridListRemoveColumn(agrid, col1);
local col2 = guiGridListAddColumn(agrid, 'test2', 0.1);

outputChatBox('Col1: '..col1..' Col2: '..col2); --returns "Col1: 1 Col2: 2", should be "Col1: 1 Col2: 1" imo

local arow = guiGridListAddRow(agrid);
guiGridListSetItemText(agrid, arow, col2, 'test', false,false);

addEventHandler('onClientGUIDoubleClick', agrid, agridDoubleClick, false);

addCommandHandler ( 'test', testfunc, false );

function agridDoubleClick()
local sRow,sColumn = guiGridListGetSelectedItem(agrid); -this returns the right column (1) not 2
outputChatBox('Row: '..sRow..' Column: '..sColumn);

TagsNo tags attached.



2010-11-06 13:46

viewer   ~~0012114

Last edited: 2010-11-06 14:21

I just recognized that guiGridListGetItemText, guiGridListSetItemText and guiGridListRemoveColumn are using the bugged Columns, too. Seems that guiGridListGetSelectedItem() is the only one using the real ones.


2012-10-10 22:45

manager   ~~0017714

Confirmed, had this problem when trying to delete all columns in ingame performance browser.

Get ipb resource from mtasa-resources
start ipb
/debugscript 3

Observe the debug output:

[2012-10-10 21:45:48] INFO: removing column id a 0 true
[2012-10-10 21:45:48] INFO: removing column id a 1 true
[2012-10-10 21:45:48] INFO: removing column id a 2 true
[2012-10-10 21:45:48] INFO: removing column id a 3 true
[2012-10-10 21:45:48] INFO: removing column id a 4 true
[2012-10-10 21:45:48] INFO: removing column id a 5 true
[2012-10-10 21:45:48] INFO: removing column id a 6 true
[2012-10-10 21:45:48] INFO: removing column id b 0 true
[2012-10-10 21:45:48] INFO: removing column id b 1 true
[2012-10-10 21:45:48] INFO: removing column id b 2 true

Notice the "id b" this should never happen because I already deleted all the columns.


2015-03-04 10:30

administrator   ~~0023072

This behavior is intended and necessary to guarantee unique IDs.

Assuming you've written the following code:
local gridList = guiCreateGridList(0, 0, 200, 200, false)
local columnPlayer = guiGridListAddColumn(gridList, 0.5)
local columnMoney = guiGridListAddColumn(gridList, 0.4)

-- Later in the code
local money = guiGridListGetItemText(gridList, columnPlayer, 1)

When you remove a column between other columns now, you'd have to adjust the column index of all columns next to the removed one which will break the code above.

Issue History

Date Modified Username Field Change