mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 08:38:12 +08:00
Remove GRAPHITE_DOCUMENT_VERSION
This commit is contained in:
@@ -81,7 +81,6 @@ pub const DEFAULT_FONT_FAMILY: &str = "Cabin";
|
||||
pub const DEFAULT_FONT_STYLE: &str = "Normal (400)";
|
||||
|
||||
// Document
|
||||
pub const GRAPHITE_DOCUMENT_VERSION: &str = "0.1.2"; // Remember to update the demo artwork in /demos with both this version number and the contents so it remains editable
|
||||
pub const DEFAULT_DOCUMENT_NAME: &str = "Untitled Document";
|
||||
pub const FILE_SAVE_SUFFIX: &str = ".graphite";
|
||||
pub const MAX_UNDO_HISTORY_LEN: usize = 100; // TODO: Add this to user preferences
|
||||
|
||||
@@ -450,9 +450,8 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// If this test is failing take a look at `GRAPHITE_DOCUMENT_VERSION` in `editor/src/consts.rs`, it may need to be updated.
|
||||
/// This test will fail when you make changes to the underlying serialization format for a document.
|
||||
fn check_if_graphite_file_version_upgrade_is_needed() {
|
||||
fn check_if_demo_art_opens() {
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
|
||||
let print_problem_to_terminal_on_failure = |value: &String| {
|
||||
@@ -460,10 +459,6 @@ mod test {
|
||||
println!("-------------------------------------------------");
|
||||
println!("Failed test due to receiving a DisplayDialogError while loading a Graphite demo file.");
|
||||
println!();
|
||||
println!("That probably means the document serialization format changed. In that case, you need to bump the constant value");
|
||||
println!("`GRAPHITE_DOCUMENT_VERSION` in `editor/src/consts.rs`, then update the documents in `/demo-artwork` by editing");
|
||||
println!("their JSON to ensure they remain compatible with both the bumped version number and the serialization format changes.");
|
||||
println!();
|
||||
println!("DisplayDialogError details:");
|
||||
println!();
|
||||
println!("Description: {value}");
|
||||
|
||||
@@ -85,7 +85,6 @@ pub enum FrontendMessage {
|
||||
TriggerIndexedDbWriteDocument {
|
||||
document: String,
|
||||
details: FrontendDocumentDetails,
|
||||
version: String,
|
||||
},
|
||||
TriggerLoadAutoSaveDocuments,
|
||||
TriggerLoadPreferences,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::utility_types::error::EditorError;
|
||||
use super::utility_types::misc::{SnappingOptions, SnappingState};
|
||||
use crate::application::{generate_uuid, GRAPHITE_GIT_COMMIT_HASH};
|
||||
use crate::consts::{ASYMPTOTIC_EFFECT, DEFAULT_DOCUMENT_NAME, FILE_SAVE_SUFFIX, GRAPHITE_DOCUMENT_VERSION, SCALE_EFFECT, SCROLLBAR_SPACING};
|
||||
use crate::consts::{ASYMPTOTIC_EFFECT, DEFAULT_DOCUMENT_NAME, FILE_SAVE_SUFFIX, SCALE_EFFECT, SCROLLBAR_SPACING};
|
||||
use crate::messages::input_mapper::utility_types::macros::action_keys;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::NodeGraphHandlerData;
|
||||
@@ -50,8 +50,6 @@ pub struct DocumentMessageHandler {
|
||||
pub network: NodeNetwork,
|
||||
#[serde(default = "default_name")]
|
||||
pub name: String,
|
||||
#[serde(default = "default_version")]
|
||||
version: String,
|
||||
#[serde(default = "default_commit_hash")]
|
||||
commit_hash: String,
|
||||
#[serde(default = "default_pan_tilt_zoom")]
|
||||
@@ -105,7 +103,6 @@ impl Default for DocumentMessageHandler {
|
||||
// ============================================
|
||||
network: root_network(),
|
||||
name: DEFAULT_DOCUMENT_NAME.to_string(),
|
||||
version: GRAPHITE_DOCUMENT_VERSION.to_string(),
|
||||
commit_hash: GRAPHITE_GIT_COMMIT_HASH.to_string(),
|
||||
navigation: PTZ::default(),
|
||||
document_mode: DocumentMode::DesignMode,
|
||||
@@ -138,10 +135,6 @@ fn default_name() -> String {
|
||||
DocumentMessageHandler::default().name
|
||||
}
|
||||
#[inline(always)]
|
||||
fn default_version() -> String {
|
||||
DocumentMessageHandler::default().version
|
||||
}
|
||||
#[inline(always)]
|
||||
fn default_commit_hash() -> String {
|
||||
DocumentMessageHandler::default().commit_hash
|
||||
}
|
||||
@@ -879,17 +872,7 @@ impl DocumentMessageHandler {
|
||||
}
|
||||
|
||||
pub fn deserialize_document(serialized_content: &str) -> Result<Self, EditorError> {
|
||||
let deserialized_result: Result<Self, EditorError> = serde_json::from_str(serialized_content).map_err(|e| EditorError::DocumentDeserialization(e.to_string()));
|
||||
match deserialized_result {
|
||||
Ok(document) => {
|
||||
if document.version == GRAPHITE_DOCUMENT_VERSION {
|
||||
Ok(document)
|
||||
} else {
|
||||
Err(EditorError::DocumentDeserialization("Graphite document version mismatch".to_string()))
|
||||
}
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
serde_json::from_str(serialized_content).map_err(|e| EditorError::DocumentDeserialization(e.to_string()))
|
||||
}
|
||||
|
||||
pub fn with_name(name: String, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) -> Self {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::utility_types::PersistentData;
|
||||
use crate::application::generate_uuid;
|
||||
use crate::consts::{DEFAULT_DOCUMENT_NAME, GRAPHITE_DOCUMENT_VERSION};
|
||||
use crate::consts::DEFAULT_DOCUMENT_NAME;
|
||||
use crate::messages::dialog::simple_dialogs;
|
||||
use crate::messages::frontend::utility_types::FrontendDocumentDetails;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
@@ -90,7 +90,6 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||
id: document_id,
|
||||
name: document.name.clone(),
|
||||
},
|
||||
version: GRAPHITE_DOCUMENT_VERSION.to_string(),
|
||||
})
|
||||
}
|
||||
PortfolioMessage::CloseActiveDocumentWithConfirmation => {
|
||||
|
||||
Reference in New Issue
Block a user