Skip to content

Commit

Permalink
Fix file dialog memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
David authored and david-swift committed Aug 9, 2024
1 parent 574aca2 commit c6d0fa5
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
- name: Modify Docs
run: |
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/,2px/,10px/g' docs/css/index.038e887c.css
sed -i '' 's/#06f/#ea3358/g' docs/css/documentation-topic~topic~tutorials-overview.*.css
sed -i '' 's/,2px/,10px/g' docs/css/index.*.css
- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,4 @@ type_contents_order:
excluded:
- Sources/Adwaita/View/Generated/
- Sources/Adwaita/Adwaita.docc/
- .build/
2 changes: 2 additions & 0 deletions Sources/Adwaita/Model/Data Flow/Binding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public struct Binding<Value> {

}

/// An extension
extension Binding where Value: MutableCollection {

/// Get a child at a certain index of the array as a binding.
Expand All @@ -134,6 +135,7 @@ extension Binding where Value: MutableCollection {

}

/// An extension
extension Binding where Value: MutableCollection, Value.Element: Identifiable {

/// Get a child of the array with a certain id as a binding.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/Data Flow/State.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public struct State<Value>: StateProtocol {

}

/// An extension
extension State where Value: Codable {

/// Initialize a property representing a state in the view.
Expand Down
5 changes: 5 additions & 0 deletions Sources/Adwaita/Model/Extensions/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation

// An extension
extension Array: View where Element == View {

Check failure on line 11 in Sources/Adwaita/Model/Extensions/Array.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// The array's view body is the array itself.
Expand Down Expand Up @@ -46,6 +47,7 @@ extension Array: View where Element == View {

}

// An extension
extension Array where Element == WindowSceneGroup {

Check failure on line 51 in Sources/Adwaita/Model/Extensions/Array.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Get the content of an array of window scene groups.
Expand All @@ -56,6 +58,7 @@ extension Array where Element == WindowSceneGroup {

}

// An extension
extension Array where Element == String {

Check failure on line 62 in Sources/Adwaita/Model/Extensions/Array.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Get the C version of the array.
Expand All @@ -78,6 +81,7 @@ extension Array where Element == String {

}

// An extension
extension Array {

Check failure on line 85 in Sources/Adwaita/Model/Extensions/Array.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Accesses the element at the specified position safely.
Expand Down Expand Up @@ -105,6 +109,7 @@ extension Array {

}

// An extension
extension Array where Element: Identifiable {

Check failure on line 113 in Sources/Adwaita/Model/Extensions/Array.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Accesses the element with a certain id safely.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/Extensions/Bool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by david-swift on 15.01.24.
//

// An extension
extension Bool {

Check failure on line 9 in Sources/Adwaita/Model/Extensions/Bool.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Get the gboolean for C.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/Extensions/Int.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by david-swift on 15.01.24.
//

// An extension
extension Int: Identifiable {

Check failure on line 9 in Sources/Adwaita/Model/Extensions/Int.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Get the integer itself as the identifier.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/Extensions/OpaquePointer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by david-swift on 15.01.23.
//

// An extension
extension OpaquePointer {

Check failure on line 9 in Sources/Adwaita/Model/Extensions/OpaquePointer.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Convert an opaque pointer into an unsafe mutable pointer with a defined type.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/Extensions/Set.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by david-swift on 21.01.24.
//

// An extension
extension Set where Element == Edge {

Check failure on line 9 in Sources/Adwaita/Model/Extensions/Set.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Horizontal and vertical edges.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/Extensions/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by david-swift on 09.09.23.
//

// An extension
extension String {

/// A label for main content in a view storage.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/Extensions/UInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by david-swift on 19.01.24.
//

// An extension
extension UInt {

Check failure on line 9 in Sources/Adwaita/Model/Extensions/UInt.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Missing Docs Violation: internal declarations should be documented (missing_docs)

/// Convert an unsigned integer into the C form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by david-swift on 15.01.24.
//

// An extension
extension UnsafeMutablePointer {

/// Convert into an opaque pointer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by david-swift on 15.01.24.
//

// An extension
extension UnsafeMutableRawPointer {

/// Convert into an unsafe mutable pointer of a certain type.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/User Interface/App/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public protocol App {

}

/// An extension
extension App {

/// The application's entry point.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/User Interface/Menu/MenuItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public protocol MenuItem: MenuItemGroup {

}

/// An extension
extension MenuItem {

/// The menu item's content is itself.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public protocol MenuItemGroup {

}

/// An extension
extension MenuItemGroup {

/// Add the menu items described by the group to a menu.
Expand Down
6 changes: 6 additions & 0 deletions Sources/Adwaita/Model/User Interface/View/View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public protocol View {

}

/// An extension
extension View {

/// Wrap the view into a widget.
Expand Down Expand Up @@ -54,6 +55,8 @@ extension View {
}
}

/// Get the state.
/// - Returns: The state.
func getState() -> [String: StateProtocol] {
var state: [String: StateProtocol] = [:]
for property in Mirror(reflecting: self).children {
Expand All @@ -71,6 +74,9 @@ extension View {
widget(modifiers: modifiers).container(modifiers: modifiers)
}

/// Get the modified view.
/// - Parameter modifiers: The modifiers.
/// - Returns: The modified view.
func getModified(modifiers: [(View) -> View]) -> View {
var modified: View = self
for modifier in modifiers {
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/Model/User Interface/View/Widget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public protocol Widget: View {

}

/// An extension
extension Widget {

/// A widget's view is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public protocol WindowScene: WindowSceneGroup {

}

/// An extension
extension WindowScene {

/// The window scene's body is itself.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public protocol WindowSceneGroup {

}

/// An extension
extension WindowSceneGroup {

/// Get the windows described by the group.
Expand Down
1 change: 1 addition & 0 deletions Sources/Adwaita/View/Menu+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import CAdw

// An extension
extension Menu {

// swiftlint:disable function_default_parameter_at_end
Expand Down
3 changes: 2 additions & 1 deletion Sources/CAdw/shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ static void
gtui_filedialog_open_finish (uint64_t dialog, uint64_t result, uint64_t data)
{
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);
}

Expand Down

0 comments on commit c6d0fa5

Please sign in to comment.