-
Notifications
You must be signed in to change notification settings - Fork 152
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
notes@schorschii: Warning when adding desklet: "This desklet contains function calls that could potentially cause Cinnamon to crash or freeze" #428
Comments
Hello, @jeremy21212121. That message that you see is a warning, not an error. It's mostly there so, in the case of a Cinnamon crash/freeze/lock, you start looking the xlets that have that warning as possible culprits. Using a synchronous file read function isn't inherently bad and not always is possible to replace with an asynchronous call. In fact, Replacing the call to If you actually want to "fix" the issue, you could just use an asynchronous file read function. I have been using let file = Gio.file_new_for_path("/path/to/file");
file.load_contents_async(null, (aFile, aResponce) => {
let success,
contents,
tag;
try {
[success, contents, tag] = aFile.load_contents_finish(aResponce);
} catch (aErr) {
global.logError(aErr.message);
return;
}
if (!success) {
global.logError("Error reading file.");
return;
}
global.log(contents);
}); |
ping author @schorschii |
After installing notes@schorschii, there is a warning in the Desklets UI: "This desklet contains function calls that could potentially cause Cinnamon to crash or freeze".
I found the function calls that trigger that warning here. The specific function call triggering this warning in notes is
Cinnamon.get_file_contents_utf8_sync()
.I changed two instances of that function call to
String(GLib.file_get_contents("/path/to/yourFile")[1])
, and that removed the error.But then it dawned on me, perhaps that warning is there because a synchronous file read, in general, has the potential to crash Cinnamon (ie. if the file is really large). If that were the case, then using
GLib.file_get_contents()
instead ofCinnamon.get_file_contents_utf8_sync()
would just be working around the warning but not actually fixing the underlying reason for the warning. Reading the commit message here confirmed my suspicion that synchronous file reads are the issue.Reading the source code for
Cinnamon.get_file_contents_utf8_sync()
, it appears to just be using Glib's file_get_contents under the hood, combined with a few sanity checks.So, if I wanted to actually fix the underlying reason for that warning, do I need to use an asynchronous file read function? I think that would not be practical, as the whole desklet seems to be inherently synchronous. Or would it suffice to just check the size of the text file before attempting to load it?
Thanks in advance. I'm a JS dev, but this is my first time diving into desklet/applet dev.
The text was updated successfully, but these errors were encountered: