[Bf-committers] exit in blender
Diego Hernan Borghetti
bdiego at gmail.com
Wed Apr 23 01:42:12 CEST 2008
On Tue, 22 Apr 2008, Gustav G?ransson wrote:
> Isn't that pretty much what the quit.blend does now? And have blender
> erase auto-save files when the user saves is a bad idea. There are
> times when make changes that you don't want to save (ex. apply
> modfiers, multires) but save anyway by mistake. In those cases it's
> good to be able to go back previous, auto-saved versions.
>
> As matt said, artist can work hours without closing blender and saving
> a second of that time not answering a pop-up isn't much of a benefit.
> Restoring quit.blend (browse, check that it's the right file, move and
> renaming the file) can take minutes, so if quit blender by mistake
> alot a pop-up could actually be faster in the long run...
>
> I don't see the problem with adding a pop-up feature and make it
> optional, especially if there's already a patch for it?
>
> On Tue, Apr 22, 2008 at 2:44 PM, lguillaume <lecocqguillaume at gmail.com> wrote:
>> Hello, we have auto save feature which save the file all x minutes, just add
>> the saved file in the installation or .blender directory, when users saves
>> his file, Blender erase the auto-save file.
>>
>> When a crash or a close accident happen, if the auto save file exists,
>> Blender can ask to open the file. And we rego for the same cycle, if user
>> save, Blender erase the file, ...
>>
>> This can (perhaps) solve the problem, no dialog box for asking to save at
>> closing, but a security for inadvertance closing.
>>
>>
>>
>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
Hello all:
To add my two cent to this "little fight", I attach the patch that we
have in plumiferos, it's really simple and optional (is disabled by
default), you can enable it from:
User Pref -> Auto Save -> Check File Changes
The patch also ask if you try open/load a new file and the current file
have changes.
Also note that this patch don't show the "standard" options ("save",
"discard", "cancel"), just ask confirmation to quit and nothing more.
--
Diego
-------------- next part --------------
Index: source/blender/blenkernel/intern/blender.c
===================================================================
--- source/blender/blenkernel/intern/blender.c (revision 14522)
+++ source/blender/blenkernel/intern/blender.c (working copy)
@@ -227,6 +227,7 @@
G.charstart = 0x0000;
G.charmin = 0x0000;
G.charmax = 0xffff;
+ G.blend_change = 0;
}
/***/
Index: source/blender/blenkernel/BKE_global.h
===================================================================
--- source/blender/blenkernel/BKE_global.h (revision 14522)
+++ source/blender/blenkernel/BKE_global.h (working copy)
@@ -152,6 +152,10 @@
/* confusing... G.f and G.flags */
int flags;
+ /* ref count for "have change" popup and yes, need a better
+ * implementation in 2.50 ;)
+ */
+ short blend_change;
} Global;
/* **************** GLOBAL ********************* */
Index: source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- source/blender/makesdna/DNA_userdef_types.h (revision 14522)
+++ source/blender/makesdna/DNA_userdef_types.h (working copy)
@@ -267,6 +267,7 @@
#define USER_ZOOM_TO_MOUSEPOS (1 << 20)
#define USER_SHOW_FPS (1 << 21)
#define USER_MMB_PASTE (1 << 22)
+#define USER_CONFIRM_QUIT (1 << 23)
/* Auto-Keying mode */
/* AUTOKEY_ON is a bitflag */
Index: source/blender/src/drawscript.c
===================================================================
--- source/blender/src/drawscript.c (revision 14522)
+++ source/blender/src/drawscript.c (working copy)
@@ -161,7 +161,7 @@
}
else {
if (event == QKEY)
- if (val && (G.qual & LR_CTRLKEY) && okee("Quit Blender")) exit_usiblender();
+ if (val && (G.qual & LR_CTRLKEY)) exit_usiblender();
}
return;
Index: source/blender/src/drawtext.c
===================================================================
--- source/blender/src/drawtext.c (revision 14522)
+++ source/blender/src/drawtext.c (working copy)
@@ -1508,7 +1508,7 @@
}
else if (event==QKEY) {
if (G.qual & LR_CTRLKEY) {
- if(okee("Quit Blender")) exit_usiblender();
+ exit_usiblender();
}
}
else if (event==NKEY) {
@@ -1731,7 +1731,7 @@
}
break; /* BREAK P */
case QKEY:
- if(okee("Quit Blender")) exit_usiblender();
+ exit_usiblender();
break; /* BREAK Q */
case RKEY:
if (G.qual == LR_ALTKEY) {
Index: source/blender/src/editscreen.c
===================================================================
--- source/blender/src/editscreen.c (revision 14522)
+++ source/blender/src/editscreen.c (working copy)
@@ -1402,7 +1402,7 @@
else if((G.obedit && G.obedit->type==OB_FONT && g_activearea->spacetype==SPACE_VIEW3D)||g_activearea->spacetype==SPACE_TEXT||g_activearea->spacetype==SPACE_SCRIPT);
else {
if(val && (G.qual == LR_CTRLKEY)) {
- if(okee("Quit Blender")) exit_usiblender();
+ exit_usiblender();
}
towin= 0;
}
Index: source/blender/src/space.c
===================================================================
--- source/blender/src/space.c (revision 14522)
+++ source/blender/src/space.c (working copy)
@@ -988,6 +988,8 @@
void BIF_undo_push(char *str)
{
+ G.blend_change++;
+
if(G.obedit) {
if (U.undosteps == 0) return;
@@ -1014,7 +1016,10 @@
}
void BIF_undo(void)
-{
+{
+ if (G.blend_change > 0)
+ G.blend_change--;
+
if(G.obedit) {
if ELEM7(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)
undo_editmode_step(1);
@@ -4072,7 +4077,12 @@
(xpos+edgsp+(3*mpref)+(4*midsp)),y3,mpref,buth,
&(U.flag), 0, 0, 0, 0,
"Enables automatic saving of preview images in the .blend file");
-
+
+ uiDefButBitI(block, TOG, USER_CONFIRM_QUIT, 0, "Check File Changes",
+ (xpos+edgsp+(3*mpref)+(4*midsp)),y2,mpref,buth,
+ &(U.uiflag), 0, 0, 0, 0,
+ "Ask confirmation to Quit if the current file has been modified before close or open a new file");
+
} else if (U.userpref == 4) { /* system & opengl */
int memcachemax;
if (sizeof(void *) ==8) memcachemax = 1024*16; /* 64bit system, 16 gig of ram would be nice */
Index: source/blender/src/usiblender.c
===================================================================
--- source/blender/src/usiblender.c (revision 14522)
+++ source/blender/src/usiblender.c (working copy)
@@ -544,6 +544,12 @@
}
#endif
+ if ((U.uiflag & USER_CONFIRM_QUIT) && G.blend_change) {
+ if (!okee("The file has been modified. Continue anyway ?"))
+ return;
+ G.blend_change= 0;
+ }
+
/* first try to read exotic file formats... */
/* it throws error box when file doesnt exist and returns -1 */
retval= BKE_read_exotic(name);
@@ -920,6 +926,7 @@
G.save_over = 1;
writeBlog();
+ G.blend_change = 0;
} else {
error("%s", err);
}
@@ -1041,7 +1048,21 @@
void exit_usiblender(void)
{
struct TmpFont *tf;
-
+
+ /* Ok, I don't want remove the "Quit" popup, but maybe
+ * we can ask only one of both, if the file have changes
+ * show only the "The file..." and if the file don't have
+ * change show the "Quit", but for now, just show the
+ * "Quit" always.
+ */
+ if (!okee("Quit Blender"))
+ return;
+
+ if ((U.uiflag & USER_CONFIRM_QUIT) && G.blend_change) {
+ if (!okee("The file has been modified. Quit anyway ?"))
+ return;
+ }
+
BIF_clear_tempfiles();
tf= G.ttfdata.first;
More information about the Bf-committers
mailing list