]> granicus.if.org Git - graphviz/commitdiff
Only rely on obj->id if set; if it is needed, it is set.
authorerg <devnull@localhost>
Thu, 4 Nov 2010 01:09:16 +0000 (01:09 +0000)
committererg <devnull@localhost>
Thu, 4 Nov 2010 01:09:16 +0000 (01:09 +0000)
lib/common/emit.c

index b7cb931642e0db829bef67437935a45725225c38..a72f0b4a69691c57013b89dba3e56eb1099dc71c 100644 (file)
@@ -2117,23 +2117,46 @@ emit_edge_label(GVJ_t* job, textlabel_t* lbl, emit_state_t lkind, int explicit,
 {
     int flags = job->flags;
     emit_state_t old_emit_state;
+    char* newid;
+    char* type;
 
     if (lbl == NULL) return;
+    if (id) { /* non-NULL if needed */
+       newid = N_NEW(strlen(id) + sizeof("-headlabel"),char);
+       switch (lkind) {
+       case EMIT_ELABEL :
+           type = "label";
+           break;
+       case EMIT_HLABEL :
+           type = "headlabel";
+           break;
+       case EMIT_TLABEL :
+           type = "taillabel";
+           break;
+       default :
+           assert (0);
+           break;
+       }
+       sprintf (newid, "%s-%s", id, type);
+    }
+    else
+       newid = NULL;
     old_emit_state = job->obj->emit_state;
     job->obj->emit_state = lkind;
     if ((url || explicit) && !(flags & EMIT_CLUSTERS_LAST)) {
        map_label(job, lbl);
-       gvrender_begin_anchor(job, url, tooltip, target, id);
+       gvrender_begin_anchor(job, url, tooltip, target, newid);
     }
     emit_label(job, lkind, lbl);
     if (spl) emit_attachment(job, lbl, spl);
     if (url || explicit) {
        if (flags & EMIT_CLUSTERS_LAST) {
            map_label(job, lbl);
-           gvrender_begin_anchor(job, url, tooltip, target, id);
+           gvrender_begin_anchor(job, url, tooltip, target, newid);
        }
        gvrender_end_anchor(job);
     }
+    if (newid) free (newid);
     job->obj->emit_state = old_emit_state;
 }