Hi all, "SP_ACTIVE_DOCUMENT" or equivalently "inkscape_active_document" uses the current active desktop to find out which document is active. So SP_ACTIVE_DOCUMENT will not work if there is no GUI (cmdline Inkscape), and will return NULL. To allow one to call SP_ACTIVE_DOCUMENT to obtain the SPDocument, I am proposing to 'fall back' to take the first listed document in the Inkscape instance if desktop==NULL.
In inkscape.cpp:
SPDocument * inkscape_active_document (void) { if (SP_ACTIVE_DESKTOP) { return sp_desktop_document (SP_ACTIVE_DESKTOP); } else if (!inkscape->document_set.empty()) { return document_set.begin()->first; }
return NULL; }
I know we should move away from SP_ACTIVE_DOCUMENT and friends, but let's do the proposed change for sake of getting functionality now instead of over 5 years. ;-) It is related to fixing r11804 [1] to work from the cmdline.
Cheers, Johan
[1] http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/11804#src/...
2012/11/5 Johan Engelen <jbc.engelen@...2592...>:
I know we should move away from SP_ACTIVE_DOCUMENT and friends, but let's do the proposed change for sake of getting functionality now instead of over 5 years. ;-)
+1 agree.
SP_ACTIVE_DOCUMENT and similar things are not inherently bad - they're just used inappropriately in some places. E.g. you want the contents of a docked dialog to be related to the window in which it is docked, but when pressing Ctrl+V you want the paste command to execute in the active document.
Regards, Krzysztof
participants (2)
-
Johan Engelen
-
Krzysztof Kosiński