Skip to content

Commit 6ef049d

Browse files
committed
better compat handling
we could produce spurious compat warnings before
1 parent 1473c1d commit 6ef049d

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ started 8.6.0 16/8/17
44
- add composite to alpha menu
55
- add Image / Select / Fill
66
- add combine mode to indexed histogram
7+
- better compat handling
78

89
started 8.5.1 22/1/17
910
- fix a crash bug

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ AC_OUTPUT([
380380
share/nip2/compat/8.2/Makefile
381381
share/nip2/compat/8.3/Makefile
382382
share/nip2/compat/8.4/Makefile
383+
share/nip2/compat/8.5/Makefile
383384
src/BITMAPS/Makefile
384385
src/Makefile
385386
test/Makefile

src/workspace.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929

3030
/*
31+
#define DEBUG_VERBOSE
3132
#define DEBUG
3233
*/
3334

@@ -42,10 +43,10 @@ static GSList *workspace_needs_layout = NULL;
4243
void
4344
workspace_set_needs_layout( Workspace *ws, gboolean needs_layout )
4445
{
45-
#ifdef DEBUG
46+
#ifdef DEBUG_VERBOSE
4647
printf( "workspace_set_needs_layout: %p %s %d\n",
4748
ws, NN( IOBJECT( ws )->name ), needs_layout );
48-
#endif /*DEBUG*/
49+
#endif /*DEBUG_VERBOSE*/
4950

5051
if( !ws->needs_layout &&
5152
needs_layout &&
@@ -652,9 +653,9 @@ workspace_changed( iObject *iobject )
652653
Workspace *ws;
653654
Workspacegroup *wsg;
654655

655-
#ifdef DEBUG
656+
#ifdef DEBUG_VERBOSE
656657
printf( "workspace_changed: %s\n", NN( iobject->name ) );
657-
#endif /*DEBUG*/
658+
#endif /*DEBUG_VERBOSE*/
658659

659660
g_return_if_fail( iobject != NULL );
660661
g_return_if_fail( IS_WORKSPACE( iobject ) );
@@ -819,8 +820,8 @@ workspace_load( Model *model,
819820
IM_FREEF( xmlFree, txt );
820821
}
821822

822-
(void) get_iprop( xnode, "major", &ws->compat_major );
823-
(void) get_iprop( xnode, "minor", &ws->compat_minor );
823+
(void) get_iprop( xnode, "major", &ws->major );
824+
(void) get_iprop( xnode, "minor", &ws->minor );
824825

825826
if( !MODEL_CLASS( parent_class )->load( model, state, parent, xnode ) )
826827
return( FALSE );
@@ -859,11 +860,9 @@ workspace_save( Model *model, xmlNode *xnode )
859860
if( !set_sprop( xthis, "filename", FILEMODEL( wsg )->filename ) )
860861
return( NULL );
861862

862-
if( ws->compat_major ) {
863-
if( !set_iprop( xthis, "major", ws->compat_major ) ||
864-
!set_iprop( xthis, "minor", ws->compat_minor ) )
865-
return( NULL );
866-
}
863+
if( !set_iprop( xthis, "major", ws->major ) ||
864+
!set_iprop( xthis, "minor", ws->minor ) )
865+
return( NULL );
867866

868867
return( xthis );
869868
}
@@ -986,14 +985,8 @@ workspace_have_compat( int major, int minor, int *best_major, int *best_minor )
986985
void
987986
workspace_get_version( Workspace *ws, int *major, int *minor )
988987
{
989-
if( ws->compat_major ) {
990-
*major = ws->compat_major;
991-
*minor = ws->compat_minor;
992-
}
993-
else {
994-
*major = MAJOR_VERSION;
995-
*minor = MINOR_VERSION;
996-
}
988+
*major = ws->major;
989+
*minor = ws->minor;
997990
}
998991

999992
gboolean
@@ -1024,10 +1017,19 @@ workspace_load_compat( Workspace *ws, int major, int minor )
10241017
}
10251018
path_free2( path );
10261019

1020+
#ifdef DEBUG
1021+
printf( "workspace_load_compat: loaded %d.%d\n",
1022+
best_major, best_minor );
1023+
#endif /*DEBUG*/
1024+
10271025
ws->compat_major = best_major;
10281026
ws->compat_minor = best_minor;
10291027
}
10301028
else {
1029+
#ifdef DEBUG
1030+
printf( "workspace_load_compat: no compat necessary\n" );
1031+
#endif /*DEBUG*/
1032+
10311033
/* No compat defs necessary for this ws.
10321034
*/
10331035
ws->compat_major = 0;
@@ -1088,6 +1090,9 @@ workspace_init( Workspace *ws )
10881090
ws->errors = NULL;
10891091
ws->mode = WORKSPACE_MODE_REGULAR;
10901092

1093+
ws->major = MAJOR_VERSION;
1094+
ws->minor = MINOR_VERSION;
1095+
10911096
ws->compat_major = 0;
10921097
ws->compat_minor = 0;
10931098

src/workspace.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,16 @@ struct _Workspace {
6868
WorkspaceMode mode; /* Display mode */
6969
gboolean locked; /* WS has been locked */
7070

71-
/* Some versions (7.10 etc.) need special compat toolkits. 0 here for
72-
* no compat toolkits loaded.
71+
/* The nip2 version that made this workspace.
72+
*/
73+
int major;
74+
int minor;
75+
76+
/* We may load some compat definitions to support this workspace, if it
77+
* was written by an older version.
78+
*
79+
* The version number of the compat stuff we loaded. Zero for no compat
80+
* stuff loaded.
7381
*/
7482
int compat_major;
7583
int compat_minor;

0 commit comments

Comments
 (0)