iOS Question Object was not initialized (UIImage) - B4XDialog

angel_

Well-Known Member
Licensed User
Longtime User
I have these lines:

B4X:
Log(DialogoGestorArchivos.IsInitialized)    'Return True'
Log(LstArchivos.IsInitialized) 'Return True'

Then I have this:
B4X:
Wait For (Dialog.ShowTemplate(LstArchivos, "Abrir", "Compartir", "Cancelar") Complete (Result As Int)

And I get the following error, it doesn't happen always:

B4X:
Error occurred on line: 274 (B4XDialog)
Object was not initialized (UIImage)
Stack Trace: (
  CoreFoundation       <redacted> + 252
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       <redacted> + 0
  MyApp             -[B4IObjectWrapper object] + 136
  MyApp             -[B4XViewWrapper Snapshot] + 580
  MyApp             -[b4i_b4xdialog _updateblur:] + 552
  MyApp             -[ResumableSub_b4xdialog_ShowCustom resume::] + 3220
  MyApp             -[b4i_b4xdialog _showcustom:::::] + 736
  MyApp             -[ResumableSub_b4xdialog_ShowTemplate resume::] + 1092
  MyApp             -[b4i_b4xdialog _showtemplate:::::] + 736
 MyApp             -[ResumableSub_b4xmainpage_AA_DialogoGestorProyectos resume::] + 9064
 MyApp             -[b4i_b4xmainpage _aa_dialogogestorproyectos:::] + 572
 CoreFoundation       <redacted> + 144
 CoreFoundation       <redacted> + 292
 MyApp             +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
 MyApp             -[B4IShell runMethod:] + 448
 MyApp             -[B4IShell raiseEventImpl:method:args::] + 2172
 MyApp             -[B4IShellBI raiseEvent:event:params:] + 1580
 MyApp             __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
 libdispatch.dylib    <redacted> + 24
 libdispatch.dylib    <redacted> + 16
 libdispatch.dylib    <redacted> + 1068
 CoreFoundation       <redacted> + 12
 CoreFoundation       <redacted> + 1924
 CoreFoundation       CFRunLoopRunSpecific + 436
 GraphicsServices     GSEventRunModal + 104
 UIKitCore            UIApplicationMain + 212
 MyApp             main + 120
 libdyld.dylib        <redacted> + 4
)

Any suggestions where the problem is?
 
Solution
Check the size or Root right before you show the dialog. If it is zero then that is the problem and adding a Sleep will solve it.

angel_

Well-Known Member
Licensed User
Longtime User
It is related to the blur effect. It fails to get a snapshot of the parent view.
Post the code that initializes the dialog.

B4X:
    Dialog.Initialize(Root)
    m05_Themes.SetLightThemeDialog(Dialog)
B4X:
    Dialog.Initialize(Root)
 
[CODE lang="b4x" title="m05_Themes"] Public Sub SetLightThemeDialog(dialog2 As B4XDialog)
    dialog2.BlurBackground = True
    dialog2.BackgroundColor = xui.Color_White
    dialog2.BorderCornersRadius = 20dip
    dialog2.BorderWidth = 1dip
    dialog2.BorderColor = xui.Color_LightGray
    dialog2.ButtonsColor = xui.Color_Transparent
    dialog2.ButtonsTextColor = 0xFF267BE9
End Sub
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
If I’m not wrong, B4XPage_Resize is just relevant in B4J, it won’t be fired in B4A or B4i
I was wrong. Se attachment in the next post
 
Last edited:
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User

Attachments

  • Screenshot_20210914-065628.jpg
    Screenshot_20210914-065628.jpg
    100.8 KB · Views: 112
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
I have prepared a small project but I have not been able to reproduce the error
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
Check the size or Root right before you show the dialog. If it is zero then that is the problem and adding a Sleep will solve it.
B4X:
Log(Root.Height & "//" & Root.Width)
Wait For (Dialog.ShowTemplate(LstArchivosValidos, "Abrir", "Compartir", "Cancelar") Complete (Result As Int)
'sometimes Root.Width return 0 and it appears the error

Log(Root.Height & "//" & Root.Width)
Sleep(0)
Wait For (Dialog.ShowTemplate(LstArchivosValidos, "Abrir", "Compartir", "Cancelar") Complete (Result As Int)
'sometimes Root.Width return 0 but the error does not appear
Thank you
 
Upvote 0
Top