?:0: attempt to index field '_view' (a nil value) in Calendar

Hello rob,

               I think it is too much long time to investigate the bug. I tried hard to solve these issue by my side and i found these issue only occurs where we use showOverly. please assist the engineer to investigate the bug so it will be prevent the troubles of development with corona sdk. 

Thank you

Can you repost your code wrapping it in

[lua] and [/lua]

tags?

Can you post the entire stack trace you are getting from your terminal/command window?

Rob

Hello Rob ,

                 I am using these calendar pickerwheel scene as a composer overlay but i am getting an unexpected error when i m going to hide the scene after selecting a particular date and trying to hide the scene on the click of the close button and it is occured randomly not everytime. This is the create scene  code ::

[lua]

local widget = require( “widget” )

local date 

local month

local year

local widget = require( “widget” )

– Create two tables to hold data for days and years      

local days = {}

local years = {}

– Populate the “days” table

for d = 1, 31 do

   days[d] = d

end

– Populate the “years” table

for y = 1, 48 do

   years[y] = 2000 + y

end

– Configure the picker wheel columns

local columnData = 

{

   – Months

   { 

       align = “right”,

       width = 140,

       startIndex = 5,

       labels = { “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }

   },

   – Days

   {

       align = “center”,

       width = 60,

       startIndex = 18,

       labels = days

   },

   – Years

   {

       align = “center”,

       width = 80,

       startIndex = 10,

       labels = years

   }

}

– Image sheet options and declaration

local options = {

   frames = 

   {

       { x=0, y=0, width=320, height=222 },

       { x=320, y=0, width=320, height=222 },

       { x=640, y=0, width=8, height=222 }

   },

   sheetContentWidth = 648,

   sheetContentHeight = 222

}

local pickerWheelSheet = graphics.newImageSheet( “images/widget-pickerwheel.png”, options )

– Create the widget

local pickerWheel2 = widget.newPickerWheel

{

   top = display.contentHeight*0.5-110,

   columns = columnData,

   sheet = pickerWheelSheet,

   overlayFrame = 1,

   overlayFrameWidth = 320,

   overlayFrameHeight = 222,

   backgroundFrame = 2,

   backgroundFrameWidth = 320,

   backgroundFrameHeight = 222,

   separatorFrame = 3,

   separatorFrameWidth = 8,

   separatorFrameHeight = 222,

   columnColor = { 0, 0, 0, 0 },

   fontColor = { 0.4, 0.4, 0.4, 0.5 },

   fontColorSelected = { 0.2, 0.6, 0.4 }

}

local function onCloseTouch( … )

   – body

   local values = pickerWheel2:getValues()

   – Get the value for each column in the wheel (by column index)

   day = values[1].value

   month = values[2].value

   year = values[3].value

      

   composer.hideOverlay()

end

local closeBtn = display.newImageRect(“images/close.png”,40,40)

closeBtn.x = _W-15–display.contentWidth*0.9

closeBtn.y = display.contentHeight*0.5-110

closeBtn:addEventListener(“tap”,onCloseTouch)

[/lua]

And i am sending the values in previous scene using parent:fromCalendar(date,month,year).

Stack Traceback Error : 

Dec 15 11:09:09.122: Runtime error

?:0: attempt to index field ‘_view’ (a nil value)

stack traceback:

?: in function <?:947>

?: in function <?:221>

Thank you

I think we need to see more code.  How you’re calling this scene?  What’s the deal with day, month, year as they appear global, etc.

Please put in the codes and around your code so it will format correctly.

Rob

Hello Rob

I am calling the function onDatePicker to load a pickerWheel Calendar overlay on the click of DateField object.

[lua]

 local function onDatePicker( event )

        if event.phase == “ended” then                 

            

            – Options table for the overlay scene “pause.lua”

            local options = {

                isModal = true,

                effect = “fade”,

                time = 100,

            }

            descrptField.isVisible = false

            benifield.isVisible = false

            currentObj = event.target

            composer.showOverlay( “datePicker2”, options )

        end

    end

    local date = os.date( “*t” ) 

    local dateLabel = (date.day…"-"…date.month …"-"…date.year) 

    DateField = widget.newButton

        {

            width = _W,

            height = 30,

            defaultFile = “images/timeBg.png”,

            overFile = “images/timeBg_hover.png”,

            id = “ContryName”,

            label = dateLabel,

            labelAlign = “right”,

            labelColor = { default={ 0.3,0.3,0.3  }, over={ 0.3, 0.3, 0.3, 0.5 } },

            labelXOffset = -6,

            labelYOffset = -2,

            fontSize  = 12,

            font = constants.mainFont,

            onEvent = onDatePicker,

        }

    DateField.x = 0

    DateField.y = borderrect.y + borderrect.height + 5

    DateField.anchorX = 0

    sceneGroup:insert(DateField)

[/lua]

So when it moves in calendar scene there is  datePicker2.lua. 

[lua]

local composer = require( “composer” )

local scene = composer.newScene()

local widget = require( “widget” )

local constants = require(“constants”)

local date

local month

local year


function scene:create( event )

local sceneGroup = self.view

local date = os.date( “*t” ) 

    local dateLabel = (date.day…"-"…date.month …"-"…date.year) 

– Create two tables to hold data for days and years      

local days = {}

local years = {}

– Populate the “days” table

for d = 1, 31 do

   days[d] = d

end

– Populate the “years” table

for y = 1, 40 do

   years[y] = 2000 + y

end

– Configure the picker wheel columns

local columnData = 

{

   – Months

   { 

       align = “left”,

       width = 120,

       startIndex = 14,

       labels = years

        },

   – Days

   {

       align = “left”,

       width = 70,

       startIndex = date.day,

       labels = days

   },

   – Years

   {

       align = “center”,

       width = 70,

       startIndex = date.month,

       labels = { “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }

   }

}

– Image sheet options and declaration

local options = {

   frames = 

   {

       { x=12, y=20, width=335, height=220 },

      – { x=110, y=0, width=110, height=218 },

       --{ x=220, y=0, width=110, height=218 }

   },

   sheetContentWidth = 335,

   sheetContentHeight = 270

}

local pickerWheelSheet = graphics.newImageSheet( “images/pickerWheel.png”, options )

– Create the widget

local pickerWheel = widget.newPickerWheel

{

   top = display.contentHeight*0.5-110,

   left = 2,

   columns = columnData,

   sheet = pickerWheelSheet,

   overlayFrame = 1,

   overlayFrameWidth = 335,

   overlayFrameHeight = 220,

   backgroundFrame = 2,

   backgroundFrameWidth = 0,

   backgroundFrameHeight = 0,

   seperatorFrame = 3,

   seperatorFrameWidth = 0,

   seperatorFrameHeight = 0

}

sceneGroup:insert(pickerWheel)

– Get the table of current values for all columns

– This can be performed on a button tap, timer execution, or other event

local function onCloseTouch( … )

   – body

   local values = pickerWheel:getValues()

   if values[3].value == “January” then

    values[3].value = 01

   elseif values[3].value == “February” then

    values[3].value = 02

   elseif values[3].value == “March” then

    values[3].value = 03

   elseif values[3].value == “April” then

    values[3].value = 04

   elseif values[3].value == “May” then

    values[3].value = 05

   elseif values[3].value == “June” then

    values[3].value = 06

   elseif values[3].value == “July” then

    values[3].value = 07

   elseif values[3].value == “August” then

    values[3].value = 08

   elseif values[3].value == “September” then

    values[3].value = 9

   elseif values[3].value == “October” then

    values[3].value = 10

   elseif values[3].value == “November” then

    values[3].value = 11

   elseif values[3].value == “December” then

    values[3].value = 12

end

   – Get the value for each column in the wheel (by column index)

    date = values[2].value

    month = values[3].value

    year = values[1].value 

   print(hour,min,timeMode)

   composer.hideOverlay( “fade”, 100 )

end

local closeBtn = display.newImageRect(“images/close.png”,40,40)

closeBtn.x = display.contentWidth*0.9

closeBtn.y = display.contentHeight*0.5-110

closeBtn:addEventListener(“tap”,onCloseTouch)

sceneGroup:insert(closeBtn)

end

function scene:show( event )

local sceneGroup = self.view

local phase = event.phase

if phase == “will” then

constants.prevScene = “nochange”

– Called when the scene is still off screen and is about to move on screen

elseif phase == “did” then

– Called when the scene is now on screen

– 

– INSERT code here to make the scene come alive

– e.g. start timers, begin animation, play audio, etc.

end

end

function scene:hide( event )

local sceneGroup = self.view

local phase = event.phase

local parent = event.parent

if event.phase == “will” then

parent:fromCalendar(date,month,year)

elseif phase == “did” then

– Called when the scene is now off screen

end

end

function scene:destroy( event )

local sceneGroup = self.view

– Called prior to the removal of scene’s “view” (sceneGroup)

– 

– INSERT code here to cleanup the scene

– e.g. remove display objects, remove touch listeners, save state, etc.

end


– Listener setup

scene:addEventListener( “create”, scene )

scene:addEventListener( “show”, scene )

scene:addEventListener( “hide”, scene )

scene:addEventListener( “destroy”, scene )


return scene

[/lua]

So in this scene after selecting any date when user click on close button it sends the date (date month, year) values to previous scene by calling parent method in hide scene. So i am getting this error for sometime which i did not rectifying.

This is the total stack Trace of error :

Dec 17 11:54:01.757: Runtime error

?:0: attempt to index field ‘_view’ (a nil value)

stack traceback:

?: in function <?:947>

?: in function <?:221> 

Thank you

I don’t know if this is it or not, but consider:

&nbsp; &nbsp;local values = pickerWheel:getValues() &nbsp; &nbsp; &nbsp;if values[3].value == "January" then &nbsp; &nbsp; values[3].value = 01 &nbsp; &nbsp;elseif values[3].value == "February" then &nbsp; &nbsp; values[3].value = 02 &nbsp; &nbsp;elseif values[3].value == "March" then &nbsp; &nbsp; values[3].value = 03 &nbsp; &nbsp;elseif values[3].value == "April" then &nbsp; &nbsp; values[3].value = 04 &nbsp; &nbsp;elseif values[3].value == "May" then &nbsp; &nbsp; values[3].value = 05 &nbsp; &nbsp;elseif values[3].value == "June" then &nbsp; &nbsp; values[3].value = 06 &nbsp; &nbsp;elseif values[3].value == "July" then &nbsp; &nbsp; values[3].value = 07 &nbsp; &nbsp;elseif values[3].value == "August" then &nbsp; &nbsp; values[3].value = 08 &nbsp; &nbsp;elseif values[3].value == "September" then &nbsp; &nbsp; values[3].value = 9 &nbsp; &nbsp;elseif values[3].value == "October" then &nbsp; &nbsp; values[3].value = 10 &nbsp; &nbsp;elseif values[3].value == "November" then &nbsp; &nbsp; values[3].value = 11 &nbsp; &nbsp;elseif values[3].value == "December" then &nbsp; &nbsp; values[3].value = 12 end &nbsp; &nbsp;-- Get the value for each column in the wheel (by column index) &nbsp; &nbsp; date = values[2].value &nbsp; &nbsp; month = values[3].value &nbsp; &nbsp; year = values[1].value 

 

perhaps this might help:

 

&nbsp; &nbsp;local values = pickerWheel:getValues() &nbsp; &nbsp;&nbsp; local month = 0 &nbsp; &nbsp;if values[3].value == "January" then &nbsp; &nbsp; month = 1 &nbsp; &nbsp;elseif values[3].value == "February" then &nbsp; &nbsp; month = 2 &nbsp; &nbsp;elseif values[3].value == "March" then &nbsp; &nbsp; month = 3 &nbsp; &nbsp;elseif values[3].value == "April" then &nbsp; &nbsp; month = 4 &nbsp; &nbsp;elseif values[3].value == "May" then &nbsp; &nbsp; month = 5 &nbsp; &nbsp;elseif values[3].value == "June" then &nbsp; &nbsp; month = 6 &nbsp; &nbsp;elseif values[3].value == "July" then &nbsp; &nbsp; month = 7 &nbsp; &nbsp;elseif values[3].value == "August" then &nbsp; &nbsp; month = 8 &nbsp; &nbsp;elseif values[3].value == "September" then &nbsp; &nbsp; month = 9 &nbsp; &nbsp;elseif values[3].value == "October" then &nbsp; &nbsp; month = 10 &nbsp; &nbsp;elseif values[3].value == "November" then &nbsp; &nbsp; month = 11 &nbsp; &nbsp;elseif values[3].value == "December" then &nbsp; &nbsp; month = 12 end &nbsp; &nbsp;-- Get the value for each column in the wheel (by column index) &nbsp; &nbsp; date = values[2].value &nbsp; &nbsp; --month = values[3].value &nbsp; &nbsp; year = values[1].value 

 

I’m not sure how writing back to the pickerView by setting values that way is safe.

I integrate this thing with my code but the error occurring as usual :( . These error mostly  occurring  when i put the start index for month > 9.when i changed it to < 9 it is not affect. 

try and wrap a:  tonumber(date.day) and make sure it’s really a number.

yeah i wrapped it with tonumber. It is a number value. I dont know but error only occurs when i put the start index of any column more than 9 except less numbers. 

The only thing that should cause a problem is if a string (or some other object) is passed in and not a number.  You might want to print out some values:

print( date.day )

print( type( date.day ) )

print( tonumber( date.day ) )

print( type( tonumber( date.day ) ) )

And report back the values you get.

Yes rob , I printed both date.day and date.month when i passed them.

[LUA]

print(“For days ======”)

print( date.day )

print( type( date.day ) )

print( tonumber( date.day ) )

print( type( tonumber( date.day ) ) )

print(“for Months ========”)

print( date.month )

print( type( date.month ) )

print( tonumber( date.month ) )

print( type( tonumber( date.month ) ) )

[/LUA]

So these is passing only numbers in it.and It prints : 

 For days ======

 22

number

22

number

for Months ========

12

number

12

number

and these error as usual even when i am not calling the hide scene. 

I guess at this point, we will need you to file a bug report on it.  We will need a small sample app that demos the project complete with any assets needed to run it, the config.lua and build.settings you are using.  Please compress it into a .zip file and use the “Report a bug” link at the top of the page.  You will get an email back from the bug tracker.  Please post the case # from the subject of the e-mail and back to this thread as a reference.

Rob

Hello Rob,

                 I have posted a small sample app demo for that bug at “Report a bug” blog. this is the case # : Case 37877. 

                 Please check it.

                Thank you

Hello Rob ,

                 Have you checked the sample app. If corona team find any solution for that bug please reply in this thread.

Thank you  :slight_smile:

It’s the holidays and most people are away enjoying a much needed break.  This probably won’t get looked at until after the first of the year and it will get prioritized with other things we have to do.

Rob

yes rob,

            Sorry ! i forgot to think about the most-anticipated religious and cultural festivity of the year. I agree with your apprise.

   

           Thanks and Regards for the feedback.  :slight_smile:

Hello Corona Team,

                               I am waiting for any positive response for case : 37877 bug. I hope it will be fix soon. :)  

hello rob, Thanx for release CoronaSDK-2015.2581 build.  :slight_smile:

It has been assigned to an engineer, but it’s still in the queue to work on.

Rob

I am eager to see the response.