simonkrauter/NiGui

SIGSEGV: Illegal storage access. (Attempt to read from nil?) Segmentation fault

thatrandomperson5 opened this issue · 6 comments

I get this error when running my app:


(process:7994): Gtk-CRITICAL **: 16:05:58.443: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed

(process:7994): Gtk-CRITICAL **: 16:05:58.443: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed

(process:7994): Gtk-CRITICAL **: 16:05:58.443: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Traceback (most recent call last)
/home/pi/Desktop/Nim/memstats/src/tabs/home.nim(3) home
/home/pi/.nimble/pkgs/nigui-0.2.6/nigui.nim(2185) newLayoutContainer
/home/pi/.nimble/pkgs/nigui-0.2.6/nigui/private/gtk3/platform_impl.nim(1223) init
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault

I have no idea what is happening, here is some code

tabs/home.nim

import nigui, ../tabs

var home = newLayoutContainer(Layout_Vertical)
home.add newTextArea("Hello world!")

let hometab* = newTab("Home", home)

main module

import nigui, tabs

app.init()

var window = newWindow("Memstats")

window.width = 600.scaleToDpi
window.height = 400.scaleToDpi
# Set the size of the window

# window.iconPath = "assets/icon.png"

var container = newLayoutContainer(Layout_Vertical)
var tabbox = newLayoutContainer(Layout_Horizontal)
var subbox = newLayoutContainer(Layout_Vertical)
# Tabs
from tabs/home import hometab
tabbox.add hometab.button
subbox.add hometab.internals


# Add parts to main stack
container.add tabbox
container.add subbox
window.add(container)

window.show()

app.run()

Can you please post your tabs.nim file or a more simple complete example?

tabs.nim:

import nigui

type Tab* = ref object
    button*: Button
    internals*: Container

proc newTab*(name: string, content: Container): Tab =
    let t = Tab(button: newButton(name), internals: content)
    t.internals.hide()
    t.button.onClick = proc(event: ClickEvent) =
        t.internals.show()
    return t

OK, I found the issue, it's the order of the statements: app.init() needs to be called before newLayoutContainer().
(On Gtk level: gtk_fixed_new() fails, because gtk_init() was not called before.)

Ok, I will fix it when I have time

OK, I found the issue, it's the order of the statements: app.init() needs to be called before newLayoutContainer().
(On Gtk level: gtk_fixed_new() fails, because gtk_init() was not called before.)

@simonkrauter I can’t seem to find the newLayoutContainer() call that is before app.init(). tabs calls nothing

I found that i need to call app.init() in every module that uses nigui, which is quite annoying.