mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #126] Question: Pointer to lxw_worksheet if lxw_workbook is closed #106
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#106
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @petricf on GitHub (Sep 5, 2017).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/126
Originally assigned to: @jmcnamara on GitHub.
If - by accident or coding error - lxw_worbook is closed, but lxw_woksheet/-format/... is used afterwards - what does happen ?
Does it throw an assert, ignore requests, invalid memory access exception, ... ?
Is there a method to verify that the workbook is closed when actually using the other pointers ?
In other words - can i check (for example) an lxw_worksheet pointer whether the accompanied workbook is still open ?
Functions like
to check the pointers without requiring access to lxw_workbook pointer would be nice.
Reasoning: At the location i use lxw_worksheet i have currently no access to its accompanied lxw_workbook.
@jmcnamara commented on GitHub (Sep 6, 2017):
Currently there isn't a warning but there probably should be. Also, I could add a function to check if a workbook is closed.
However, I'm not convinced by the use case for accessing the workbook from a worksheet. That seems to me to be something that could be handled in the application logic.
If that part of the request gets some +1 then I'll add it.
@petricf commented on GitHub (Sep 6, 2017):
All functions writing to a worksheet do not need access to the lxw_workbook pointer. They have a lxw_worksheet pointer.
If you simply pass the the worksheet pointer to separate (for example) thread or (im my case) a separate class instance (at init) you run in a problem (no - not if you code carefully - but shit happens ...).
Inside there you don't know whether the workbook have been already closed when accessing the class methods (which are using the worksheet pointer to write data) later.
So you have a worksheet pointer whose workbook have been closed but you do not have the ability to verify this.
@jmcnamara commented on GitHub (Sep 6, 2017):
For me this is the important part. In general I am against adding syntactic sugar for things that can be handled in the end-users application apart from cases that are really painful to do otherwise or cases that are frequently requested.
@petricf commented on GitHub (Sep 6, 2017):
Sure. But nobody is perfect - even i am not.
Having a safeguard - in my opinion - is never a mistake.