+ // if file name is invalid: first try in xoj file's directory
+ if (!valid && tmpBg_pdf->file_domain != DOMAIN_ATTACH) {
+ p = g_path_get_dirname(filename);
+ q = g_path_get_basename(tmpfn);
+ tmpfn2 = g_strdup_printf("%s/%s", p, q);
+ g_free(p); g_free(q);
+ valid = init_bgpdf(tmpfn2, FALSE, tmpBg_pdf->file_domain);
+ if (valid) { // change the file name...
+ printf("substituting %s -> %s\n", tmpfn, tmpfn2);
+ g_free(tmpBg_pdf->filename->s);
+ tmpBg_pdf->filename->s = tmpfn2;
+ }
+ else g_free(tmpfn2);
+ }
+ // if file name is invalid: next prompt user