Avoid creating extra ImageStores
authorThomas White <taw@physics.org>
Sun, 11 Mar 2018 15:56:56 +0000 (16:56 +0100)
committerThomas White <taw@physics.org>
Sun, 11 Mar 2018 15:57:17 +0000 (16:57 +0100)
src/frame.c
src/narrative_window.c
src/sc_editor.c
src/sc_editor.h
src/slide_window.c

index abdebe0..7099209 100644 (file)
@@ -505,6 +505,11 @@ void add_image_para(struct frame *fr, SCBlock *scblock, const char *filename,
        Paragraph *pnew;
        int wi, hi;
 
+       if ( is == NULL ) {
+               fprintf(stderr, "Adding image without ImageStore!\n");
+               return;
+       }
+
        pnew = create_paragraph(fr);
        if ( pnew == NULL ) {
                fprintf(stderr, "Failed to add image paragraph\n");
index 968ea5c..3bd066f 100644 (file)
@@ -820,6 +820,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp
        sc_callback_list_add_callback(cbl, "sthumb", create_thumbnail,
                                      render_thumbnail, click_thumbnail, p);
        sc_editor_set_callbacks(nw->sceditor, cbl);
+       sc_editor_set_imagestore(nw->sceditor, p->is);
 
        toolbar = gtk_toolbar_new();
        gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
index cec0186..3972f02 100644 (file)
@@ -2041,6 +2041,15 @@ void sc_editor_set_scale(SCEditor *e, int scale)
 }
 
 
+void sc_editor_set_imagestore(SCEditor *e, ImageStore *is)
+{
+       if ( e->is != NULL ) {
+               fprintf(stderr, "WARNING: Changing imagestore\n");
+       }
+       e->is = is;
+}
+
+
 SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets,
                         PangoLanguage *lang, const char *storename)
 {
@@ -2057,7 +2066,7 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets,
        sceditor->log_h = 100;
        sceditor->border_offs_x = 0;
        sceditor->border_offs_y = 0;
-       sceditor->is = imagestore_new(storename);
+       sceditor->is = NULL;
        sceditor->slidenum = 0;
        sceditor->min_border = 0.0;
        sceditor->top_editable = 0;
index ea5b8f8..cef61d2 100644 (file)
@@ -193,6 +193,7 @@ extern void sc_editor_delete_selected_frame(SCEditor *e);
 extern void sc_editor_remove_cursor(SCEditor *e);
 extern SCBlock *split_paragraph_at_cursor(SCEditor *e);
 
+extern void sc_editor_set_imagestore(SCEditor *e, ImageStore *is);
 extern void sc_editor_set_para_highlight(SCEditor *e, int para_highlight);
 extern int sc_editor_get_cursor_para(SCEditor *e);
 extern void *sc_editor_get_cursor_bvp(SCEditor *e);
index 8e9918b..e6d0970 100644 (file)
@@ -254,6 +254,7 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks,
                                     colloquium_get_imagestore(app));
        sc_editor_set_slidenum(sw->sceditor, slide_number(sw->p, scblocks));
        sc_editor_set_scale(sw->sceditor, 1);
+       sc_editor_set_imagestore(sw->sceditor, p->is);
 
 //     scroll = gtk_scrolled_window_new(NULL, NULL);
 //     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),