Code::Blocks Forums

User forums => Help => Topic started by: wever on September 09, 2014, 12:04:42 pm

Title: Watches problem
Post by: wever on September 09, 2014, 12:04:42 pm
I am not sure if this is error in code or I am doing something wrong in code::blocks. I have array
Code
 FILES files[256];
I am saving values to the files[count].name and files[count].filename and I want to check the values which I have in the array files. But I don't see it in the window. I type *files and I see only the first element files[count] but not the rest of the elements. So what to do to watch it complete? With all 256 elements?

Code
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
 
typedef struct  {
  char * name;
  char * filename;
} FILES;
FILES files[256];
 
int readFiles(FILES * files)
{
char * nameTmp;
nameTmp = "gaussian";
int count = 0;
files[count].name =  (char*) malloc( sizeof(char)*256 );
files[count].filename =  (char*) malloc( sizeof(char)*256 );
strcpy(files[count].name,nameTmp);

count++;

files[count].name =  (char*) malloc( sizeof(char)*256 );
files[count].filename =  (char*) malloc( sizeof(char)*256 );
strcpy(files[count].name,nameTmp);
 
}
 
int main()
{
   readFiles(files);
return 0;
}

Also is there any shortcut or hotkey to edit the existing item in Watches? I often want to change from files to *files or something and it is uncomfortable to do it through context menu; it would be much better just to press f2 for rename.
Title: Re: Watches problem
Post by: Jenna on September 09, 2014, 02:01:26 pm
Right-click on the watch, chose properties and select to watch as array, set start-element and count.
For dereferencing you can right-click the watch and chose "Dereference [watchname]".
NO shortcuts available.
F2 would be fine for many plavces where we can rename something, but unfortunately it is also used for switching the "Logs & others" frame on and off, so it's not available for historical reasons (and of course backwards compatibility).
Title: Re: Watches problem
Post by: wever on September 09, 2014, 03:51:24 pm
Sometimes I pressed f2 intuitively when I selected the name of variable and no "window Logs & others" opened. Now it opens, but I think there is some bug. Once it opens, once not. Depending on situation. This is not only problem. I noticed that the auto-update does not work for the old variables which are there in the Watch windows from the previous debug run. So I must update them manually. Maybe F5 could update all the variabes/values in the Watch window similar like we have F5 in browser to update page.

Note, that most of my time (at least 35%) which I spent with using Watches I spent with manipulating/fixing the width of columns.

Yet I did not success to watch the array. I did as you did, but I selected the variable first and clicked on it. Then did what you told.

Here is depicted what I see:
Title: Re: Watches problem
Post by: Jenna on September 09, 2014, 04:52:49 pm
If you watch the variable inside the function, you only see the local variable files, but not the global one.
The local variable is just a pointer, but the global one is an array of 256 FILES structs.
So you get different context-menus inside and outside the function and of course different content of the watch.
Title: Re: Watches problem
Post by: oBFusCATed on September 09, 2014, 07:05:56 pm
Maybe F5 could update all the variabes/values in the Watch window similar like we have F5 in browser to update page.
Can be done, but I have not had a case where it is needed. (It won't be a f5 or any other shortcut, just a menu item).
Probably it will be useful if you disable many watches and then want to update them at once...

Note, that most of my time (at least 35%) which I spent with using Watches I spent with manipulating/fixing the width of columns.
This is known bug I cannot reproduce reliably... so it is almost impossible to fix...

Yet I did not success to watch the array. I did as you did, but I selected the variable first and clicked on it. Then did what you told.
Just do what Jens told you and it should work, at least it has worked for me.
If it still doesn't work, you'll have to enable the full log in the settings of the debugger and then paste it in here (use pastebin like service if it is more than a couple of lines).
Title: Re: Watches problem
Post by: wever on September 09, 2014, 10:29:05 pm
It really works I did not fill the count, that was why nothing changed before.

Yet idea: you could set the widths of Watches columns manually in settings. Would this help to remove the bug?
Title: Re: Watches problem
Post by: wever on September 13, 2014, 04:05:22 pm
It would be great if the variable name in the Watches window could be renamed after single click on the name. I cannot get rid of the habit, that I am always trying to single click on the selected item and expecting that it will enter the edit mode.... I know the command rename is in context menu, but still it would be simpler, faster, intuitive.
Title: Re: Watches problem
Post by: oBFusCATed on September 15, 2014, 12:51:58 am
I don't think that it will be possible because of limitations in wxpropgrid.

You can always use the insert key to start a rename...
Title: Re: Watches problem
Post by: raynebc on September 18, 2014, 12:24:58 am
Note, that most of my time (at least 35%) which I spent with using Watches I spent with manipulating/fixing the width of columns.
This is known bug I cannot reproduce reliably... so it is almost impossible to fix...
Unfortunately I still occasionally run into this issue, usually only after I've had CodeBlocks running for a long time.  I do Remote Desktop into my development computer regularly (while C::B is running), perhaps Windows is resizing the display or program window properties in a way CodeBlocks isn't handling well?