Fix file dialog memory leak

This commit is contained in:
David 2024-08-09 21:41:18 +02:00 committed by david-swift
parent 574aca245a
commit c6d0fa5080
22 changed files with 34 additions and 3 deletions

View File

@ -46,8 +46,8 @@ jobs:
- name: Modify Docs - name: Modify Docs
run: | run: |
echo "<script>window.location.href += \"/documentation/adwaita\"</script>" > docs/index.html; echo "<script>window.location.href += \"/documentation/adwaita\"</script>" > docs/index.html;
sed -i '' 's/#06f/#ea3358/g' docs/css/documentation-topic~topic~tutorials-overview.d6f5411c.css sed -i '' 's/#06f/#ea3358/g' docs/css/documentation-topic~topic~tutorials-overview.*.css
sed -i '' 's/,2px/,10px/g' docs/css/index.038e887c.css sed -i '' 's/,2px/,10px/g' docs/css/index.*.css
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-pages-artifact@v3 uses: actions/upload-pages-artifact@v3
with: with:

View File

@ -164,3 +164,4 @@ type_contents_order:
excluded: excluded:
- Sources/Adwaita/View/Generated/ - Sources/Adwaita/View/Generated/
- Sources/Adwaita/Adwaita.docc/ - Sources/Adwaita/Adwaita.docc/
- .build/

View File

@ -112,6 +112,7 @@ public struct Binding<Value> {
} }
/// An extension
extension Binding where Value: MutableCollection { extension Binding where Value: MutableCollection {
/// Get a child at a certain index of the array as a binding. /// Get a child at a certain index of the array as a binding.
@ -134,6 +135,7 @@ extension Binding where Value: MutableCollection {
} }
/// An extension
extension Binding where Value: MutableCollection, Value.Element: Identifiable { extension Binding where Value: MutableCollection, Value.Element: Identifiable {
/// Get a child of the array with a certain id as a binding. /// Get a child of the array with a certain id as a binding.

View File

@ -185,6 +185,7 @@ public struct State<Value>: StateProtocol {
} }
/// An extension
extension State where Value: Codable { extension State where Value: Codable {
/// Initialize a property representing a state in the view. /// Initialize a property representing a state in the view.

View File

@ -7,6 +7,7 @@
import Foundation import Foundation
// An extension
extension Array: View where Element == View { extension Array: View where Element == View {
/// The array's view body is the array itself. /// The array's view body is the array itself.
@ -46,6 +47,7 @@ extension Array: View where Element == View {
} }
// An extension
extension Array where Element == WindowSceneGroup { extension Array where Element == WindowSceneGroup {
/// Get the content of an array of window scene groups. /// Get the content of an array of window scene groups.
@ -56,6 +58,7 @@ extension Array where Element == WindowSceneGroup {
} }
// An extension
extension Array where Element == String { extension Array where Element == String {
/// Get the C version of the array. /// Get the C version of the array.
@ -78,6 +81,7 @@ extension Array where Element == String {
} }
// An extension
extension Array { extension Array {
/// Accesses the element at the specified position safely. /// Accesses the element at the specified position safely.
@ -105,6 +109,7 @@ extension Array {
} }
// An extension
extension Array where Element: Identifiable { extension Array where Element: Identifiable {
/// Accesses the element with a certain id safely. /// Accesses the element with a certain id safely.

View File

@ -5,6 +5,7 @@
// Created by david-swift on 15.01.24. // Created by david-swift on 15.01.24.
// //
// An extension
extension Bool { extension Bool {
/// Get the gboolean for C. /// Get the gboolean for C.

View File

@ -5,6 +5,7 @@
// Created by david-swift on 15.01.24. // Created by david-swift on 15.01.24.
// //
// An extension
extension Int: Identifiable { extension Int: Identifiable {
/// Get the integer itself as the identifier. /// Get the integer itself as the identifier.

View File

@ -5,6 +5,7 @@
// Created by david-swift on 15.01.23. // Created by david-swift on 15.01.23.
// //
// An extension
extension OpaquePointer { extension OpaquePointer {
/// Convert an opaque pointer into an unsafe mutable pointer with a defined type. /// Convert an opaque pointer into an unsafe mutable pointer with a defined type.

View File

@ -5,6 +5,7 @@
// Created by david-swift on 21.01.24. // Created by david-swift on 21.01.24.
// //
// An extension
extension Set where Element == Edge { extension Set where Element == Edge {
/// Horizontal and vertical edges. /// Horizontal and vertical edges.

View File

@ -5,6 +5,7 @@
// Created by david-swift on 09.09.23. // Created by david-swift on 09.09.23.
// //
// An extension
extension String { extension String {
/// A label for main content in a view storage. /// A label for main content in a view storage.

View File

@ -5,6 +5,7 @@
// Created by david-swift on 19.01.24. // Created by david-swift on 19.01.24.
// //
// An extension
extension UInt { extension UInt {
/// Convert an unsigned integer into the C form. /// Convert an unsigned integer into the C form.

View File

@ -5,6 +5,7 @@
// Created by david-swift on 15.01.24. // Created by david-swift on 15.01.24.
// //
// An extension
extension UnsafeMutablePointer { extension UnsafeMutablePointer {
/// Convert into an opaque pointer. /// Convert into an opaque pointer.

View File

@ -5,6 +5,7 @@
// Created by david-swift on 15.01.24. // Created by david-swift on 15.01.24.
// //
// An extension
extension UnsafeMutableRawPointer { extension UnsafeMutableRawPointer {
/// Convert into an unsafe mutable pointer of a certain type. /// Convert into an unsafe mutable pointer of a certain type.

View File

@ -38,6 +38,7 @@ public protocol App {
} }
/// An extension
extension App { extension App {
/// The application's entry point. /// The application's entry point.

View File

@ -19,6 +19,7 @@ public protocol MenuItem: MenuItemGroup {
} }
/// An extension
extension MenuItem { extension MenuItem {
/// The menu item's content is itself. /// The menu item's content is itself.

View File

@ -15,6 +15,7 @@ public protocol MenuItemGroup {
} }
/// An extension
extension MenuItemGroup { extension MenuItemGroup {
/// Add the menu items described by the group to a menu. /// Add the menu items described by the group to a menu.

View File

@ -25,6 +25,7 @@ public protocol View {
} }
/// An extension
extension View { extension View {
/// Wrap the view into a widget. /// Wrap the view into a widget.
@ -54,6 +55,8 @@ extension View {
} }
} }
/// Get the state.
/// - Returns: The state.
func getState() -> [String: StateProtocol] { func getState() -> [String: StateProtocol] {
var state: [String: StateProtocol] = [:] var state: [String: StateProtocol] = [:]
for property in Mirror(reflecting: self).children { for property in Mirror(reflecting: self).children {
@ -71,6 +74,9 @@ extension View {
widget(modifiers: modifiers).container(modifiers: modifiers) widget(modifiers: modifiers).container(modifiers: modifiers)
} }
/// Get the modified view.
/// - Parameter modifiers: The modifiers.
/// - Returns: The modified view.
func getModified(modifiers: [(View) -> View]) -> View { func getModified(modifiers: [(View) -> View]) -> View {
var modified: View = self var modified: View = self
for modifier in modifiers { for modifier in modifiers {

View File

@ -20,6 +20,7 @@ public protocol Widget: View {
} }
/// An extension
extension Widget { extension Widget {
/// A widget's view is empty. /// A widget's view is empty.

View File

@ -29,6 +29,7 @@ public protocol WindowScene: WindowSceneGroup {
} }
/// An extension
extension WindowScene { extension WindowScene {
/// The window scene's body is itself. /// The window scene's body is itself.

View File

@ -13,6 +13,7 @@ public protocol WindowSceneGroup {
} }
/// An extension
extension WindowSceneGroup { extension WindowSceneGroup {
/// Get the windows described by the group. /// Get the windows described by the group.

View File

@ -7,6 +7,7 @@
import CAdw import CAdw
// An extension
extension Menu { extension Menu {
// swiftlint:disable function_default_parameter_at_end // swiftlint:disable function_default_parameter_at_end

View File

@ -27,7 +27,8 @@ static void
gtui_filedialog_open_finish (uint64_t dialog, uint64_t result, uint64_t data) gtui_filedialog_open_finish (uint64_t dialog, uint64_t result, uint64_t data)
{ {
GFile *file = gtk_file_dialog_open_finish (dialog, result, NULL); GFile *file = gtk_file_dialog_open_finish (dialog, result, NULL);
const char *path = g_file_get_path (file); const char *path = g_file_peek_path (file);
g_object_unref (file);
filedialog_on_open_cb (dialog, path, data); filedialog_on_open_cb (dialog, path, data);
} }