shotwell: fix build with vala 0.54

This commit is contained in:
Michal Vasilek 2021-12-19 14:23:18 +01:00 committed by Enno Boland
parent 08933c3545
commit 5a8fc3ac4f
No known key found for this signature in database
GPG key ID: 5A7B9F1D0DFEB55D

View file

@ -0,0 +1,368 @@
From 9a9876e27076f5939525023eb8c7f24d48c8ff25 Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Sun, 14 Mar 2021 11:21:10 +0100
Subject: [PATCH 1/6] vapis: Plug memory leak in GPhoto2
Caller was supposed to free the StorageInfo, which with the old binding
we never did
---
src/camera/GPhoto.vala | 5 +++--
src/camera/ImportPage.vala | 14 ++++++--------
vapi/libgphoto2.vapi | 2 +-
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/camera/GPhoto.vala b/src/camera/GPhoto.vala
index aa2fcf2b..64ff7ca0 100644
--- a/src/camera/GPhoto.vala
+++ b/src/camera/GPhoto.vala
@@ -135,9 +135,10 @@ namespace GPhoto {
// filesystem. In these cases shotwell can access the file directly. See:
// https://bugzilla.gnome.org/show_bug.cgi?id=716915
public PhotoMetadata? get_fallback_metadata(Camera camera, Context context, string folder, string filename) {
- GPhoto.CameraStorageInformation *sifs = null;
+ // Fixme: Why do we need to query get_storageinfo here first?
+ GPhoto.CameraStorageInformation[] sifs = null;
int count = 0;
- camera.get_storageinfo(&sifs, out count, context);
+ camera.get_storageinfo(out sifs, context);
GPhoto.PortInfo port_info;
camera.get_port_info(out port_info);
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index ab24df61..c424de88 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -1179,9 +1179,9 @@ public class ImportPage : CheckerboardPage {
Gee.ArrayList<ImportSource> import_list = new Gee.ArrayList<ImportSource>();
- GPhoto.CameraStorageInformation *sifs = null;
+ GPhoto.CameraStorageInformation[] sifs = null;
int count = 0;
- refresh_result = dcamera.gcamera.get_storageinfo(&sifs, out count, spin_idle_context.context);
+ refresh_result = dcamera.gcamera.get_storageinfo(out sifs, spin_idle_context.context);
if (refresh_result == GPhoto.Result.OK) {
for (int fsid = 0; fsid < count; fsid++) {
// Check well-known video and image paths first to prevent accidental
@@ -1324,18 +1324,16 @@ public class ImportPage : CheckerboardPage {
// Need to do this because some phones (iPhone, in particular) changes the name of their filesystem
// between each mount
public static string? get_fs_basedir(GPhoto.Camera camera, int fsid) {
- GPhoto.CameraStorageInformation *sifs = null;
+ GPhoto.CameraStorageInformation[] sifs = null;
int count = 0;
- GPhoto.Result res = camera.get_storageinfo(&sifs, out count, null_context.context);
+ GPhoto.Result res = camera.get_storageinfo(out sifs, null_context.context);
if (res != GPhoto.Result.OK)
return null;
- if (fsid >= count)
+ if (fsid >= sifs.length)
return null;
- GPhoto.CameraStorageInformation *ifs = sifs + fsid;
-
- return (ifs->fields & GPhoto.CameraStorageInfoFields.BASE) != 0 ? ifs->basedir : "/";
+ return (sifs[fsid].fields & GPhoto.CameraStorageInfoFields.BASE) != 0 ? sifs[fsid].basedir : "/";
}
public static string? get_fulldir(GPhoto.Camera camera, string camera_name, int fsid, string folder) {
diff --git a/vapi/libgphoto2.vapi b/vapi/libgphoto2.vapi
index 22f70eed..7e569823 100644
--- a/vapi/libgphoto2.vapi
+++ b/vapi/libgphoto2.vapi
@@ -64,7 +64,7 @@ namespace GPhoto {
public Result set_port_info(PortInfo info);
public Result get_abilities(out CameraAbilities abilities);
public Result set_abilities(CameraAbilities abilities);
- public Result get_storageinfo(CameraStorageInformation **sifs, out int count, Context context);
+ public Result get_storageinfo([CCode (array_length_pos=1)]out CameraStorageInformation[] sifs, Context context);
// Folders
[CCode (cname="gp_camera_folder_list_folders")]
--
2.31.1
From e1f53784dd7475388470a30683df34b5ca7784eb Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Sat, 13 Mar 2021 23:22:50 +0100
Subject: [PATCH 2/6] More GPhoto2 vapi fixes
---
vapi/libgphoto2.vapi | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/vapi/libgphoto2.vapi b/vapi/libgphoto2.vapi
index 7e569823..607a644f 100644
--- a/vapi/libgphoto2.vapi
+++ b/vapi/libgphoto2.vapi
@@ -53,7 +53,7 @@ namespace GPhoto {
ref_function="GPHOTO_REF_CAMERA",
unref_function="gp_camera_unref",
free_function="gp_camera_free",
- cheader_filename="gphoto2/gphoto2-camera.h,gphoto.h"
+ cheader_filename="gphoto2/gphoto2-camera.h,gphoto2.h"
)]
public class Camera {
[CCode (cname="gp_camera_new")]
@@ -74,7 +74,7 @@ namespace GPhoto {
[CCode (cname="gp_camera_folder_delete_all")]
public Result delete_all_files(string folder, Context context);
[CCode (cname="gp_camera_folder_put_file")]
- public Result put_file(string folder, CameraFile file, Context context);
+ public Result put_file(string folder, string filename, CameraFileType type, CameraFile file, Context context);
[CCode (cname="gp_camera_folder_make_dir")]
public Result make_dir(string folder, string name, Context context);
[CCode (cname="gp_camera_folder_remove_dir")]
@@ -99,7 +99,7 @@ namespace GPhoto {
ref_function="GPHOTO_REF_FILE",
unref_function="gp_file_unref",
free_function="gp_file_free",
- cheader_filename="gphoto2/gphoto2-file.h,gphoto.h"
+ cheader_filename="gphoto2/gphoto2-file.h,gphoto2.h"
)]
public class CameraFile {
[CCode (cname="gp_file_new")]
@@ -140,7 +140,6 @@ namespace GPhoto {
public enum CameraFileInfoFields {
NONE,
TYPE,
- NAME,
SIZE,
WIDTH,
HEIGHT,
@@ -159,7 +158,7 @@ namespace GPhoto {
public CameraFileInfoFields fields;
public CameraFileStatus status;
public ulong size;
- public string type;
+ public char type[64];
public uint width;
public uint height;
public string name;
@@ -176,7 +175,7 @@ namespace GPhoto {
public CameraFileInfoFields fields;
public CameraFileStatus status;
public ulong size;
- public string type;
+ public char type[64];
public uint width;
public uint height;
public string name;
@@ -257,7 +256,7 @@ namespace GPhoto {
ref_function="GPHOTO_REF_LIST",
unref_function="gp_list_unref",
free_function="gp_list_free",
- cheader_filename="gphoto2/gphoto2-list.h,gphoto.h"
+ cheader_filename="gphoto2/gphoto2-list.h,gphoto2.h"
)]
public class CameraList {
[CCode (cname="gp_list_new")]
@@ -266,7 +265,7 @@ namespace GPhoto {
public Result append(string name, string value);
public Result reset();
public Result sort();
- public Result find_by_name(out int? index, string name);
+ public Result find_by_name(out int index, string name);
public Result get_name(int index, out unowned string name);
public Result get_value(int index, out unowned string value);
public Result set_name(int index, string name);
@@ -314,9 +313,9 @@ namespace GPhoto {
)]
public struct CameraStorageInformation {
public CameraStorageInfoFields fields;
- public string basedir;
- public string label;
- public string description;
+ public char basedir[256];
+ public char label[256];
+ public char description[256];
public int type;
public int fstype;
public int access;
@@ -329,7 +328,7 @@ namespace GPhoto {
[CCode (
ref_function="GPHOTO_REF_CONTEXT",
unref_function="gp_context_unref",
- cheader_filename="gphoto2/gphoto2-context.h,gphoto.h"
+ cheader_filename="gphoto2/gphoto2-context.h,gphoto2.h"
)]
public class Context {
[CCode (cname="gp_context_new")]
@@ -485,7 +484,7 @@ namespace GPhoto {
[CCode (
cheader_filename="gphoto2/gphoto2-version.h",
- cprefix="GP_VERSION"
+ cprefix="GP_VERSION_"
)]
public enum VersionVerbosity {
SHORT,
--
2.31.1
From 754520638beafa997d81fdbff58a9d07a48f7cfd Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Sat, 13 Mar 2021 22:31:32 +0100
Subject: [PATCH 3/6] vapis: Fix gphoto2 vapi
There was some copy-paste going on there that didn't actually match the
C structs
---
vapi/libgphoto2.vapi | 4 ----
1 file changed, 4 deletions(-)
diff --git a/vapi/libgphoto2.vapi b/vapi/libgphoto2.vapi
index 607a644f..adcef5c5 100644
--- a/vapi/libgphoto2.vapi
+++ b/vapi/libgphoto2.vapi
@@ -161,7 +161,6 @@ namespace GPhoto {
public char type[64];
public uint width;
public uint height;
- public string name;
public CameraFilePermissions permissions;
public time_t mtime;
}
@@ -178,9 +177,6 @@ namespace GPhoto {
public char type[64];
public uint width;
public uint height;
- public string name;
- public CameraFilePermissions permissions;
- public time_t mtime;
}
[CCode (
--
2.31.1
From f7d044e7a72b80a550fd1907a2d56053caab1ae3 Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Sat, 13 Mar 2021 22:32:17 +0100
Subject: [PATCH 4/6] Fix strings in [SimpleType] structs
---
src/camera/ImportPage.vala | 5 +++--
vapi/libraw.vapi | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index c424de88..f5e98955 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -1408,12 +1408,13 @@ public class ImportPage : CheckerboardPage {
import_list.add(video_source);
} else {
// determine file format from type, and then from file extension
- PhotoFileFormat file_format = PhotoFileFormat.from_gphoto_type(info.file.type);
+ string file_type = (string)info.file.type;
+ PhotoFileFormat file_format = PhotoFileFormat.from_gphoto_type(file_type);
if (file_format == PhotoFileFormat.UNKNOWN) {
file_format = PhotoFileFormat.get_by_basename_extension(filename);
if (file_format == PhotoFileFormat.UNKNOWN) {
message("Skipping %s/%s: Not a supported file extension (%s)", fulldir,
- filename, info.file.type);
+ filename, file_type);
continue;
}
diff --git a/vapi/libraw.vapi b/vapi/libraw.vapi
index b1b5875b..146f447e 100644
--- a/vapi/libraw.vapi
+++ b/vapi/libraw.vapi
@@ -248,7 +248,7 @@ public struct Thumbnail {
public uint tlength;
public int tcolors;
[CCode (array_length_cname="tlength")]
- public uint8[] thumb;
+ public unowned uint8[] thumb;
}
[CCode (cname="enum LibRaw_thumbnail_formats", cprefix="LIBRAW_THUMBNAIL_")]
--
2.31.1
From a035ff6ee39dc47c6051f7b29c7da83d3ecde52e Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Sun, 14 Mar 2021 11:21:10 +0100
Subject: [PATCH 5/6] Fix compile error after GPhoto vapi change
---
src/camera/ImportPage.vala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index f5e98955..7dbe9d42 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -1333,7 +1333,7 @@ public class ImportPage : CheckerboardPage {
if (fsid >= sifs.length)
return null;
- return (sifs[fsid].fields & GPhoto.CameraStorageInfoFields.BASE) != 0 ? sifs[fsid].basedir : "/";
+ return (GPhoto.CameraStorageInfoFields.BASE in sifs[fsid].fields) ? (string) sifs[fsid].basedir : "/";
}
public static string? get_fulldir(GPhoto.Camera camera, string camera_name, int fsid, string folder) {
--
2.31.1
From 44dae743da462742f1acdeb599f0a10afa43e629 Mon Sep 17 00:00:00 2001
From: Jens Georg <mail@jensge.org>
Date: Sun, 14 Mar 2021 12:22:55 +0100
Subject: [PATCH 6/6] Fix and clarify the helper header for GPhoto
---
vapi/libgphoto2.vapi | 8 ++++----
vapi/{gphoto.h => shotwell-gphoto-helper.h} | 0
2 files changed, 4 insertions(+), 4 deletions(-)
rename vapi/{gphoto.h => shotwell-gphoto-helper.h} (100%)
diff --git a/vapi/libgphoto2.vapi b/vapi/libgphoto2.vapi
index adcef5c5..aeab7255 100644
--- a/vapi/libgphoto2.vapi
+++ b/vapi/libgphoto2.vapi
@@ -53,7 +53,7 @@ namespace GPhoto {
ref_function="GPHOTO_REF_CAMERA",
unref_function="gp_camera_unref",
free_function="gp_camera_free",
- cheader_filename="gphoto2/gphoto2-camera.h,gphoto2.h"
+ cheader_filename="gphoto2/gphoto2-camera.h,shotwell-gphoto-helper.h"
)]
public class Camera {
[CCode (cname="gp_camera_new")]
@@ -99,7 +99,7 @@ namespace GPhoto {
ref_function="GPHOTO_REF_FILE",
unref_function="gp_file_unref",
free_function="gp_file_free",
- cheader_filename="gphoto2/gphoto2-file.h,gphoto2.h"
+ cheader_filename="gphoto2/gphoto2-file.h,shotwell-gphoto-helper.h"
)]
public class CameraFile {
[CCode (cname="gp_file_new")]
@@ -252,7 +252,7 @@ namespace GPhoto {
ref_function="GPHOTO_REF_LIST",
unref_function="gp_list_unref",
free_function="gp_list_free",
- cheader_filename="gphoto2/gphoto2-list.h,gphoto2.h"
+ cheader_filename="gphoto2/gphoto2-list.h,shotwell-gphoto-helper.h"
)]
public class CameraList {
[CCode (cname="gp_list_new")]
@@ -324,7 +324,7 @@ namespace GPhoto {
[CCode (
ref_function="GPHOTO_REF_CONTEXT",
unref_function="gp_context_unref",
- cheader_filename="gphoto2/gphoto2-context.h,gphoto2.h"
+ cheader_filename="gphoto2/gphoto2-context.h,shotwell-gphoto-helper.h"
)]
public class Context {
[CCode (cname="gp_context_new")]
diff --git a/vapi/gphoto.h b/vapi/shotwell-gphoto-helper.h
similarity index 100%
rename from vapi/gphoto.h
rename to vapi/shotwell-gphoto-helper.h
--
2.31.1