Hi, I want to call a funtion to open a file. I find the three function: sp_file_open_dialog(*parent, NULL, NULL); sp_file_new_default(); sp_file_open( path, NULL); But when I call these funtions in another thread, it crash inkscape. Is there any required initialization before I call these this function? My program block is like to : ==== bool InkDBus::openFile(const string& path){ bool result = true; bool create_new = true; list< SPDesktop* > desktops; list< SPDesktop* >::iterator iter; inkscape_get_all_desktops(desktops); iter = desktops.begin(); SPDesktop* desktop = *iter; Gtk::Window *parent = desktop->getToplevel(); sp_file_open_dialog(*parent, NULL, NULL); return result; } ==== Thanks first for reading this letter :-) sincerely, Mat.
Mat-48 wrote:
But when I call these funtions in another thread, it crash inkscape. Is there any required initialization before I call these this function?
Inkscape is not multithread-safe. You cannot call arbitrary functions from different threads. To open a file by its path, you need to use sp_file_open. However, the argument must be UTF-8 encoded, so you need to use Glib::ustring instead of std::string, and call it like this: sp_file_open(path.data(), NULL); If you're trying to do something related to D-Bus, consult it with Soren (aka "Glimmer Labs"). Regards, Krzysztof -- View this message in context: http://www.nabble.com/Question-about-file-opening-function-tp24990307p250115... Sent from the Inkscape - Dev mailing list archive at Nabble.com.
Thank you very much!! It's a great hint to mention that Inkscape is not multithread-safe. My implementation does fork another thread to handle d-bus request at run-time. This reason also explain why I encounter some run-time unpredictable broken during d-bus interations. I wish to improve the implementation, but don't know how to write a safe code with inkscape functions. Would you like to give me some hint, like which part of code I can read, or some tutorials else..., so that I can learn more about the inkscape implementation conventions? sincerely, Mat. Krzysztof Kosiński 提到:
Mat-48 wrote:
But when I call these funtions in another thread, it crash inkscape. Is there any required initialization before I call these this function?
Inkscape is not multithread-safe. You cannot call arbitrary functions from different threads.
To open a file by its path, you need to use sp_file_open. However, the argument must be UTF-8 encoded, so you need to use Glib::ustring instead of std::string, and call it like this: sp_file_open(path.data(), NULL);
Thanks for the detail corrections.
If you're trying to do something related to D-Bus, consult it with Soren (aka "Glimmer Labs").
Sure, I wll :-)
Regards, Krzysztof
Hi Soren, I encounter a problem of multithread-safe for D-Bus implementation. Did you encounter this problem before, too? Would you like to share me some hint about this problem? sincerely, Mat. Krzysztof Kosiński 提到:
Mat-48 wrote:
But when I call these funtions in another thread, it crash inkscape. Is there any required initialization before I call these this function?
Inkscape is not multithread-safe. You cannot call arbitrary functions from different threads.
To open a file by its path, you need to use sp_file_open. However, the argument must be UTF-8 encoded, so you need to use Glib::ustring instead of std::string, and call it like this: sp_file_open(path.data(), NULL);
If you're trying to do something related to D-Bus, consult it with Soren (aka "Glimmer Labs").
Regards, Krzysztof
participants (2)
-
Krzysztof Kosiński -
Mat