! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
sort settings are reset after program restart
Status:
RESOLVED: FIXED
Product:
Xfce4-taskmanager
Component:
General

Comments

Description Liv 2014-02-03 18:30:03 CET
In 1.0.1, click on RSS column header to sort by that. Now quit and restart xfce4-taskmanager, and notice that the sorting  was reverted to CPU. I would expect the sorting to be remembered (and vaguely recall that this is how it was working in 1.0.0).
Comment 1 Liv 2014-11-07 20:21:43 CET
Any progress on this bug? I get bit by this every other day...
Comment 2 Landry Breuil editbugs 2014-12-20 11:36:41 CET
There's something wrong wrt SortColumn saving in the rc file. Try running (once built with --enable-debug) with G_MESSAGES_DEBUG=all ./src/xfce4-taskmanager, see what is outputted for SortColumn when you click on the header, and compare with the value saved in ~/.config/xfce4/xfce4-taskmanager.rc..
Comment 3 Landry Breuil editbugs 2014-12-20 11:39:57 CET
I *think* this might be related to conflicts between the two enums used in XTM_PTV_COLUMN_COMMAND in process-tree-view.h and COLUMN_COMMAND in process-tree-view.c
Comment 4 Landry Breuil editbugs 2014-12-20 12:11:56 CET
With current git master it *seems* to work... but im not sure.
Comment 5 Liv 2014-12-20 12:42:09 CET
Hmm, for some reason GIT doesn't compile for me: 

cd /tmp
git clone git://git.xfce.org/apps/xfce4-taskmanager

Build Configuration:

* Gksu:          no
* Wnck:          2.30.7
* Cairo:         1.13.1
* GTK+:          2.24.23
* Target OS:     linux-gnu (linux)
* Debug:         minimum

Then upon `make` I get: 
make[3]: Entering directory `/tmp/xfce4-taskmanager/src'
  CC       xfce4_taskmanager-main.o
  CC       xfce4_taskmanager-process-window.o
process-window.c:28:31: fatal error: process-window_ui.h: No such file or directory
 #include "process-window_ui.h"
                               ^
compilation terminated.
make[3]: *** [xfce4_taskmanager-process-window.o] Error 1
make[3]: Leaving directory `/tmp/xfce4-taskmanager/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/tmp/xfce4-taskmanager/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/xfce4-taskmanager'
make: *** [all] Error 2

Am I doing something wrong?
Comment 6 Landry Breuil editbugs 2014-12-20 13:32:33 CET
yeah, rerun autogen.sh so that --enable-maintainer-mode is passed to configure, this way the targets regenerating the _ui.h files are added to the Makefile.. actually, i'm not sure this should be conditional to MAINTAINER_MODE.
Comment 7 Liv 2014-12-20 14:04:22 CET
Yup, that worked. With current GIT simple `./configure` fails, but `./configure --enable-maintainer-mode` works. 


In any case, with GIT sorting memory still doesn't work for me. With `G_MESSAGES_DEBUG=all xfce4-taskmanager`, when I hit the RSS header I get this in the console: 
(xfce4-taskmanager:1699): xfce4-taskmanager-DEBUG: Last sort column 1; sort type: 0
(xfce4-taskmanager:1699): xfce4-taskmanager-DEBUG: New sort column 7; sort type: 1

While in `~/.config/xfce4/xfce4-taskmanager.rc` I see: 
SortColumn=0
SortType=0

The two values above don't change between sessions, even if I change sorting of a given column. I tried removing the file, but it never gets re-created.
Comment 8 Landry Breuil editbugs 2014-12-20 15:19:11 CET
Hah, interesting so it might be a config file saving issue then, not specific to sorting order.. can you try changing other settings and see if the file is saved/created ? Here it seems the file is saved.
Comment 9 Liv 2014-12-20 15:35:48 CET
OK. When I change sort order, nothing gets saved. But if I check, say, 'State' to add this column in the main UI, then the file gets instantly created.
Comment 10 Liv 2014-12-20 15:35:48 CET
OK. When I change sort order, nothing gets saved. But if I check, say, 'State' to add this column in the main UI, then the file gets instantly created.
Comment 11 Landry Breuil editbugs 2014-12-20 15:58:02 CET
Can you try with replacing "column-id" by "sort-column-id" here :

http://git.xfce.org/apps/xfce4-taskmanager/tree/src/process-tree-view.c#n747

? I'm not sure that's related to the issue we're seeing here, but i think this is bogus..
Comment 12 Liv 2014-12-20 16:08:15 CET
I replaced "column-id" by "sort-column-id" and recompiled, which was fine. But I still don't get the sorting remembered between sessions. It's always like this in the config file: 
SortColumn=0
SortType=0
Comment 13 Landry Breuil editbugs 2014-12-21 21:19:03 CET
I'm sorry, but with current git master (without the proposed change) i can't reproduce at all here. If i change the sort column, the content is not changed immediately in the existing xfce4-taskmanager.rc file, but upon exit the file is correctly updated, and at the next start the setting is correctly applied from the file.

Can you instrument xtm_settings_save_settings() here http://git.xfce.org/apps/xfce4-taskmanager/tree/src/settings.c#n325 and add a debug statement like g_warning("name=%s, v=%s", spec->name, string); to print the key/value pair about to be saved in the file ?
Comment 14 Liv 2014-12-21 21:48:53 CET
Hmm, this is strange. Here when I change the sort column, the content is not changed immediately in the existing xfce4-taskmanager.rc file nor upon exit. The modified time-stamp of the file doesn't change at all. 

I patched xtm_settings_save_settings() which now reads: 
            string = g_value_get_string (&dst);
            g_warning("name=%s, v=%s", spec->name, string);

And here's what I see. When starting via `G_MESSAGES_DEBUG=all src/xfce4-taskmanager`, then xfce4-taskmanager.rc gets immediately modified  and I get a bunch of Warning messages in the console, including: 
(xfce4-taskmanager:24460): xfce4-taskmanager-WARNING **: name=sort-column-id, v=0

(xfce4-taskmanager:24460): xfce4-taskmanager-WARNING **: name=sort-type, v=0


When changing the 'Show State column' checkbox, then xfce4-taskmanager.rc gets immediately modified and I get a bunch of Warning messages in the console, including: 
(xfce4-taskmanager:24304): xfce4-taskmanager-WARNING **: name=sort-column-id, v=0

(xfce4-taskmanager:24304): xfce4-taskmanager-WARNING **: name=sort-type, v=0


BUT when changing the sort column and sort order, then xfce4-taskmanager.rc does not get modified and I do not get any warning messages at all. I suspect that somehow xtm_settings_save_settings() simply doesn't get triggered upon that event. 

How can we detect if xtm_settings_save_settings() gets called when needed?
Comment 15 Liv 2014-12-21 21:53:33 CET
I also tried this trick. First change column sort, then change State checkbox. Here's what I see: 

(xfce4-taskmanager:24584): xfce4-taskmanager-DEBUG: Last sort column 1; sort type: 0
(xfce4-taskmanager:24584): xfce4-taskmanager-DEBUG: New sort column 7; sort type: 1
(xfce4-taskmanager:24584): xfce4-taskmanager-DEBUG: Last sort column 7; sort type: 1
(xfce4-taskmanager:24584): xfce4-taskmanager-DEBUG: New sort column 7; sort type: 0

[..]

(xfce4-taskmanager:24584): xfce4-taskmanager-WARNING **: name=sort-column-id, v=0

(xfce4-taskmanager:24584): xfce4-taskmanager-WARNING **: name=sort-type, v=0


It seems that something doesn't get triggered after a change column sort event...
Comment 16 Landry Breuil editbugs 2014-12-21 22:01:04 CET
The way i understand the code, the file seems saved several times upon startup (!) and then upon exit xtm_process_window_finalize() is called, sets some properties on window->settings object, which calls xtm_settings_set_property(), which compares the existing value with the new value of the property, which calls xtm_settings_save_settings if settings needs to be saved.
Comment 17 Liv 2014-12-21 22:05:36 CET
Hmm, but then why I after I fiddle with the sort column, the relevant settings to saved are unchanged: 
(xfce4-taskmanager:24584): xfce4-taskmanager-WARNING **: name=sort-column-id, v=0

(xfce4-taskmanager:24584): xfce4-taskmanager-WARNING **: name=sort-type, v=0


They're always like this, however I change the sorting order or column. Maybe these changes don't get registered properly, and then when the check happens on what has changed these changes are not detected hence the save is not triggered. Can we debug what happens after the event, and what values get stored in memory?
Comment 18 Landry Breuil editbugs 2014-12-21 22:16:12 CET
Yes, using gdb, setting a breakpoint on column_clicked in process-tree-view.c, and same in the set_property/get_property functions in settings.c.

But to me, the value is actually stored/saved only upon exit when the window is finalized in http://git.xfce.org/apps/xfce4-taskmanager/tree/src/process-window.c#n239
Comment 19 Landry Breuil editbugs 2014-12-21 22:22:24 CET
Created attachment 5828 
Tentative patch

i doubt that'll change anything, but maybe try this, it removes an unneeded cast and uses the correct variable type for sort_column_id - and also fetches sort-column-id prop instead of column-id - that doesnt seem needed (here i have the same results without this change) but still looks wrong.
Comment 20 Landry Breuil editbugs 2014-12-21 22:31:24 CET
Ok, i think i have an idea what's going on... did you reorder the columns, and thus have a ColumnsPositions key in the rc file ? What happens if you remove the line (coming back to the default column ordering) and then change sort column, exit and restart, still without changing the columns ordering ?

Here, works fine without reordering. As soon as i reorder the columns, the sort column behaviour is wrong.
Comment 21 Landry Breuil editbugs 2014-12-21 22:35:44 CET
something is definitely fishy. It worked 100% fine before, and now that i modified the columns ordering, even after coming back to the default ordering, the sort column isnt saved.
Comment 22 Liv 2014-12-21 22:36:02 CET
OK! I think found the culprit. You're probably using the systray icon. Try disabling it, restart, change column sort, and then see if any changes get saved and restored upon close/restart. It should fail. 
If I enable the systray icon, then change column sort, the close app, then Quit, only then I do get different values in the debug messages: 
(xfce4-taskmanager:28512): xfce4-taskmanager-WARNING **: name=sort-column-id, v=7

(xfce4-taskmanager:28512): xfce4-taskmanager-WARNING **: name=sort-type, v=1

But then it strangely doesn't get restored: 
geek@liv-inspiron:/tmp/xfce4-taskmanager$ G_MESSAGES_DEBUG=all src/xfce4-taskmanager
[..]
(xfce4-taskmanager:28431): xfce4-taskmanager-WARNING **: name=sort-column-id, v=0

(xfce4-taskmanager:28431): xfce4-taskmanager-WARNING **: name=sort-type, v=0

Even if now the config file reads: 
SortColumn=7
SortType=1


Weird!! Also, try to redo all this debugging with a fresh config file.
Comment 23 Landry Breuil editbugs 2014-12-21 22:40:04 CET
I think without config file, only changing the sort column doesnt trigger a config file write, you need to change another setting (like enabling another column, or another setting) so that the file is actually written.
Comment 24 Liv 2014-12-21 22:41:32 CET
Sure. Start with no config, then change a setting (like Show State column), then change order, then close and restart. You should be able to reproduce then. (Definitely don't enable systray icon.)
Comment 25 Landry Breuil editbugs 2014-12-22 22:21:24 CET
(In reply to Liviu Andronic from comment #22)
> OK! I think found the culprit. You're probably using the systray icon. Try
> disabling it, restart, change column sort, and then see if any changes get
> saved and restored upon close/restart. It should fail. 
> If I enable the systray icon, then change column sort, the close app, then
> Quit, only then I do get different values in the debug messages: 
> (xfce4-taskmanager:28512): xfce4-taskmanager-WARNING **:
> name=sort-column-id, v=7
> 
> (xfce4-taskmanager:28512): xfce4-taskmanager-WARNING **: name=sort-type, v=1
> 
> But then it strangely doesn't get restored: 
> geek@liv-inspiron:/tmp/xfce4-taskmanager$ G_MESSAGES_DEBUG=all
> src/xfce4-taskmanager
> [..]
> (xfce4-taskmanager:28431): xfce4-taskmanager-WARNING **:
> name=sort-column-id, v=0
> 
> (xfce4-taskmanager:28431): xfce4-taskmanager-WARNING **: name=sort-type, v=0
> 
> Even if now the config file reads: 
> SortColumn=7
> SortType=1
> 

That is misleading, because for some reason at startup it seems to *save* settings before actually reading them. If you look at all the log, it'll say this, then that it read the correct value.

$G_MESSAGES_DEBUG=all src/xfce4-taskmanager 
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving settings
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-column-id->0
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-type->0
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving settings
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-column-id->0
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-type->0
....
....
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-column-id->0
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-type->0
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: read property name=sort-column-id -> 7
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving settings
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-column-id->7
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-type->0
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: read property name=sort-type -> 1
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving settings
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-column-id->7
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving name=sort-type->1
(xfce4-taskmanager:17856): xfce4-taskmanager-DEBUG: saving settings

I've tried for 45mn to reproduce on another computer, and failed to reproduce the issue. Moving columns around, changing sort column/direction... it seems always correctly restored upon start.

Did you try removing the cast like i proposed in the posted patch ?
Comment 26 Landry Breuil editbugs 2014-12-22 22:26:49 CET
Hah! i think i found it.. all my testing was done by exiting the window using escape, which is a shortcut. If i close the window using the window close button, the settings aren't saved. Digging into that idea...
Comment 27 Landry Breuil editbugs 2014-12-22 22:42:46 CET
Okay. As far as i understand it.... the two different codepaths here are:

when exiting with escape, a delete-event signal is trigerred, then the window is finalized by xtm_process_window_finalize(). At that point window->window still exists, so the code block going g_object_set (window->settings) with all the sort setting/window size is executed, effectively saving the settings.

on the other hand, when you close the window using the wm close button, a delete-event signal is trigerred, then a destroy signal is trigerred on the window, and finally xtm_process_window_finalize() is called. At that point, window->window has already been destroyed, so the code block saving the settings ins not executed. Column Sort or window size settings done since the last call to xtm_settings_save_settings() are lost.
Comment 28 Landry Breuil editbugs 2014-12-22 23:06:33 CET
Created attachment 5831 
Move the code setting window properties to delete-event callback

I think this patch fixes the issue here, in both usecases. Care to test and confirm ?
Comment 29 Liv 2014-12-22 23:26:24 CET
Good catch! I always used the WM to close the app. 

The patch seems to be helping things. I started with a fresh config, and now settings are being saved when closing via WM cross. And the settings are being saved correctly, from what I see. For instance: 
(xfce4-taskmanager:28935): xfce4-taskmanager-WARNING **: name=sort-column-id, v=1

(xfce4-taskmanager:28935): xfce4-taskmanager-WARNING **: name=sort-type, v=1


and:
SortColumn=1
SortType=1


But for some reason they're being initialized incorrectly, as after restart I get sorting on the 2nd column. Upon exit, I see this (even though I haven't touched a thing!):  

(xfce4-taskmanager:28983): xfce4-taskmanager-WARNING **: name=sort-column-id, v=2

(xfce4-taskmanager:28983): xfce4-taskmanager-WARNING **: name=sort-type, v=1


To reproduce, start with empty config, click on 1st column header to change sort order, close via WM cross, restart, and notice that the columns are sorted by the 2nd column. Do you see this?
Comment 30 Landry Breuil editbugs 2014-12-23 21:19:51 CET
I can reproduce that one here *only* if i leave the tweak from comment 11.. Are you sure you only have the patch from attachment 5831 , or you also have the tweak from comment 11 ? if so, remove it, because it turns out *i* was wrong here.
Comment 31 Landry Breuil editbugs 2014-12-23 21:50:08 CET
Attachment 5831  pushed to master in 007c2c6c, edited to remove the GTK_IS_WINDOW check (we're sure there's a window at that point). Reopen if you still see issues with a clean master checkout.

Bug #10670

Reported by:
Liv
Reported on: 2014-02-03
Last modified on: 2014-12-23

People

Assignee:
Landry Breuil
CC List:
1 user

Version

Version:
unspecified

Attachments

Additional information