Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
0444796b
Commit
0444796b
authored
16 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
fix copy constructor to set original object ptr on new object to allow deep copy.
parent
4746777c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/include/ZMap/zmapBase.h
+7
-4
7 additions, 4 deletions
src/include/ZMap/zmapBase.h
src/zmapFeature/zmapStyle.c
+3
-3
3 additions, 3 deletions
src/zmapFeature/zmapStyle.c
src/zmapUtils/zmapBase.c
+15
-9
15 additions, 9 deletions
src/zmapUtils/zmapBase.c
with
25 additions
and
16 deletions
src/include/ZMap/zmapBase.h
+
7
−
4
View file @
0444796b
...
...
@@ -27,9 +27,9 @@
*
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited:
Oct 24 11:48
2008 (edgrif)
* Last edited:
Nov 13 10:54
2008 (edgrif)
* Created: Thu Jun 12 12:09:39 2008 (rds)
* CVS info: $Id: zmapBase.h,v 1.
2
2008-1
0-29 16:01
:57 edgrif Exp $
* CVS info: $Id: zmapBase.h,v 1.
3
2008-1
1-13 11:32
:57 edgrif Exp $
*-------------------------------------------------------------------
*/
...
...
@@ -51,6 +51,11 @@
#define ZMAP_IS_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), ZMAP_TYPE_BASE))
#define ZMAP_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ZMAP_TYPE_BASE, zmapBaseClass))
/* Used as retrieval key for source object for object copy code. */
#define ZMAPBASECOPY_PARAMDATA_KEY "ZMap_Base_Copy_Key"
/*
* Main object structure
*/
...
...
@@ -72,8 +77,6 @@ typedef struct _zmapBaseClassStruct zmapBaseClass;
GType
zMapBaseGetType
(
void
);
#define ZMAPBASECOPY_PARAMDATA_KEY "ZMap_Base_Copy_Key"
ZMapBase
zMapBaseCopy
(
ZMapBase
src
);
gboolean
zMapBaseCCopy
(
ZMapBase
src
,
ZMapBase
*
dest_out
);
...
...
This diff is collapsed.
Click to expand it.
src/zmapFeature/zmapStyle.c
+
3
−
3
View file @
0444796b
...
...
@@ -28,9 +28,9 @@
*
* Exported functions: See ZMap/zmapStyle.h
* HISTORY:
* Last edited: Nov 1
2
1
6
:5
8
2008 (edgrif)
* Last edited: Nov 1
3
1
0
:5
7
2008 (edgrif)
* Created: Mon Feb 26 09:12:18 2007 (edgrif)
* CVS info: $Id: zmapStyle.c,v 1.1
8
2008-11-13 1
0:10
:5
9
edgrif Exp $
* CVS info: $Id: zmapStyle.c,v 1.1
9
2008-11-13 1
1:32
:5
7
edgrif Exp $
*-------------------------------------------------------------------
*/
...
...
@@ -2223,7 +2223,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
/* Try to retrieve the style to be copied, returns NULL if we have been called just to set
* values rather than copy. */
copy_style
=
g_
param_sp
ec_get_
q
data
(
psp
ec
,
g_quark_from_string
(
ZMAPBASECOPY_PARAMDATA_KEY
)
)
;
copy_style
=
g_
obj
ec
t
_get_data
(
gobj
ec
t
,
ZMAPBASECOPY_PARAMDATA_KEY
)
;
switch
(
param_id
)
{
...
...
This diff is collapsed.
Click to expand it.
src/zmapUtils/zmapBase.c
+
15
−
9
View file @
0444796b
...
...
@@ -27,9 +27,9 @@
*
* Exported functions: See ZMap/zmapBase.h
* HISTORY:
* Last edited: Nov
4
1
2
:5
3
2008 (
rds
)
* Last edited: Nov
13
1
0
:5
6
2008 (
edgrif
)
* Created: Thu Jun 12 12:02:12 2008 (rds)
* CVS info: $Id: zmapBase.c,v 1.
4
2008-11-
05 12:20:20 rds
Exp $
* CVS info: $Id: zmapBase.c,v 1.
5
2008-11-
13 11:32:57 edgrif
Exp $
*-------------------------------------------------------------------
*/
...
...
@@ -292,18 +292,23 @@ static void zmapBaseCopyConstructor(const GValue *src_value, GValue *dest_value)
GType
gobject_type
;
guint
count
=
0
,
i
;
/* Create the object which will the new copy. */
gobject_type
=
G_OBJECT_TYPE
(
gobject_src
);
gobject_dest
=
g_object_new
(
gobject_type
,
NULL
);
/* Now copy all the original objects data, works by calling get_property on original
* object and then set_property on new object. */
param_specs
=
g_object_class_list_properties
(
gobject_class
,
&
count
);
ps_ptr
=
param_specs
;
for
(
i
=
0
;
param_specs
&&
i
<
count
;
i
++
,
param_specs
++
)
for
(
i
=
0
;
param_specs
&&
i
<
count
;
i
++
,
param_specs
++
)
{
GParamSpec
*
current
=
*
param_specs
,
*
redirect
;
GType
current_type
=
G_PARAM_SPEC_VALUE_TYPE
(
current
);
#ifdef COPY_CONSTRUCT_DEBUG
const
char
*
name
=
g_param_spec_get_name
(
current
);
#endif
/* COPY_CONSTRUCT_DEBUG */
/* Access to this is the _only_ problem here, according to docs it's not public.
* It does save g_object_get and allows us to use the object methods directly.
* Also the copy_set_property method can have the same signature as get/set_prop */
...
...
@@ -324,16 +329,17 @@ static void zmapBaseCopyConstructor(const GValue *src_value, GValue *dest_value)
gobject_class
->
get_property
(
gobject_src
,
param_id
,
&
value
,
current
);
/* Store a pointer to th
is
object on the
param sp
ec so it can be retrieved in the
* objects copy code
, need to do this
otherwise copy code cannot see original object ! */
g_
param_sp
ec_set_
q
data
(
current
,
g_quark_from_string
(
ZMAPBASECOPY_PARAMDATA_KEY
)
,
gobject_src
)
;
/* Store a pointer to th
e original
object on the
new obj
ec
t
so it can be retrieved in the
*
new
objects copy code otherwise copy code cannot see original object ! */
g_
obj
ec
t
_set_data
(
gobject_dest
,
ZMAPBASECOPY_PARAMDATA_KEY
,
gobject_src
)
;
/* do the copy... */
zmap_class
->
copy_set_property
(
gobject_dest
,
param_id
,
&
value
,
current
);
/* Now remove it, V. IMPORTANT because "set-property" routine gets called during copy
* but MUST be able to tell difference between a "set" call and a "copy" call. */
g_param_spec_set_qdata
(
current
,
g_quark_from_string
(
ZMAPBASECOPY_PARAMDATA_KEY
),
NULL
)
;
/* Now remove the pointer, V. IMPORTANT because "set-property" routine gets called
* both to set properties per se and during object copy and set routine decides
* which is which by whether pointer is NULL. */
g_object_set_data
(
gobject_dest
,
ZMAPBASECOPY_PARAMDATA_KEY
,
NULL
)
;
g_value_unset
(
&
value
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment