Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot save ini file on exit, dearpygui already exited #1448

Closed
kuchi opened this issue Nov 24, 2021 · 3 comments
Closed

Cannot save ini file on exit, dearpygui already exited #1448

kuchi opened this issue Nov 24, 2021 · 3 comments
Assignees
Labels
priority: high high priority state: ready Fixed/Added and will be present in an upcoming release type: bug bug

Comments

@kuchi
Copy link

kuchi commented Nov 24, 2021

Version of Dear PyGui

DPG Version: 1.1.1
OS: macOS-10.15.7-x86_64-i386-64bit

My Issue/Question

Would be nice to be able to save the ini files using the exit callback. But it seems everything has exited. Seems like the utility of set_exit_callback is currently broken.

I think this is related to #1390

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg
import dearpygui

import platform
print(f"DPG Version: {dearpygui.__version__}")
print(f"OS: {platform.platform()}")

dpg.create_context()

dpg.configure_app(
    wait_for_input=False, # Can set to true but items may not live update. Lowers CPU usage
    init_file="temp.ini",
    docking=True,
    docking_space=True
    ) 

def exit_callback():
    print("Exit called...")
    dpg.save_init_file("temp.ini")

with dpg.window() as main_window:
    dpg.add_text("Hello")
    
dpg.create_viewport()
dpg.setup_dearpygui()
dpg.set_primary_window(main_window, True)
dpg.show_viewport()
dpg.set_exit_callback(exit_callback)
dpg.start_dearpygui()
dpg.destroy_context()

Output

Exit called...
Exception: Error: [1000] Message:       Dear PyGui must be started to use "save_init_file".

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/atanbak/dev/MONOREPO/experimental/libs/dearpygui-eval/bugs/exit_callback.py", line 19, in exit_callback
    dpg.save_init_file("temp.ini")
  File "/Users/atanbak/Library/Caches/pypoetry/virtualenvs/msi-IwjgdkSm-py3.9/lib/python3.9/site-packages/dearpygui/dearpygui.py", line 8614, in save_init_file
    return internal_dpg.save_init_file(file, **kwargs)
SystemError: <built-in function save_init_file> returned a result with an error set
@kuchi kuchi added state: pending not addressed yet type: bug bug labels Nov 24, 2021
@Mstpyt
Copy link
Sponsor Collaborator

Mstpyt commented Nov 25, 2021

As a Workaround till it is fixed:

import dearpygui.dearpygui as dpg
import dearpygui

import platform

print(f"DPG Version: {dearpygui.__version__}")
print(f"OS: {platform.platform()}")

dpg.create_context()

dpg.configure_app(
    wait_for_input=False,  # Can set to true but items may not live update. Lowers CPU usage
    init_file="temp.ini",
    docking=True,
    docking_space=True
)


def exit_callback():
    print("Exit called...")
    dpg.save_init_file("temp.ini")


with dpg.window(on_close=lambda sender, data: exit_callback) as main_window:
    dpg.add_text("Hello")

dpg.create_viewport()
dpg.setup_dearpygui()
dpg.set_primary_window(main_window, True)
dpg.show_viewport()
#dpg.set_exit_callback(exit_callback)
dpg.start_dearpygui()
dpg.destroy_context()

@hoffstadt hoffstadt added priority: high high priority state: ready Fixed/Added and will be present in an upcoming release and removed state: pending not addressed yet labels Nov 29, 2021
@hoffstadt hoffstadt self-assigned this Nov 29, 2021
@hoffstadt
Copy link
Owner

Fixed in next release.

@RyanQ96
Copy link

RyanQ96 commented Feb 13, 2024

Still has segmentation fault:
DPG Version: 1.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high high priority state: ready Fixed/Added and will be present in an upcoming release type: bug bug
Projects
None yet
Development

No branches or pull requests

4 participants