| [ Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]
STR #13
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 4 - High, e.g. key functionality not working |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Core Library |
Summary: | Strange behaviour of Fl_Preferences::deleteGroup() - problem & (maybe) solution |
Version: | 1.1.3 |
Created By: | francesco.bradascio |
Assigned To: | mike |
Fix Version: | 1.1.4 |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | francesco.bradascio 06:27 Apr 13, 2003 |
| In the fltk-1.1.3, when you remove a group, which is not the first, with the Fl_Preferences::deleteGroup(), and after that you rescan the preferences, without reloading them from the file, all the groups preceding the deleted one can't be no more accessed, debugging my application I've found the next_ pointer of the group preceeding the one deleted isn't updated but also the first child of the chain is set to the group next to the deleted one, follows the test code:
>>>>>>>>>>>> TEST CODE STARTS HERE <<<<<<<<<<<<<<<<<<<<<<<
#include <stdio.h> #include <FL/Fl_Preferences.H>
Fl_Preferences pref(Fl_Preferences::USER,"foo","bar");
void printPreferences(void) { int i, j, k, v, d; char line[90];
line[0] = '\0';
for (i=0;i<pref.groups();i++) { Fl_Preferences group(pref,pref.group(i)); sprintf(line,"%s:", pref.group(i)); for (j=0, k=0;j<group.entries();j++, k++) { d = group.get(group.entry(j),v,0); if (k<5) { sprintf ( line, "%s %s=%03d[%c]", line, group.entry(j), v, (d) ? 'v' : 'd' ); } else { k = 0; printf("%s\n",line); sprintf ( line, " %s=%03d[%c]", group.entry(j), v, (d) ? 'v' : 'd' ); } } printf("%s\n",line); } printf("\n"); }
int main(int argc, char *argv[]) { int i, j;
printf("\n");
printf("Adding some groups with entries:\n\n"); for (i=0;i<5;i++) { Fl_Preferences group(pref,Fl_Preferences::Name("Group_%c",i+65)); for (j=0;j<5;j++) { group.set(Fl_Preferences::Name("i_%02d",j),(i+1)*(j+1)); } } printPreferences();
printf ( "Removing the first group:\n" "(Only Group_E should be removed)\n\n" ); pref.deleteGroup(pref.group(0)); printPreferences();
printf ( "Removing the second of the groups remained:\n" "(Only Group_B should be removed)\n\n" ); pref.deleteGroup(pref.group(2)); printPreferences();
fflush(stdout); return 0; }
>>>>>>>>>>>>>> TEST CODE END HERE <<<<<<<<<<<<<<<<<<<<<<<
And here is the patch:
*** fltk-1.1.3/src/Fl_Preferences_BUG.cxx Thu Jan 30 22:42:30 2003 --- fltk-1.1.3/src/Fl_Preferences.cxx Sun Apr 13 14:56:58 2003 *************** *** 1097,1103 **** if ( parent_ ) { nd = parent_->child_; np = 0L; ! for ( ; nd; nd = nd->next_ ) { if ( nd == this ) { --- 1097,1103 ---- if ( parent_ ) { nd = parent_->child_; np = 0L; ! for ( ; nd; np = nd, nd = nd->next_ ) { if ( nd == this ) {
| |
|
#2 | mike 13:27 May 04, 2003 |
| Fixed in CVS for 1.1.4. | |
[ Return to Bugs & Features ]
|
| |